sudo /etc/init.d/postgresql restart(如何select安装?)

我有两个postgresql安装:

$ sudo /etc/init.d/postgresql status 9.1/main (port 5432): online 9.2/main (port 5433): online 

我被用来重新启动postgres数据库做一个:

 $ sudo /etc/init.d/postgresql restart 

…但现在有两个,如何select重启?

更新 :继我从Micah Yoder收到的答复,我做了一个:

 /usr/lib/postgresql/9.2/bin/pg_ctl -D /var/lib/postgresql/9.2/main restart 

遇到“无法打开PID文件/var/lib/postgresql/9.2/main/main/postmaster.pid权限被拒绝”。 当我试图在sudo-i会话中运行pg_ctl时 ,遇到了:

 pg_ctl: cannot be run as root Please log in (using, eg, "su") as the (unprivileged) user that will own the server process. 

我该如何运行pg_ctl程序? 另外我不明白为什么我必须指出重新启动数据文件。 该进程不知道它正在使用哪个数据文件?

更新2最后,我放弃了pg_ctl ,做了一个:

 sudo /etc/init.d/postgresql restart 9.2 

按照接受的答案。

如果你使用debian,你可以告诉init脚本,你想要pipe理哪个版本:

 pg01:~# /etc/init.d/postgresql Usage: /etc/init.d/postgresql {start|stop|restart|reload|force-reload|status} [version ..] pg01:~# 

首先,你有意或者两个并排运行,或者你是从一个不同的软件包安装9.2,它没有删除9.1? (Postgres包通常是这样设置的。)如果你已经迁移了,那么9.1应该被删除。

如果你同时需要,那么每个应该有它自己的pg_ctl可执行文件,它可以和普通的initscript做同样的事情。 作为'postgres'用户运行它。 请参阅… / path / bin / pg_ctl –help

你可能有两个postgresql实例运行时使用两个不同的configuration文件,名为postgresql.conf,存储在两个地方。

您应该检查/etc/sysconfig/pgsql/postgresqlconfiguration文件以validation它用于/etc/init.d/postgresql哪个pgsql。 它必须具有存储postgresql.conf文件的pgsql目录的位置。 在这个conf文件中,将会有特定pgsql的端口号。