How to Install PostgreSQL 9.2 on CentOS 6.3

This quick post shows the basic steps to install PostgreSQL Database Server (PostgreSQL 9.2) on CentOS 6.3. This steps has been tested using CentOS 6.3. However, It may works on other version CentOS or Redhat as well. PostgreSQL is a Sophisticated open-source Object-Relational DBMS supporting almost all SQL constructs, including subselects, transactions, and user-defined types. PostgreSQL is a powerful, open source object-relational database system that available for many platforms including Linux, FreeBSD, Solaris, Microsoft Windows and Mac OS X.

PostgreSQL Global Development Group (PGDG) builds RPMs for various Linux distributions. At the time of this writing, there are available RPMs and SRPMs for the following platforms :

  • PostgreSQL 9.2
See also  How to Configure Static IP Address on CentOS 6.2 Linux Server

Follow these steps to install PostgreSQL 9.2 on CentOS 6.3 :

1. Download the latest production release for your distro here: http://yum.pgrpms.org/repopackages.php

[root@centos63 ~]# wget http://yum.pgrpms.org/9.2/redhat/rhel-6-i386/pgdg-centos92-9.2-5.noarch.rpm
--2012-09-25 21:50:05--  http://yum.pgrpms.org/9.2/redhat/rhel-6-i386/pgdg-centos92-9.2-5.noarch.rpm
Resolving yum.pgrpms.org... 98.129.198.114
Connecting to yum.pgrpms.org|98.129.198.114|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5220 (5.1K) [application/x-redhat-package-manager]
Saving to: âpgdg-centos92-9.2-5.noarch.rpmâ

100%[==========================================================>] 5,220       4.76K/s   in 1.1s

2012-09-25 21:50:06 (4.76 KB/s) - âpgdg-centos92-9.2-5.noarch.rpmâ

2. Install the repo :

[root@centos63 ~]# rpm -ivh pgdg-centos92-9.2-5.noarch.rpm
Preparing...                ########################################### [100%]
   1:pgdg-centos92          ########################################### [100%]

3. Edit the CentOS-Base.repo to exclude postgreql.

[root@centos63 ~]# vi /etc/yum.repos.d/CentOS-Base.repo

Add ‘exclude=postgresql*’ to the [base] and [updates] sections:

[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
exclude=postgresql*

#released updates
[updates]
name=CentOS-$releasever - Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
exclude=postgresql*

4. Use ‘yum list’ to check the packages that are now available.

[root@centos63 ~]# yum list postgres*
Loaded plugins: fastestmirror, presto, priorities
Loading mirror speeds from cached hostfile
 * base: centos.ipserverone.com
 * extras: centos.ipserverone.com
 * updates: centos.ipserverone.com
Available Packages
postgresql.i686                              8.4.11-1.el6_2                     CentOS6.3-Repository
postgresql-contrib.i686                      8.4.11-1.el6_2                     CentOS6.3-Repository
postgresql-devel.i686                        8.4.11-1.el6_2                     CentOS6.3-Repository
postgresql-docs.i686                         8.4.11-1.el6_2                     CentOS6.3-Repository
postgresql-jdbc.i686                         8.4.701-3.el6                      CentOS6.3-Repository
postgresql-jdbc.noarch                       8.4.701-8.el6                      CentOS6.3-Repository
postgresql-libs.i686                         8.4.11-1.el6_2                     CentOS6.3-Repository
postgresql-odbc.i686                         08.04.0200-1.el6                   CentOS6.3-Repository
postgresql-plperl.i686                       8.4.11-1.el6_2                     CentOS6.3-Repository
postgresql-plpython.i686                     8.4.11-1.el6_2                     CentOS6.3-Repository
postgresql-pltcl.i686                        8.4.11-1.el6_2                     CentOS6.3-Repository
postgresql-server.i686                       8.4.11-1.el6_2                     CentOS6.3-Repository
postgresql-test.i686                         8.4.11-1.el6_2                     CentOS6.3-Repository
postgresql92.i686                            9.2.1-1PGDG.rhel6                  pgdg92
postgresql92-contrib.i686                    9.2.1-1PGDG.rhel6                  pgdg92
postgresql92-debuginfo.i686                  9.2.1-1PGDG.rhel6                  pgdg92
postgresql92-devel.i686                      9.2.1-1PGDG.rhel6                  pgdg92
postgresql92-docs.i686                       9.2.1-1PGDG.rhel6                  pgdg92
postgresql92-libs.i686                       9.2.1-1PGDG.rhel6                  pgdg92
postgresql92-odbc.i686                       09.01.0200-1PGDG.rhel6             pgdg92
postgresql92-odbc-debuginfo.i686             09.01.0200-1PGDG.rhel6             pgdg92
postgresql92-plperl.i686                     9.2.1-1PGDG.rhel6                  pgdg92
postgresql92-plpython.i686                   9.2.1-1PGDG.rhel6                  pgdg92
postgresql92-pltcl.i686                      9.2.1-1PGDG.rhel6                  pgdg92
postgresql92-server.i686                     9.2.1-1PGDG.rhel6                  pgdg92
postgresql92-tcl.i686                        2.0.0-1.rhel6                      pgdg92
postgresql92-tcl-debuginfo.i686              2.0.0-1.rhel6                      pgdg92
postgresql92-test.i686                       9.2.1-1PGDG.rhel6                  pgdg92

5. Start install PostgreSQL 9 using yum:

[root@centos63 ~]# yum install postgresql92 postgresql92-devel postgresql92-server postgresql92-libs postgresql92-contrib -y

6. Verify, Initialize and Start PostgreSQL service :

[root@centos63 ~]# service postgresql-9.2 status
 is stopped
[root@centos63 ~]# service postgresql-9.2 initdb
Initializing database:                                     [  OK  ]
[root@centos63 ~]# service postgresql-9.2 start
Starting postgresql-9.2 service:                           [  OK  ]

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *