Tuesday, March 1, 2011

Sendmail during Pgpool II failover and failback operation

0 comments

I already discussed the steps that I followed for Pgpool II replication and failover system at http://airumman.blogspot.com/2011/02/postgresql-failover-with-pgpool-ii.html.

In addition to this, we can easily send mail whenever failover ot failback happen using pgpool.
We only need to change two parameters at pgpool.conf which are described below.

Start sendmail service

service sendmail start

Modify pgpool.conf :

....

failover_command = 'echo  -e " Pgpool II failover executed successfully at $(hostname):$(hostname -i) for backend node %d down on the $(date).\n\n Details of Backend Node %d :-\n Host = %h \n Port = %p \n Cluster Path =  %D \n\nFor Pgpool II at $(hostname):$(hostname -i) current master node is Backend_node%m (Old master node was Backend_node%M)">/opt/pgpoolII/log/failover.log;mail -s "Pgpool II failover executed at $(hostname):$(hostname -i)" edf@rumman.com abc@rumman.com < /opt/pgpoolII/log/failover.log'
....
failback_command = 'echo  -e " Pgpool II failback done successfully at $(hostname):$(hostname -i) for backend node %d down on the $(date).\n\n Details of Backend Node %d :-\n Host = %h \n Port = %p \n Cluster Path =  %D \n\nFor Pgpool II at $(hostname):$(hostname -i) current master node is Backend_node%m (Old master node was Backend_node%M)">/opt/pgpoolII/log/failover.log;mail -s "Pgpool II failback done at $(hostname):$(hostname -i)" edf@rumman.com < /opt/pgpoolII/log/failback.log'

....


I get the following mails when any node gets down.

Pgpool II failover executed successfully on the Mon Feb  1 19:30:31 BDT 2010 at dev02.dhaka.rumman.com:192.168.200.32 for backend node 0 down.
 Details of Backend Node 0 :-
 Host = 192.168.200.217
 Port = 5432
 Cluster Path =  /var/lib/pgsql/data

After successfull online recovery, I get the following mail.

For Pgpool II at dev02.dhaka.rumman.com:192.168.200.32 current master node is Backend_node 1
Pgpool II failback done successfully on the Wed Feb  3 10:51:16 BDT 2010 at dev02.dhaka.rumman.com:192.168.200.32 for backend node 0 down.
 Details of Backend Node 0 :-
 Host = 192.168.200.217
 Port = 5432
 Cluster Path =  /var/lib/pgsql/data
For Pgpool II at dev02.dhaka.rumman.com:192.168.200.32 current master node is Backend_node0 (Old master node was Backend_node1)

Leave a Reply

Labels