linux 如何管理多个PostgreSQL安装

col17t5w  于 5个月前  发布在  Linux
关注(0)|答案(1)|浏览(84)

我有Ubuntu服务器20.04与postgresql 13与postgis在使用中.我想逐步迁移到postgres 16,通过有两个版本并排一段时间和移动数据库一个接一个.但首先我需要“清理”我安装的软件包我猜,我不知道最好的方法来做到这一点,而不是打破我的postgres 13安装.
首先,我列出了与postgres相关的已安装软件包:

me@myserver:/$ apt list --installed | grep postgre

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

postgresql-13-postgis-3-scripts/now 3.4.0+dfsg-1.pgdg20.04+1 all [installed,upgradable to: 3.4.1+dfsg-1.pgdg20.04+1]
postgresql-13-postgis-3/now 3.4.0+dfsg-1.pgdg20.04+1 amd64 [installed,upgradable to: 3.4.1+dfsg-1.pgdg20.04+1]
postgresql-13/now 13.12-1.pgdg20.04+1 amd64 [installed,upgradable to: 13.13-1.pgdg20.04+1]
postgresql-15-postgis-3-scripts/now 3.4.0+dfsg-1.pgdg20.04+1 all [installed,upgradable to: 3.4.1+dfsg-1.pgdg20.04+1]
postgresql-15-postgis-3/now 3.4.0+dfsg-1.pgdg20.04+1 amd64 [installed,upgradable to: 3.4.1+dfsg-1.pgdg20.04+1]
postgresql-15/now 15.4-1.pgdg20.04+1 amd64 [installed,upgradable to: 15.5-1.pgdg20.04+1]
postgresql-client-13/now 13.12-1.pgdg20.04+1 amd64 [installed,upgradable to: 13.13-1.pgdg20.04+1]
postgresql-client-15/now 15.4-1.pgdg20.04+1 amd64 [installed,upgradable to: 15.5-1.pgdg20.04+1]
postgresql-client-common/now 241.pgdg20.04+1 all [installed,upgradable to: 256.pgdg20.04+1]
postgresql-common/now 241.pgdg20.04+1 all [installed,upgradable to: 256.pgdg20.04+1]
postgresql-postgis-scripts/now 3.4.0+dfsg-1.pgdg20.04+1 all [installed,upgradable to: 3.4.1+dfsg-1.pgdg20.04+1]
postgresql-postgis/now 3.4.0+dfsg-1.pgdg20.04+1 amd64 [installed,upgradable to: 3.4.1+dfsg-1.pgdg20.04+1]

字符串
我就想“搞什么鬼,我装了postgres 15?”

me@myserver:/$ pg_lsclusters
Ver Cluster Port Status Owner    Data directory               Log file
13  main    5432 online postgres /dataraid/postgresql/13/main log/postgresql-%Y-%m-%d_%H%M%S.log
15  main    5433 online postgres /var/lib/postgresql/15/main  /var/log/postgresql/postgresql-15-main.log


是的,我有,它甚至运行,甚至没有我知道这一点。我猜它得到安装有时当我做apt upgrade,因为我有postgresql-postgis虚拟包安装?是假设正确?
好吧,我不想要它,所以让我们卸载它:

root@myserver:/# apt remove postgresql-15-postgis-3
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libboost-serialization1.71.0 libfwupdplugin1 libgmpxx4ldbl libjson-perl libllvm10 libllvm9 libprotobuf-c1 libsfcgal1 libxmlb1 pgdg-keyring
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  postgresql-client-common
The following packages will be REMOVED:
  pgbouncer postgresql-13 postgresql-13-postgis-3 postgresql-15 postgresql-15-postgis-3 postgresql-common postgresql-postgis
The following packages will be upgraded:
  postgresql-client-common
1 upgraded, 0 newly installed, 7 to remove and 24 not upgraded.
Need to get 94.0 kB of archives.
After this operation, 127 MB disk space will be freed.
Do you want to continue? [Y/n] n
Abort.


不,我也想删除我的PostGres 13。
所以,几个问题:
1.如何安全地卸载postgres 15在我的情况下,留下postgres 13不变?
1.如何确保今后不再发生这种情况?
1.如何安装postgres 16“正确的方式”?(我猜apt install postgresql-16-postgis-3 specifically?)

mkshixfv

mkshixfv1#

在某些情况下,为Postgres安装某些开发包或库会带来额外的版本。您也可以通过dpkg -l | grep postgresql查找Postgres版本。然后禁用Postgres服务,sudo systemctl disable postgresql。为了确保Postgres-15完全删除,甚至其配置文件,请执行sudo apt-get purge postgresql-15-postgis-3。通过sudo apt autoremove删除依赖项。您可能需要删除数据目录:sudo rm -rf /var/lib/postgres。首先安装Postgres-16 sudo apt-get -y install postgresql-16,然后在其上构建postgis扩展。

相关问题