Setting up Slony cluster with PerlTools
A few days back while I was giving a training on Slony and was showing the students steps to building a Slony cluster using Perltools, they asked me to write down the steps for them as it was very hard to memorize everything. I just did that and thought of sharing it with everyone as it might help.
First of all make sure you have the perltools available for Slony and once you have confirmed that, follow the steps given below:
– Edit the slon_tools.conf file according to your cluster needs, i.e. change the nodes, sets information and tables to be replicated. This file by default is located in /usr/local/etc/slon_tools.conf and the Perltools will by default look into this directory for the configuration file.
– Now first of all you need to initialize the cluster
slonik_init_cluster | slonik
– Once that step is successful, start the Slon processes on each of the nodes involved
– Create the Sets, in our case we just had one set so the process goes as
slonik_create_set 1 | slonik
(Where 1 is the ID of the first set which we had set in the slon_tools.conf file)
– Subscribe the sets now, in our case we had just two nodes and one set
slonik_subscribe_set 1 2 | slonik
(Where 1 is the ID of the set and 2 is the node to which you want to subscribe)
– Once the subscription is successfull you should have replication all working now, which can be tested by adding a row in one of the replicated tables on master and verifying the change in your slave node.
Perltools really make life easy and takes rid of those extra steps for creating Slonik scripts yourself . Once you have the slon_tools.conf properly configured it just takes a few minutes generating all the required scripts.
Just make sure when you make any changes to your Slony cluster like adding new sets, new tables, merging sets and doing switchovers or failover… keep on updating the slon_tools.conf file regularly as then it will not take much time rebuilding all scripts for the latest cluster in case that is needed.