fix pgpool down, check replication and add node
[pgpool-online-recovery] / fix-pgpool.sh
1 #!/bin/sh -xe
2
3 ssh postgres@10.200.1.60 PCPPASSFILE=/etc/pgpool-II/.pcppass pcp_watchdog_info --no-password | tee /dev/stderr | grep DEAD | cut -d' ' -f2 | while read host ; do
4         ssh -F ssh_config $host systemctl start pgpool
5 done
6
7 replication_ok=`psql -h 10.200.1.61 -t -A -c 'SELECT count(*) from pg_stat_replication' postgres postgres`
8 if [ $replication_ok != 1 ] ; then
9         echo FIXME online-recovery?
10         exit 1
11 fi
12
13 psql -h 10.200.1.60 -p 9999 -c 'show pool_nodes' postgres postgres | grep down | awk '{ print $1 }' | while read node_id ; do
14         ssh postgres@10.200.1.60 PCPPASSFILE=/etc/pgpool-II/.pcppass pcp_attach_node --node-id $node_id --no-password
15 done
16
17