安装了太多的 postgresql 版本:如何仅启动选定的 postgresql 版本或删除不需要的版本?需要的端口是标准的“5432" [英] Too many postgresql versions installed: How to start only a chosen postgresql version or remove the unneeded ones? Needed port is the standard "5432"

查看:22
本文介绍了安装了太多的 postgresql 版本:如何仅启动选定的 postgresql 版本或删除不需要的版本?需要的端口是标准的“5432"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我安装了两个版本的 postgresql,1213(在这个问题的早期版本中,它们是 9.1>9.2,我将其更改为与更高版本添加的输出详细信息一致).

I have installed two versions of postgresql, 12 and 13 (in an earlier version of this question, these were 9.1 and 9.2, I change this to be in line with the added output details from the higher versions).

sudo service postgresql status
12/main (port 5432): down
13/main (port 5433): down

它们位于 /etc/postgresql/12//etc/postgresql/13/.

在版本 13 上安装扩展后:

After installing an extension on version 13:

sudo apt-get install postgresql-contrib postgresql-plpython3-13

启动 postgresql 服务:

start the postgresql service:

sudo service postgresql start

输出:

 * Starting PostgreSQL 12 database server                                                                                                                                                                                             
 * Starting PostgreSQL 13 database server

现在让我们在数据库中创建扩展,运行:

Now let us create the extension in the database, running:

sudo su - postgres

然后:

postgres=# psql
psql (13.4 (Ubuntu 13.4-1.pgdg20.04+1), server 12.7 (Ubuntu 12.7-0ubuntu0.20.04.1))
Type "help" for help.

postgres=# CREATE EXTENSION plpython3u;
ERROR:  could not open extension control file "/usr/share/postgresql/12/extension/plpython3u.control": No such file or directory

虽然我已经将postgresql-python3u安装到13版本的目录中,但我们看到在12版本中搜索了扩展.

We see that the extension is searched in version 12 although I have installed the postgresql-python3u to the directory of version 13.

我只想使用 13 版本,我不需要两个不同的版本,而且 psql 似乎默认选择了启动服务的最低可用 postgresql 版本,而不是我需要的最高版本.

I want to use version 13 only, I don't need two different versions, and psql seems to choose the lowest available postgresql version of the started services by default, not the highest which I need.

如何安全删除版本 12 或使 13 成为唯一启动(或默认)的服务,也使用标准端口 5432版本 13?

How to either remove version 12 safely or make 13 the only started (or default) service, also using the standard port 5432 for version 13?

推荐答案

当升级到提供较新 postgresql 版本的较新版本时,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 

相应的数据目录将被删除,service 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*'

这篇关于安装了太多的 postgresql 版本:如何仅启动选定的 postgresql 版本或删除不需要的版本?需要的端口是标准的“5432"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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