PostgreSQL Replication

2 Installation & Configuration

<- 1 Getting Started and Fundamentals [  up  ] - [ TOC ] 2.1 Master ->

2.1   Master
2.2   Slave

Consider using PG Version >= 7.3.1 where replication is included in the base distribution (postgresql-7.3.x/contrib/dbmirror)

cd /root/software/postgresql-7.3.1/contrib/dbmirror
make
make install

You should now have a file named pending.so that contains the trigger.

Install this file in /usr/local/pgsql/lib (or another suitable location).

If you choose a different location the MirrorSetup.sql script will need to be modified to reflect your new location! The CREATE FUNCTION command in the MirrorSetup.sql script associates the trigger function with the pending.so shared library. Modify the arguments to this command if you choose to install the trigger elsewhere.

2) Run MirrorSetup.sql

This file contains SQL commands to setup the Mirroring environment. This includes

  • Telling Postgres about the "recordchange" trigger function.
  • Creating the Pending,PendingData, MirrorHost, MirroredTransaction tables

To execute the script use psql as follows

psql -f MirrorSetup.sql MyDatabaseName

where MyDatabaseName is the name of the database you wish to install mirroring on (Your master).

Each slave database needs its own configuration file for the DBMirror.pl script. See slaveDatabase.conf for a sample.

DON'T FORGET TO CREATE THE TRIGGER ON THE MASTER'S SIDE ;-)





copyright by retoh - created with mytexi