« Is it just me? | Main | Using FreeBSD »

February 8, 2005

PostgreSQL replication using Slony-I

So, I have been testing database replication for a PostgreSQL database, using Slony-I.

It works well, however, getting things set up were tricky, so I am writing this down for posterity.

First off, if you are trying to set up replication between remote machines, be sure you do not use localhost or 127.0.0.1 as the address for the instance running locally (master of slave). I don't know why, but this screws the whole thing up. For instance, you should define the environment variables for the connections between the master and slave like so:

export PGDATA=/usr/local/pgsql/data
export CLUSTERNAME=slony_example
export MASTERDBNAME=pgbench
export SLAVEDBNAME=pgbench
export MASTERHOST=192.168.1.2
export SLAVEHOST=192.168.1.3
export REPLICATIONUSER=pgsql
export PGBENCHUSER=pgbench

It doesn't matter if these variables are defined on the master or slave, they will work since the addresses are the proper network addresses of the machines in question. Once I did this the examples in the readme files went smoothly.

Also, be sure the permissions in your pg_hba.conf are set up correctly, or, obviously, nothing will work.

Posted by ed at February 8, 2005 4:43 PM

Comments

Post a comment




Type the characters you see in the picture above.


Remember Me?