刚刚将 Ubuntu 升级到最新版本,但现在我有两个 Postgres 实例。
8.4 和 9.1
问题是我不知道第二个在哪个端口上运行?
如何检测正在运行的端口....
如果我运行 cristi@cristi-hp:/usr/share/postgresql-common$ sudo -u postgres psql psql (8.4.8) 输入“help”以获得帮助。
如何在 9.1 中使用 psql?
两者似乎都在运行:cristi@cristi-hp:/usr/share/postgresql-common$ sudo /etc/init.d/postgresql start [sudo] cristi 的密码:* 启动 PostgreSQL 8.4 数据库服务器 [OK] * 启动 PostgreSQL 9.1数据库服务器
谢谢...
小智 7
如果您只想找到当前运行的端口和/或布局,您需要做的就是运行“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
Run Code Online (Sandbox Code Playgroud)
正如您所见,Ubuntu 作为基于 Debian 的系统能够运行多个 Postgres 实例。通常,除非另有配置,否则第一个启动的实例将具有默认的 Postgres 端口,并且每个后续实例将采用下一个更高的端口(如果可用)。这些端口可以在下面的配置文件中定义,/etc/postgresql/<version>/<cluster>/
这样它们就不会在您需要时更改,但我实际上需要更改。事实上,粗略地看一下/etc/init.d/postgresql
也会告诉你你可以通过/etc/postgresql/<version>/<cluster>/environment
.
包管理器甚至非常好,/usr/share/doc/postgresql-common/README.Debian.gz
其中有一个部分可以快速解释如何处理集群管理,包括pg_lsclusters
命令,该命令将为您提供 Postgres 版本和端口号以及有关每个配置集群的其他详细信息。
要回答有关停止实例的评论中的问题...您可以编辑下的start.conf
文件/etc/postgresql/<version>/<cluster>/
并将其从auto更改为disabled或manual。引用默认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).
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
8167 次 |
最近记录: |