Installing 32 bit PostgreSQL on 64 bit Linux

During an emergency server upgrade last week I was faced with a problem. I’d installed 64 bit Linux to replace a 32 bit Linux box, copied across the PostgreSQL data directory, then installed the identical version of PostgreSQL, but 64 bit. It turns out that the data file format is incompatible between 32 and 64 bit PostgreSQL.

PostgreSQL is my favourite RDBMS, but it’s worth noting that MySQL had no such problem and automatically updated the data files. Thanks MySQL!

The 32 bit server install was dead, so I couldn’t do a dump from the 32 bit system. I needed to install 32 bit PostgreSQL on my 64 bit box.

First you need to install ia32-libs using apt-get install. This gets you the base libraries necessary to run 32 bit apps.

Then you need to manually download the 32 bit .deb files for PostgreSQL. You’ll find them under /ubuntu/pool/main/p/ in your local Ubuntu archive. Try doing an install of PostgreSQL as per normal to see which packages are required. The postgresql-common packages are architecture independent so you can install those using apt-get.

After you’ve downloaded the .deb files you must install them using dpkg -i —force-architecture <debs>.

After doing this I was able to start PostgreSQL. It said it failed during startup! But it did actually start. I wasn’t able to use psql, as the libreadline library wasn’t 32 bit, but I was able to use pg_dump, which was the critical bit.

Once I’d dumped the databases I quickly uninstalled the 32 bit PostgreSQL, moved the data directory and installed the 64 bit version and sat through the lengthy reload.

This was posted 1 month ago. It has 6 notes.
  1. karlvr posted this