I have setup pgpool with load balancing and failover mode.
This is my failover command:
failover_command='/usr/local/etc/failover.sh %d %P %H %R'
The following is the script:
#!/bin/bash -x
FALLING_NODE=$1 # %d
OLDPRIMARY_NODE=$2 # %P
NEW_PRIMARY=$3 # %H
PGDATA=$4 # %R
if [ $FALLING_NODE = $OLDPRIMARY_NODE ]; then
if [ $UID -eq 0 ]
then
su postgres -c "ssh -T enterprisedb@$NEW_PRIMARY touch $PGDATA/trigger"
else
ssh -T enterprisedb@$NEW_PRIMARY touch $PGDATA/trigger
fi
exit 0;
fi;
exit 0;
But somehow the script is not executing as expected.
I have stopped the Master DB. According to script the slave should take the role of master but this was not happening in the script.
After failover from pgpool end:
show pool_nodes;
Output:
edb=# show pool_nodes;
node_id | hostname | port | status | lb_weight | role
---------+------------+------+--------+-----------+---------
0 | 10.0.0.149 | 5444 | 3 | 0.500000 | standby
1 | 10.0.0.158 | 5444 | 2 | 0.500000 | standby
(2 rows)
Please help me out to fix this issue.