Skip to content

Instantly share code, notes, and snippets.

@holly
Created October 13, 2013 04:34
Show Gist options
  • Save holly/6958223 to your computer and use it in GitHub Desktop.
Save holly/6958223 to your computer and use it in GitHub Desktop.
pgpool failover script(pg_ctl promote) failover_command = '/path/to/pgpool_failover_stream.sh %d %H %R'
#!/bin/bash
set -e
SSH=/usr/bin/ssh
PGCTL=/usr/bin/pg_ctl
failed_node=$1
new_master=$2
cluster_path=$3
# Do nothing if standby goes down.
if [ $failed_node != 0 ]; then
echo "node number:$failed_node is standby. skip"
exit 0;
fi
# execute promote
$SSH -T $new_master $PGCTL promote -D $cluster_path
echo "$new_master has been promoted from slave to temp master"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment