默认的yum 安装命令如下:
yum install postgresql
该命令会安装较低版本的PostgreSQL 8.4,具体过程如下:
[root@April ~]# yum install postgresql
Loaded plugins: fastestmirror, security
Determining fastest mirrors
* base: mirrors.163.com
* extras: mirrors.163.com
* updates: mirrors.163.com
base | 3.7 kB 00:00
extras | 3.3 kB 00:00
extras/primary_db | 20 kB 00:00
updates | 3.4 kB 00:00
updates/primary_db | 3.1 MB 00:00
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package postgresql.i686 0:8.4.20-8.el6_9 will be installed
--> Processing Dependency: postgresql-libs(x86-32) = 8.4.20-8.el6_9 for package: postgresql-8.4.20-8.el6_9.i686
--> Processing Dependency: libpq.so.5 for package: postgresql-8.4.20-8.el6_9.i686
--> Running transaction check
---> Package postgresql-libs.i686 0:8.4.20-8.el6_9 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===============================================================================================================================
Package Arch Version Repository Size
===============================================================================================================================
Installing:
postgresql i686 8.4.20-8.el6_9 base 2.6 M
Installing for dependencies:
postgresql-libs i686 8.4.20-8.el6_9 base 206 k
Transaction Summary
===============================================================================================================================
Install 2 Package(s)
Total download size: 2.8 M
Installed size: 14 M
Is this ok [y/N]: y
Downloading Packages:
(1/2): postgresql-8.4.20-8.el6_9.i686.rpm | 2.6 MB 00:00
(2/2): postgresql-libs-8.4.20-8.el6_9.i686.rpm | 206 kB 00:00
-------------------------------------------------------------------------------------------------------------------------------
Total 1.8 MB/s | 2.8 MB 00:01
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : postgresql-libs-8.4.20-8.el6_9.i686 1/2
Installing : postgresql-8.4.20-8.el6_9.i686 2/2
Verifying : postgresql-8.4.20-8.el6_9.i686 1/2
Verifying : postgresql-libs-8.4.20-8.el6_9.i686 2/2
Installed:
postgresql.i686 0:8.4.20-8.el6_9
Dependency Installed:
postgresql-libs.i686 0:8.4.20-8.el6_9
Complete!
如果我们想安装最新版本的PostgreSQL ,该命令显然不符合我们的要求。卸载上述低版本的PostgreSQL 8.4,命令如下:
yum remove postgresql*
具体过程如下:
[root@April ~]# yum remove postgresql*
Loaded plugins: fastestmirror, security
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package postgresql.i686 0:8.4.20-8.el6_9 will be erased
---> Package postgresql-libs.i686 0:8.4.20-8.el6_9 will be erased
--> Finished Dependency Resolution
Dependencies Resolved
===============================================================================================================================
Package Arch Version Repository Size
===============================================================================================================================
Removing:
postgresql i686 8.4.20-8.el6_9 @base 14 M
postgresql-libs i686 8.4.20-8.el6_9 @base 614 k
Transaction Summary
===============================================================================================================================
Remove 2 Package(s)
Installed size: 14 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Erasing : postgresql-8.4.20-8.el6_9.i686 1/2
Erasing : postgresql-libs-8.4.20-8.el6_9.i686 2/2
Verifying : postgresql-8.4.20-8.el6_9.i686 1/2
Verifying : postgresql-libs-8.4.20-8.el6_9.i686 2/2
Removed:
postgresql.i686 0:8.4.20-8.el6_9 postgresql-libs.i686 0:8.4.20-8.el6_9
Complete!
[root@April ~]# rpm -i http://yum.postgresql.org/9.2/redhat/rhel-6-x86_64/pgdg-centos92-9.2-8.noarch.rpm
[root@April ~]# yum install postgresql92-server postgresql92-contrib
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.163.com
* updates: mirrors.163.com
pgdg92 | 4.1 kB 00:00
pgdg92/primary_db | 131 kB 00:00
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package postgresql92-contrib.i686 0:9.2.24-5PGDG.rhel6 will be installed
--> Processing Dependency: postgresql92 = 9.2.24 for package: postgresql92-contrib-9.2.24-5PGDG.rhel6.i686
--> Processing Dependency: libpq.so.5 for package: postgresql92-contrib-9.2.24-5PGDG.rhel6.i686
--> Processing Dependency: libossp-uuid.so.16 for package: postgresql92-contrib-9.2.24-5PGDG.rhel6.i686
---> Package postgresql92-server.i686 0:9.2.24-5PGDG.rhel6 will be installed
--> Running transaction check
---> Package postgresql92.i686 0:9.2.24-5PGDG.rhel6 will be installed
---> Package postgresql92-libs.i686 0:9.2.24-5PGDG.rhel6 will be installed
---> Package uuid.i686 0:1.6.1-10.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===============================================================================================================================
Package Arch Version Repository Size
===============================================================================================================================
Installing:
postgresql92-contrib i686 9.2.24-5PGDG.rhel6 pgdg92 444 k
postgresql92-server i686 9.2.24-5PGDG.rhel6 pgdg92 3.9 M
Installing for dependencies:
postgresql92 i686 9.2.24-5PGDG.rhel6 pgdg92 996 k
postgresql92-libs i686 9.2.24-5PGDG.rhel6 pgdg92 198 k
uuid i686 1.6.1-10.el6 base 54 k
Transaction Summary
===============================================================================================================================
Install 5 Package(s)
Total download size: 5.6 M
Installed size: 23 M
Is this ok [y/N]: y
Downloading Packages:
(1/5): postgresql92-9.2.24-5PGDG.rhel6.i686.rpm | 996 kB 00:01
(2/5): postgresql92-contrib-9.2.24-5PGDG.rhel6.i686.rpm | 444 kB 00:00
(3/5): postgresql92-libs-9.2.24-5PGDG.rhel6.i686.rpm | 198 kB 00:00
(4/5): postgresql92-server-9.2.24-5PGDG.rhel6.i686.rpm | 3.9 MB 00:01
(5/5): uuid-1.6.1-10.el6.i686.rpm | 54 kB 00:00
-------------------------------------------------------------------------------------------------------------------------------
Total 959 kB/s | 5.6 MB 00:05
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
Installing : postgresql92-libs-9.2.24-5PGDG.rhel6.i686 1/5
Installing : postgresql92-9.2.24-5PGDG.rhel6.i686 2/5
Installing : uuid-1.6.1-10.el6.i686 3/5
Installing : postgresql92-contrib-9.2.24-5PGDG.rhel6.i686 4/5
Installing : postgresql92-server-9.2.24-5PGDG.rhel6.i686 5/5
Verifying : postgresql92-9.2.24-5PGDG.rhel6.i686 1/5
Verifying : postgresql92-server-9.2.24-5PGDG.rhel6.i686 2/5
Verifying : postgresql92-contrib-9.2.24-5PGDG.rhel6.i686 3/5
Verifying : uuid-1.6.1-10.el6.i686 4/5
Verifying : postgresql92-libs-9.2.24-5PGDG.rhel6.i686 5/5
Installed:
postgresql92-contrib.i686 0:9.2.24-5PGDG.rhel6 postgresql92-server.i686 0:9.2.24-5PGDG.rhel6
Dependency Installed:
postgresql92.i686 0:9.2.24-5PGDG.rhel6 postgresql92-libs.i686 0:9.2.24-5PGDG.rhel6 uuid.i686 0:1.6.1-10.el6
Complete!