刚升级Ubuntu到最新版本,但现在我有两个Postgres的实例。
8.4和9.1
问题是我不知道第二个端口在运行什么端口?
我怎样才能检测什么端口正在运行….
如果我运行cristi @ cristi-hp:/ usr / share / postgresql-common $ sudo -u postgres psql psql(8.4.8)input“help”获取帮助。
我怎样才能使用psql 9.1?
两个似乎运行:cristi @ cristi-hp:/ usr / share / postgresql-common $ sudo /etc/init.d/postgresql start [sudo] password for cristi:*启动PostgreSQL 8.4数据库服务器[OK] *启动PostgreSQL 9.1数据库服务器
谢谢…
Ubuntu是一个基于Debian的系统,可以运行多个Postgres实例。 一般情况下,除非另有configuration,否则第一个实例将启用默认的Postgres端口,如果可用,每个后续实例将采用下一个更高的端口。 这些端口可以在/etc/postgresql/<version>/<cluster>/下的configuration文件中定义,以便在需要时不会更改,但实际上需要。 实际上,粗略看一下/etc/init.d/postgresql也会告诉你可以通过/etc/postgresql/<version>/<cluster>/environment设置环境variables。
软件包pipe理者甚至可以包含/usr/share/doc/postgresql-common/README.Debian.gz ,它有一个快速解释如何处理集群pipe理的部分,包括pg_lsclusters命令,它将为您提供Postgres版本和端口号以及关于每个configuration的集群的其他好的细节。
要回答关于停止实例的注释问题…您可以编辑/etc/postgresql/<version>/<cluster>/下的start.conf文件,并将其从自动更改为禁用或手动 。 引用默认的start.conf文件本身…
# Automatic startup configuration # auto: automatically start/stop the cluster in the init script # manual: do not start/stop in init scripts, but allow manual startup with # pg_ctlcluster # disabled: do not allow manual startup with pg_ctlcluster (this can be easily # circumvented and is only meant to be a small protection for # accidents).
如果您只想查找当前正在运行的端口和/或布局,则只需运行“pg_lsclusters”
rtreat@xdw1:~$ pg_lsclusters Version Cluster Port Status Owner Data directory Log file 9.0 data1 5432 online postgres /var/lib/postgresql/9.0/data1 /var/log/postgresql/postgresql-9.0-data1.log 9.0 data2 5488 online postgres /var/lib/postgresql/9.0/data2 /var/log/postgresql/postgresql-9.0-data2.log 9.0 data3 5499 online postgres /var/lib/postgresql/9.0/data3 /var/log/postgresql/postgresql-9.0-data3.log 9.0 sanitize1 6544 online postgres /var/lib/postgresql/9.0/sanitize1 /var/log/postgresql/postgresql-9.0-sanitize1.log 9.0 sanitize2 6543 online postgres /var/lib/postgresql/9.0/sanitize2 /var/log/postgresql/postgresql-9.0-sanitize2.log