大网数据广告活动
服务器运维问答

Managing multiple postgres versions on CentOS

· 52CE 我爱测

I have the following packages installed with yum : Installed Packages postgresql92.x86_64 9.2.24-1.65.amzn1 @amzn-updates postgresql92-libs.x86_64 9.2.24-1.65.amzn1 @amzn-updates postgresql92-server.x86_64 9.2.24-1.65.amzn1 @amzn…

问题原文

原帖链接 · Avery235 · CC BY-SA 3.0

I have the following packages installed with yum:

Installed Packages
postgresql92.x86_64                                                                                                  9.2.24-1.65.amzn1                                                                                   @amzn-updates
postgresql92-libs.x86_64                                                                                             9.2.24-1.65.amzn1                                                                                   @amzn-updates
postgresql92-server.x86_64                                                                                           9.2.24-1.65.amzn1                                                                                   @amzn-updates
postgresql92-server-compat.x86_64                                                                                    9.2.24-1.65.amzn1                                                                                   @amzn-updates
postgresql95.x86_64                                                                                                  9.5.10-1.77.amzn1                                                                                   @amzn-updates
postgresql95-libs.x86_64                                                                                             9.5.10-1.77.amzn1                                                                                   @amzn-updates
postgresql95-server.x86_64                                                                                           9.5.10-1.77.amzn1                                                                                   @amzn-updates

But I can't seem to control them individually:

/home/ec2-user$ sudo service postgresql95 stop
Stopping postgresql95 service:                             [  OK  ]
/home/ec2-user$ sudo service postgresql95 status
postmaster (pid  43442) is running...
/home/ec2-user$ sudo service postgresql92 status
postmaster (pid  43442) is running...

Why are they having the same pid?

Also I only have 1 configuration file, located in /var/lib/pgsql9/data/postgresql.conf.

已采纳解答

原帖链接 · Pierre-Alain TORET · CC BY-SA 3.0

First go to this page and download the appropriate packages for CentOS 6 (as you mentionned using service and not systemd)

Once setup you can install both postgresql92-server and postgresql95-server through the commend yum install postgresql92-server postgresql95-server.

You have to manually init the databases like the following service postgresql-9.2 initdb and service postgresql-9.5 initdb. That will create 2 different databases directories in /var/lib/pgsql, 9.2 and 9.5 and initialize a database inside of each data subdirectory.

Once this is done you can start each instance with its own service comand service postgresql-9.2 start and service postgresql-9.5 start. But not both at the same time as they're using the same 5432 port.

9.2 port can be edited in /etc/init.d/postgresql-9.2 with variable PGPORT 9.5 port can be edited in /var/lib/pgsql/9.5/data/postgresql.conf with the variable port. So you can use both instances at the same time.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-03-22)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。