Postgresql Upgrade

1094438881000

The time has come to upgrade my postgres installation from the ancient 7.3.2 currently running on my computer to the more recent 7.4.5 version.

Upgrading is a bit tricky because the pg_dumpall function in the older versions isn't as good as it could be. The developers have presented a chicken and egg solution for this problem: you are supposed to run the pg_dumpall function of the version you are upgrading to.

A good installer will not clobber your old data but the mantra of software development is back up, back up and back up again. So I took a copy of my /var/lib/pgsql/ directory just in case. If you are on Red Hat this is the location you are likely to find your data. (btw my system is nominally redhat but only a few Red Hat RPMs are left on - postgresql is one of them.)

Since I will be accessing my database from java as well as PHP my configure command looks like:

./configure --datadir=/var/lib/pgsql/data --with-java

This step didn't produce any suprises so onto the next step. The docs say use gmake which is the same as make on my system, so here goes ....

It did take a while to complete the compilation (enough time for me to add a few lines of code to a nother project I am working on) and it wasn't successfully. The break was when attempting to copmile the jdbc driver. I already have a more upto date version of the driver which I downloaded a couple of weeks back as a binary. So here goes another attempt to compile postgres, this time without the jdbc driver. (time to add a few more lines of code but not too many this time).

The second run was uneventfull. But before going on to the make install step I now need to run the 'new' pg_dumpall command to extract the data from my database. Too bad it does not work without the make install step.

./src/bin/pg_dump/pg_dumpall: relocation error: ./src/bin/pg_dump/pg_dumpall: undefined symbol: get_progname

Hang on a sec, what if I remove my RPMs? no luck. So now it's time to say bye bye to the data (I don't need it anyway, I already have the schema's safe and sound on numorous CDs) and on to the make install

Make install went well but attempting to run initdb causes problems. Apparently I am not supposed use --datadir=/var/lib/pgsql/data because the error produced says:

The database cluster will be initialized with locale en_US.UTF-8.

initdb: directory "/var/lib/pgsql/data/" exists but is not empty

If you want to create a new database system, either remove or empty

the directory "/var/lib/pgsql/data/" or run initdb with an argument other than

"/var/lib/pgsql/data/"

Attempting to clear out the folder leads to another error:

The database cluster will be initialized with locale en_US.UTF-8.

initdb: directory "/var/lib/pgsql/data/" exists but is not empty

If you want to create a new database system, either remove or empty

the directory "/var/lib/pgsql/data/" or run initdb with an argument other than

/var/lib/pgsql/data/

So it's time for another compilations. This time my configure script has no paramaters. (This entry will probably end up being the longest in my blog). Thankfully this time everything including the initdb went well.

My problems do not end here. I now need to recompile my php installation. Since I have both PHP 4 and PHP 5 running (no not together, i have to edit httpd.conf to use one or the other) that means a lot more work for my poor old hard disk and CPU.

comments powered by Disqus