我的服务器系统是:
$ lsb_release -d
Description: Red Hat Enterprise Linux Server release 7.5 (Maipo)
一般来说,我在该服务器上有一个运行 postgres:11 的 Dockerized 数据库,粗略地说,我需要从中创建一个数据库转储。
通过输入:
$ sudo yum install postgresql
我可以在版本 9 中安装 postgresql clinet (包括 pg_dump、psql 等)。但它无法从 postgresql:11 数据库创建转储,所以我在以下位置找到了建议:https://www.symmcom.com/docs/how-tos/databases/how-to-install-postgresql-11-x-on-centos-7
我一步一步做了:
step 1: $ sudo yum update -y # I didn't sudo reboot as I wanted to avoid server to not start again and ghaving to ask IT support for restarting it for me
step 2: $ sudo rpm -Uvh https://yum.postgresql.org/11/redhat/rhel-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
step 3: $ sudo yum install postgresql11 -y
奇怪的是——这是它第一次安装并工作。然而,注销/登录后,我仍然将最初预安装的postgresql:9
作为第一选择,所以我删除了所有 postgresqlyum remove postgresql postgresql11
我再次尝试执行上述步骤 1-3,但我得到:
$ sudo yum install postgresql11 -y
Loaded plugins: langpacks, product-id, rhnplugin, search-disabled-repos
This system is not registered with RHN Classic or Red Hat Satellite.
You can use rhn_register to register.
Red Hat Satellite or RHN Classic support will be disabled.
No package postgresql11 available.
Error: Nothing to do
你能帮我解释为什么当我尝试再次安装 postgresql11 包时看不到它吗?
我尝试清理 yum 缓存,但没有帮助。
日志来自yum list
:
$ sudo yum list | grep postgresql
This system is not registered with RHN Classic or Red Hat Satellite.
You can use rhn_register to register.
Red Hat Satellite or RHN Classic support will be disabled.
postgresql.x86_64 9.2.24-2.el7_7 @GSS-RHEL7
postgresql-devel.x86_64 9.2.24-2.el7_7 @GSS-RHEL7
postgresql-libs.x86_64 9.2.24-2.el7_7 @GSS-RHEL7
postgresql11-libs.x86_64 11.7-1PGDG.rhel7 @pgdg11
qt-postgresql.x86_64 1:4.8.7-4.el7 @GSS-RHEL7
qt5-qtbase-postgresql.x86_64 5.9.7-2.el7 @GSS-RHEL7
freeradius-postgresql.x86_64 3.0.13-10.el7_6 GSS-RHEL7-optional
libreoffice-postgresql.x86_64 1:5.3.6.1-21.el7 GSS-RHEL7-optional
pcp-pmda-postgresql.x86_64 4.3.2-4.el7_7 GSS-RHEL7
postgresql.i686 9.2.24-2.el7_7 GSS-RHEL7
postgresql-contrib.x86_64 9.2.24-2.el7_7 GSS-RHEL7
postgresql-devel.i686 9.2.24-2.el7_7 GSS-RHEL7
postgresql-docs.x86_64 9.2.24-2.el7_7 GSS-RHEL7
postgresql-jdbc.noarch 9.2.1002-6.el7_5 GSS-RHEL7
postgresql-jdbc-javadoc.noarch 9.2.1002-6.el7_5 GSS-RHEL7-optional
postgresql-libs.i686 9.2.24-2.el7_7 GSS-RHEL7
postgresql-odbc.x86_64 09.03.0100-2.el7 GSS-RHEL7
postgresql-plperl.x86_64 9.2.24-2.el7_7 GSS-RHEL7
postgresql-plpython.x86_64 9.2.24-2.el7_7 GSS-RHEL7
postgresql-pltcl.x86_64 9.2.24-2.el7_7 GSS-RHEL7
postgresql-server.x86_64 9.2.24-2.el7_7 GSS-RHEL7
postgresql-static.i686 9.2.24-2.el7_7 GSS-RHEL7-optional
postgresql-static.x86_64 9.2.24-2.el7_7 GSS-RHEL7-optional
postgresql-test.x86_64 9.2.24-2.el7_7 GSS-RHEL7
postgresql-upgrade.x86_64 9.2.24-2.el7_7 GSS-RHEL7-optional
qt-postgresql.i686 1:4.8.7-4.el7 GSS-RHEL7
qt5-qtbase-postgresql.i686 5.9.7-2.el7 GSS-RHEL7
答案1
解决了:
我不确定这是否是正确的方法,但我用帮助我的解决方案做出回应:
从 RPM 管理器我强制使用 postgresql11 重新安装包https://www.redhat.com/archives/rpm-list/2005-September/msg00030.html
经过:
$ rpm -Uvh https://yum.postgresql.org/11/redhat/rhel-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm --replacepkgs
然后我删除了原来安装的 postgresql 版本。 9
$ yum remove postgresql
最后:
$ sudo yum install postgresql11-server postgresql11 -y
Loaded plugins: langpacks, product-id, rhnplugin, search-disabled-repos
This system is not registered with RHN Classic or Red Hat Satellite.
You can use rhn_register to register.
Red Hat Satellite or RHN Classic support will be disabled.
Resolving Dependencies
--> Running transaction check
---> Package postgresql11.x86_64 0:11.7-1PGDG.rhel7 will be installed
---> Package postgresql11-server.x86_64 0:11.7-1PGDG.rhel7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=================================================================================================================================================================================================================
Package Arch Version Repository Size
=================================================================================================================================================================================================================
Installing:
postgresql11 x86_64 11.7-1PGDG.rhel7 pgdg11 1.7 M
postgresql11-server x86_64 11.7-1PGDG.rhel7 pgdg11 4.7 M
Transaction Summary
=================================================================================================================================================================================================================
Install 2 Packages
Total download size: 6.4 M
Installed size: 28 M
Downloading packages:
(1/2): postgresql11-11.7-1PGDG.rhel7.x86_64.rpm | 1.7 MB 00:00:00
(2/2): postgresql11-server-11.7-1PGDG.rhel7.x86_64.rpm | 4.7 MB 00:00:00
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 8.8 MB/s | 6.4 MB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : postgresql11-11.7-1PGDG.rhel7.x86_64 1/2
Installing : postgresql11-server-11.7-1PGDG.rhel7.x86_64 2/2
Verifying : postgresql11-server-11.7-1PGDG.rhel7.x86_64 1/2
Verifying : postgresql11-11.7-1PGDG.rhel7.x86_64 2/2
Installed:
postgresql11.x86_64 0:11.7-1PGDG.rhel7 postgresql11-server.x86_64 0:11.7-1PGDG.rhel7
Complete!
它对我有用,也许--replacepkgs
向 rpm 管理器添加选项会对某人有所帮助,但我不确定为什么需要它?