How to upgrade Postgresql from 8x to 9.2.6 – Centos 5.9 and Centos 6.4

These upgrades retain the old database engine while installing the new version as well. However, in order to have both engines running you will need to change the port on which each engine is listening to. Remember, two applications cannot use the same port over the network for incoming connections.  The directory structure of the Postgresql 8x is

  • /var/lib/pgsql/data

Once you upgrade to version 9.2.6 the directory structure for your new engine will be

  • /var/lib/pgsql/9.2

It is highly recommended to make a backup of the /var/lib/pgsq/data directory by simply issuing a cp -rf  command.   Once the new engine is installed you will have to initialize the new engine by using initdb. You can specify a location to your liking by issuing “initdb -D /some/directory/somewhere” . However, this is reserved only when dealing with production systems and you wish to install the engine to a different filesystem.

In case there is a failure starting any of the engines the log file for each specific engine is located as follows:

Postgresql 8x /var/lib/pgsql/pgstartup.log

Postgresql 9x /var/lib/pgsql/9.2/pgstartup.log

 

The config file for each engine is located as follows: You will need to do changes in the config files only in case you want to run both engines or if you wish to further customize performance of your database.

Postgresql 8x: /var/lib/pgsql/data/postgresql.conf

Postgresql 9x: /var/lib/pgsql/9.2/data/postgresql.conf

 

Centos 5.9 upgrade Postgresql from 8.1.23 to 9.2.6

 

service postgresql  stop
wget rpm -ivh http://yum.postgresql.org/9.2/redhat/rhel-5-x86_64/pgdg-centos92-9.2-6.noarch.rpm
rpm -i pgdg-centos92-9.2-6.noarch.rpm
yum install postgresql92 postgresql92-server postgresql92-contrib
vi /etc/sysconfig/pgsql/postgresql-9.3

On the file you ust created you will need to specify the location of where the database will be initialized. In my case (which is a bit unorthodox) will be:

PGDATA=/home/postgres93/pgsql/data93
PGLOG=/home/postgres93/pgsql/pgstartup93.log

To start your database execute

/etc/init.d/postgresql-9.2 initdb service postgresql-9.2 start

After running the yum command you should see something similar to this. Make sure you read what yum will do before you answer Yes to install the packages.

pgdg92/primary_db | 121 kB 00:00
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package postgresql92.x86_64 0:9.2.6-1PGDG.rhel5 set to be updated
--> Processing Dependency: postgresql92-libs = 9.2.6-1PGDG.rhel5 for package: po stgresql92
--> Processing Dependency: libpq.so.5()(64bit) for package: postgresql92
---> Package postgresql92-contrib.x86_64 0:9.2.6-1PGDG.rhel5 set to be updated
--> Processing Dependency: libossp-uuid.so.15()(64bit) for package: postgresql92 -contrib
---> Package postgresql92-server.x86_64 0:9.2.6-1PGDG.rhel5 set to be updated
--> Running transaction check
---> Package postgresql92-libs.x86_64 0:9.2.6-1PGDG.rhel5 set to be updated
---> Package uuid.x86_64 0:1.5.1-4.rhel5 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
postgresql92 x86_64 9.2.6-1PGDG.rhel5 pgdg92 1.6 M
postgresql92-contrib x86_64 9.2.6-1PGDG.rhel5 pgdg92 523 k
postgresql92-server x86_64 9.2.6-1PGDG.rhel5 pgdg92 5.6 M
Installing for dependencies:
postgresql92-libs x86_64 9.2.6-1PGDG.rhel5 pgdg92 217 k
uuid x86_64 1.5.1-4.rhel5 pgdg92 52 k

 

 

 

Centos 6.4 upgrade Postgresql from 8.4.18 to 9.2.6

service postgresql  stop
wget http://yum.pgrpms.org/9.2/redhat/rhel-6-x86_64/pgdg-centos92-9.2-6.noarch.rpm
rpm -ivh pgdg-centos92-9.2-6.noarch.rpm
yum install postgresql92 postgresql92-server

On the file you ust created you will need to specify the location of where the database will be initialized. In my case (which is a bit unorthodox) will be:

PGDATA=/home/postgres93/pgsql/data93
PGLOG=/home/postgres93/pgsql/pgstartup93.log
To start your database execute:
service postgresql-9.2 start
 After running the yum command you should see something similar to this. Make sure you read what yum will do before you answer Yes to install the packages.
============================================
Downloading Packages:
(1/4): openssl-1.0.1e-16.el6_5.x86_64.rpm                | 1.5 MB     00:03
(2/4): postgresql92-9.2.6-1PGDG.rhel6.x86_64.rpm         | 971 kB     00:00
(3/4): postgresql92-libs-9.2.6-1PGDG.rhel6.x86_64.rpm    | 187 kB     00:00
(4/4): postgresql92-server-9.2.6-1PGDG.rhel6.x86_64.rpm  | 3.8 MB     00:01
--------------------------------------------------------------------------------
Total                                           1.0 MB/s | 6.5 MB     00:06
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
  Updating   : openssl-1.0.1e-16.el6_5.x86_64                               1/5
  Installing : postgresql92-libs-9.2.6-1PGDG.rhel6.x86_64                   2/5
  Installing : postgresql92-9.2.6-1PGDG.rhel6.x86_64                        3/5
  Installing : postgresql92-server-9.2.6-1PGDG.rhel6.x86_64                 4/5
  Cleanup    : openssl-1.0.0-27.el6.x86_64                                  5/5
  Verifying  : openssl-1.0.1e-16.el6_5.x86_64                               1/5
  Verifying  : postgresql92-libs-9.2.6-1PGDG.rhel6.x86_64                   2/5
  Verifying  : postgresql92-server-9.2.6-1PGDG.rhel6.x86_64                 3/5
  Verifying  : postgresql92-9.2.6-1PGDG.rhel6.x86_64                        4/5
  Verifying  : openssl-1.0.0-27.el6.x86_64                                  5/5

Installed:
  postgresql92.x86_64 0:9.2.6-1PGDG.rhel6
  postgresql92-server.x86_64 0:9.2.6-1PGDG.rhel6

Dependency Installed:
  postgresql92-libs.x86_64 0:9.2.6-1PGDG.rhel6

Dependency Updated:
  openssl.x86_64 0:1.0.1e-16.el6_5

Complete!
Share Button

Leave a Reply

Your email address will not be published.

Time limit is exhausted. Please reload the CAPTCHA.