How to Setup Slony Replication Using PgAdmin
In this example, a master server is setup with two direct slaves. This example was written and tested using Slony-I v1.2.11 and PostgreSQL 8.2.5, running on a single Windows XP machine. The PostgresSQL pgbench utility is used to generate the test schema and workload.
- Create 3 databases, master, slave1 and slave2 and ensure pl/pgsql is setup in each.
- Create a pgbench schema in the master database:
- Add a primary key called history_pkey to the history table on the tid, bid and aid columns
- Create a schema-only dump of the master database, and load it into slave1 and slave2:
- Create Slony config files for each slon engine (daemon on Unix). The files should contain just the following two lines:Create a file for each database, adjusting the dbname parameter as required and adding any other connection options that may be needed.
- (Windows only) Install the Slony-I service:
- Register each of the engines (this is only necessary on Windows - on Unix the slon daemons may be started individually and given the path to the config file on the command line using the -f option):
- In pgAdmin under the Slony Replication node in the master database, create a new Slony-I cluster using the following options:
- Under the Slony Replication node, create a Slony-I cluster in each of the slave databases using the following options:
- Create Paths on the master to both slaves, and on each slave back to the master. Create the paths under each node on the master, using the connection strings specified in the slon config files. Note that future restructuring of the cluster may require additional paths to be defined.
- Create a Replication Set on the master using the following settings:
- Add the tables to the replication set using the following settings:
- On the master node, create a new subscription for each slave using the following options:
- Start the slon service (or daemons on Unix):
Initial replication should begin and can be monitored on the statistics tab in pgAdmin for each node. The pgbench utility may be run against the master database to generate a test workload.
Comments
Post a Comment