Install Postgresql 9 by yum on Centos

 How to Install Postgresql 9 by yum on Centos

 

 

 

1.  Link to download Yum repo for Postgresql

http://yum.pgrpms.org/

2. Download Postgresql Yum repo to Centos

[root@localhost ~]# wget http://yum.pgrpms.org/9.2/redhat/rhel-6.3-x86_64/pgdg-centos92-9.2-6.noarch.rpm

–2012-12-10 08:07:16– http://yum.pgrpms.org/9.2/redhat/rhel-6.3-x86_64/pgdg-centos92-9.2-6.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: 5288 (5.2K) [application/x-redhat-package-manager] Saving to: âpgdg-centos92-9.2-6.noarch.rpmâ 100%[===========================================================================================================================================================>] 5,288 16.0K/s in 0.3s 2012-12-10 08:07:17 (16.0 KB/s) – âpgdg-centos92-9.2-6.noarch.rpmâ [root@localhost ~]#

3. Install Repo into our Server

[root@localhost ~]# rpm -ivh pgdg-centos92-9.2-6.noarch.rpm

Preparing… ########################################### [100%]
1:pgdg-centos92 ########################################### [100%]
[root@localhost ~]#

4. Exclude postgresql in CentOS-Base.repo

 vi /etc/yum.repos.d/CentOS-Base.repo

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#

[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*
#additional packages that may be useful
[extras]
name=CentOS-$releasever – Extras
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever – Plus
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

#contrib – packages by Centos Users
[contrib]
name=CentOS-$releasever – Contrib
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
#baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

5. Install Postgresql by yum

[root@localhost yum.repos.d]# yum install postgresql92 postgresql92-devel postgresql92-server postgresql92-libs postgresql92-contrib -y
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: mirror.neu.edu.cn
* epel: ftp.jaist.ac.jp
* extras: centos-hcm.viettelidc.com.vn
* updates: mirror.neu.edu.cn
Setting up Install Process
Package postgresql92-9.2.1-1PGDG.rhel6.x86_64 already installed and latest version
Package postgresql92-libs-9.2.1-1PGDG.rhel6.x86_64 already installed and latest version
Resolving Dependencies
–> Running transaction check
—> Package postgresql92-contrib.x86_64 0:9.2.1-1PGDG.rhel6 will be installed
–> Processing Dependency: libossp-uuid.so.16()(64bit) for package: postgresql92-contrib-9.2.1-1PGDG.rhel6.x86_64
—> Package postgresql92-devel.x86_64 0:9.2.1-1PGDG.rhel6 will be installed
—> Package postgresql92-server.x86_64 0:9.2.1-1PGDG.rhel6 will be installed
–> Running transaction check
—> Package uuid.x86_64 0:1.6.1-10.el6 will be installed
–> Finished Dependency Resolution
Dependencies Resolved=====================================================================================================================================================================================================
Package Arch Version Repository Size
=====================================================================================================================================================================================================
Installing:
postgresql92-contrib x86_64 9.2.1-1PGDG.rhel6 pgdg92 434 k
postgresql92-devel x86_64 9.2.1-1PGDG.rhel6 pgdg92 1.4 M
postgresql92-server x86_64 9.2.1-1PGDG.rhel6 pgdg92 3.7 M
Installing for dependencies:
uuid x86_64 1.6.1-10.el6 base 54 kTransaction Summary
=====================================================================================================================================================================================================
Install 4 Package(s)Total download size: 5.6 M
Installed size: 23 M
Downloading Packages:
y(1/4): postgresql92-contrib-9.2.1-1PGDG.rhel6.x86_64.rpm (0%) 9% [======= ] 21 kB/s | 43 kB 00:18 ET((1/4): postgresql92-contrib-9.2.1-1PGDG.rhel6.x86_64.rpm | 434 kB 00:06
(2/4): postgresql92-devel-9.2.1-1PGDG.rhel6.x86_64.rpm | 1.4 MB 00:15
(3/4): postgresql92-server-9.2.1-1PGDG.rhel6.x86_64.rpm | 3.7 MB 00:35
(4/4): uuid-1.6.1-10.el6.x86_64.rpm | 54 kB 00:00
—————————————————————————————————————————————————————————————————–
Total 94 kB/s | 5.6 MB 01:01
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : uuid-1.6.1-10.el6.x86_64 1/4
Installing : postgresql92-contrib-9.2.1-1PGDG.rhel6.x86_64 2/4
Installing : postgresql92-server-9.2.1-1PGDG.rhel6.x86_64 3/4
Installing : postgresql92-devel-9.2.1-1PGDG.rhel6.x86_64 4/4
Verifying : postgresql92-devel-9.2.1-1PGDG.rhel6.x86_64 1/4
Verifying : postgresql92-contrib-9.2.1-1PGDG.rhel6.x86_64 2/4
Verifying : postgresql92-server-9.2.1-1PGDG.rhel6.x86_64 3/4
Verifying : uuid-1.6.1-10.el6.x86_64 4/4Installed:
postgresql92-contrib.x86_64 0:9.2.1-1PGDG.rhel6 postgresql92-devel.x86_64 0:9.2.1-1PGDG.rhel6 postgresql92-server.x86_64 0:9.2.1-1PGDG.rhel6Dependency Installed:
uuid.x86_64 0:1.6.1-10.el6Complete!
[root@localhost yum.repos.d]#

6. Start Postgresql and check postgresql process

[root@localhost yum.repos.d]# /etc/init.d/postgresql-9.2 start
/var/lib/pgsql/9.2/data is missing. Use “service postgresql-9.2 initdb” to initialize the cluster first.
[FAILED]
[root@localhost yum.repos.d]# service postgresql-9.2 initdb
Initializing database: [ OK ]
[root@localhost yum.repos.d]# /etc/init.d/postgresql-9.2 start
Starting postgresql-9.2 service: [ OK ]
[root@localhost yum.repos.d]#
[root@localhost yum.repos.d]# netstat -nutlap | grep post
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN 20457/postmaster
tcp 0 0 ::1:5432 :::* LISTEN 20457/postmaster
udp 0 0 ::1:42931 ::1:42931 ESTABLISHED 20457/postmaster
[root@localhost yum.repos.d]#

That’s all. Thanks for using IThelpblog.com

Tags:  

One comment to Install Postgresql 9 by yum on Centos

  • Matt  says:

    Just want to say thanks! This was an incredibly useful guide.

Leave a reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>