Beacon Hill, Inc. Technology Solutions

Home > Knowledge Base > Upgrading Postgres 8.1 to 8.3

Download and Compile Source

$ cd ~/sources$ wget XXXX postgresql-8.3.8.tar.gz

Unpack

$ tar -zxvf postgresql-8.3.8.tar.gz

Install required libraries

$ apt-get readline-devel$ apg-get zlib-devel

Build

$ ./configure$ gmake$ gmake install

Installs into

/usr/local/pgsql

Old is in /var/lib/pgsql

Backup 8.1 Installation

Executables (ISSUE)

/usr/bin/psql/usr/bin/postmaster/usr/bin/pg_ctl/usr/bin/posgres

Startup script

/etc/rc.d/init.d/postgresql

Procedure

Backup databases

$ cd ~/backups$ pg_dumpall > backup

Stop postmaster

$ pg_ctl stop

for me this didn't work.

As root:

$ /etc/rc.d/init.d/postgres stop

Backup PGDATA directory

As root$ mv /var/lib/pgsql /var/lib/pgsql.8.1

Create PGDATA

# As root:$ mkdir /usr/local/pgsql/data$ chown postgres:postgres data

# As postgres$ su $ password$ su - postgressu: warning: cannot change directory to /var/lib/pgsql: No such file or directory

/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data

Fix home directory problem

usermod -d /usr/local/pgsql postgres

Create new /etc/rc.d/init.d/postgresql file

$ cd /etc/rc.d/init.d/$ cp /home/blucas/sources/postgresql-8.3.8/contrib/start-scripts/linux postgresql

Add with chkconfig

$ /sbin/chkconfig --add postgresql

# check$ /sbin/chkconfig --list

Start database

$ /etc/rc.d/init.d/postgresql start

Restore

$ cd ~/backups

As postgres:

$ psql -f backup postgres

Next Steps

Fix /usr/bin files (remove or link to new ones)

su -yum remove *postgre*

Dependencies Resolved

============================================================================= Package Arch Version Repository Size =============================================================================Removing: postgresql i386 8.1.11-1.el5_1.1 installed 10 M postgresql-devel i386 8.1.11-1.el5_1.1 installed 3.6 M postgresql-libs i386 8.1.11-1.el5_1.1 installed 495 k postgresql-server i386 8.1.11-1.el5_1.1 installed 9.8 MRemoving for dependencies: apr-util i386 1.2.7-7.el5 installed 156 k dovecot i386 1.0.7-2.el5 installed 3.6 M httpd i386 2.2.3-11.el5_2.centos.4 installed 2.8 M mod_dav_svn i386 1.4.2-2.el5 installed 134 k mod_perl i386 2.0.2-6.3.el5 installed 6.5 M mod_python i386 3.2.8-3.1 installed 1.1 M mod_ssl i386 1:2.2.3-11.el5_2.centos.4 installed 173 k php i386 5.1.6-20.el5_2.1 installed 2.9 M subversion i386 1.4.2-2.el5 installed 7.6 M webalizer i386 2.01_10-30.1 installed 252 k

Solutions

Leave library...See rimuhosting mail

Reboot box to test starting fine

Remove old /var/lib/pgsql