2个PostgreSQL实例,但我真的需要一个 [英] 2 instances of postgresql but I really need one

查看:106
本文介绍了2个PostgreSQL实例,但我真的需要一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的机器上碰巧安装了2个postgresql实例:9.1和9.2:

I happen to have 2 installed instances of postgresql at my machine: 9.1 and 9.2:

sudo service postgresql status
9.1/main (port 5432): down
9.2/main (port 5433): down

它们位于 /etc/postgresql/9.1 / /etc/postgresql/9.2 / 中。然后我说 sudo service postgresql start

They are located at /etc/postgresql/9.1/ and /etc/postgresql/9.2/. Then I run 9.2 by saying sudo service postgresql start

9.2 >但是此命令失败:

But this command fails:

$ psql
psql: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

我真的只想使用 9.2 ,我不需要2个实例。

I really want to use 9.2 only, I don't need 2 instances.

您是否知道如何安全地删除 9.1 或使 9.2 是主要的默认实例?

Do you have any idea of how to either remove 9.1 safely or make 9.2 to be the main, default instance?

推荐答案

在升级时,可能会在Ubuntu中出现两个群集的情况

This situation with two clusters in Ubuntu may happen when upgrading to a newer release providing an newer postgresql version.

自动升级不会删除旧集群,大概是因为担心会擦除有价值的数据(这是明智的,因为某些postgres升级

The automatic upgrade does not remove the old cluster, presumably for fear of erasing valuable data (which is wise because some postgres upgrades may require human work to be complete).

如果您知道要删除它,只需运行:

If you know you want to drop it, just run:

sudo pg_dropcluster --stop 9.1 main 

对应的数据目录将被删除,服务postgresql 将不再引用9.1

The corresponding data directory will be removed and service postgresql will no longer refer to 9.1

此时9.2群集仍将使用端口5433,这是不切实际的。

At this point the 9.2 cluster will still use the port 5433, which is unpractical.

要将其切换为默认端口,请编辑 /etc/postgresql/9.2/main/postgresql.conf 并将行 port = 5433 更改为 port = 5432

To switch it to the default port, edit /etc/postgresql/9.2/main/postgresql.conf and change the line port = 5433 to port = 5432

然后重新启动PostgreSQL。

Then restart PostgreSQL.

最后要摆脱postgresql-9.1软件包,请参见 dpkg -l'postgresql的结果* 9.1 *'

Finally to get rid of the postgresql-9.1 packages see the result of dpkg -l 'postgresql*9.1*'

这篇关于2个PostgreSQL实例,但我真的需要一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆