1. Compiling Postgres 7.1

You will only need Postgres and the latest OpenNSD Postgres driver to upgrade your system.

1.1. Downloading Postgres 7.1

First, obtain the latest version, at the time of this writing that would be Release Candidate 2 from ftp://ftp.postgresql.org/pub/dev. Be sure to check the FTP archive link, as the Postgres FTP server may keep the RC2 file online after the final version has been released. And do not forget to use a mirror site.

Note: Remember, the Postgres team is doing some awesome programming, but they are not gods and release candidates are probably not the best choice for a production system... (although if you have the nerve/backups it will be helpful if you do run a production system on a release candidate version and report the bugs you find)

1.2. Extracting the Postgres Sources

Because I am running a Redhat 6.2 system with the Postgres 7.0.3 RPM version, /usr/local/pgsql is conveniently free. If you have 7.0.3 installed at that location, I suggest you use /usr/local/psql. All command samples in this document use the /usr/local/psql location, to prevent all the cut-n-pasters out there from messing up their 7.0.3 version by mistake. The rest of the text assumes you are installing under pgsql.

su -
cd /usr/local
mkdir psql
chown pascal.pascal pgsql (substitute the user name that will be compiling Postgres)
su - pascal
cd /usr/local/psql
tar xzf /tmp/postgresql-7.1RC2.tar.gz
mv postgresql-7.1RC2/* .
rmdir postgresql-7.1RC2

1.3. Compiling

Compiling Postgres is extremely simple. This section contains only a brief configuration guide. If you think you have some special needs, you should refer to the Postgres installation documentation. You must not compile Postgres as root. You can mess up your system big time of you do.

This procedure was borrowed from /usr/local/pgsql/INSTALL. There are some configuration options for ./configure that you may want to look at.

Again, check the INSTALL file and the Postgres admin guide for more info.

The simplest form would be:
./configure [--prefix=/usr/local/psql] [options...]
gmake
gmake install
All as the some unprivileged user, that way you are 100% sure that you are not touching any of the Postgres 7.0.3 files. This will install everything under /usr/local/pgsql, including the manpages. You should update your man paths to include the new locations or move the man files to some common location (/usr/local/man, for example). You can also specify where 'gmake install' puts them with a ./configure option.

1.4. Initializing the Database

I decided to use a different user account for 7.1, this makes it much simpler to configure, start and stop the database service. This is not mandatory, but if you do not do it, you will probably make a deadly mistake somewhere along the line.

First you need to add the new Postgres user account, which will own the database files and server processes. I usually do not set a password on these accounts, I just 'su' into them when I need to.
su - 
adduser postgr71
mkdir /usr/local/psql/data
chown postgr71.postgr71 /usr/local/psql/data
su - postgr71

Now change .bash_profile (or .profile), the PATH must have '/usr/local/psql/bin' as its first entry. You must also add the PGDATA and PGPORT exports. My profile looks like:
PATH=/usr/local/psql/bin:$PATH:$HOME/bin
export PGDATA=/usr/local/psql/data
export PGPORT=5433
This assumes that Postgres 7.0.3 is running on port 5432. After you remove 7.0.3 from your system you may want to consider changing the port back to 5432. Now, log out and back in as postgr71 and check that the command which initdb returns /usr/local/psql/bin/initdb.

1.5. Starting the Postmaster

If your are feeling lucky, you can skip the test. But don't forget to start the postmaster.

su - postgr71
initdb 
pg_ctl -l logfile start
createdb test
psql test
You should now be able to create some tables in test, have fun with outer joins, etc. But I just exited psql (with '\q') and typed 'dropdb test'

You will want to add this brand new postgres instance to your automated startup, for that please refer to your OS manual.

1.6. Compiling the Postgres Driver

After and installing Postgres, you need to compile the latest postgres driver for OpenNSD. Get that from the sourceforge.net CVS repository:
cd /usr/local/aolserver (or whereever your aolserver source resides) 
cvs -d:pserver:anonymous@cvs.acs-pg.sourceforge.net:/cvsroot/acs-pg login 
cvs -z3 -d:pserver:anonymous@cvs.acs-pg.sourceforge.net:/cvsroot/acs-pg co driver-2.3
The driver source must be under the AOLServer source directory.

Now you need to change some parameters in driver-2.3/makefile (yes, that is makefile not Makefile). There are plenty of samples in the file, but these need your immediate attention:
PGLIB=/usr/local/psql/lib          # Where your PG libraries are installed 
PGINC=/usr/local/psql/include      # Where your PG includes are installed 
NSHOME=/home/aolserver             # Where your AOLserver is installed 
NSINC=/usr/local/aolserver/include # Where you untarred AOLserver

Making should be simple, error free and fast. After make you should copy the new driver to your AOLServer bin dir, but don't overwrite the original postgres driver!
cd /usr/local/aolserver/
make
cp postgres.so /home/aolserver/bin/postgres71.so

Now you are all set to convert the database.