Upgrade Postgresql 8.4 to 9.4 in Centos

Yum Install PG9.4

1
2
3
4
5
wget http://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/pgdg-redhat94-9.4-1.noarch.rpm
yum instlal pgdg-redhat94-9.4-1.noarch.rpm
yum install postgresql94-server
service postgresql-9.4 initdb
chkconfig postgresql-9.4 on

Backup Data

1
2
su - postgres
pg_dumpall > dump.sql

Restore Data

1
2
3
4
service postgresql stop
service postgresql-9.4 start
su - postgres
psql < dump.sql

Config Network Access

vi /var/lib/pgsql/9.4/data/postgresql.conf

1
2
listen_addresses = '*'
port = 5432

/var/lib/pgsql/9.4/data/pg_hba.conf

1
2
3
4
5
6
7
8
# "local" is for Unix domain socket connections only
local   all         all                               ident
# IPv4 local connections:
host    all         all         127.0.0.1/32          ident
host    all         all         130.51.79.0/24        md5
host    all         all         10.210.29.0/24        md5
# IPv6 local connections:
host    all         all         ::1/128               ident

Remove PG8.4

1
2
yum remove postgresql
ln -s /usr/pgsql-9.4/bin/psql /usr/local/bin/psql

Refrences

  1. http://yum.postgresql.org/repopackages.php#pg94
  2. https://wiki.postgresql.org/wiki/YUM_Installation
  3. http://www.postgresql.org/docs/9.4/static/upgrading.html