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*:

cyrus-sasl-lib.i686
keyutils-libs.i686
krb5-libs.i686
libcom_err.i686
libdb.i686
libselinux.i686
libstdc++.i686
ncurses-libs.i686
nspr.i686
nss.i686
nss-softokn.i686
nss-util.i686
openldap.i686
openssl-libs.i686
pcre.i686
readline.i686
readline-devel.i686
sqlite.i686
zlib.i686
zlib-devel.i686

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.