March 25th, 2013, 06:16 PM
Compiling 32-bit PostgreSQL on 64-bit Linux
There are a handful of reasons you might want to run 32-bit PostgreSQL on 64-bit Linux; the main one that comes to mind is streaming replication. You can't do streaming replication unless your two clusters are storing data the same way, so if one of your servers is 32-bit and the other is 64-bit, you'll need to do them both as 32-bit.
Here's what I did to build 32-bit PostgreSQL on 64-bit Fedora 18:
1) The biggest complication is finding the assorted libraries that 32-bit PostgreSQL is going to need. Here is the list I installed from yum*:
2) In the "./configure" step of compiling PostgreSQL, run this line instead:
CFLAGS=-m32 LDFLAGS=-m32 CXXFLAGS=-m32 ./configure
And that's it! When PostgreSQL builds, it should be 32-bit.
*: "So how did you come up with that particular list of libraries?" I ran "yum --assumeno install postgresql.i686" and looked at the dependencies that came up**. I also included readline-devel.i686 and zlib-devel.i686 because PostgreSQL tends to want them at compile time.
**: "If yum offers 32-bit PostgreSQL, why didn't you just install from yum?" Because yum isn't always up-to-date; especially for bug fixes, I like being able to deploy new PostgreSQL quickly. That means learning to compile it.