pgpool 之八 脚本 pgpool_failover_stream

pgpool_failover_stream

$ vi /data/pg9.6/main/pgpool_failover_stream

#!/bin/bash
# Special values:
#   %d = node id
#   %h = host name
#   %p = port number
#   %D = database cluster path
#   %m = new master node id
#   %H = hostname of the new master node
#   %M = old master node id
#   %P = old primary node id
#   %r = new master port number
#   %R = new master database cluster path
#   %% = '%' character

failed_node_id=$1
new_master_host_name=$6
old_primary_node_id=$8
promote_command="/usr/lib/postgresql/9.6/bin/pg_ctl promote -D /data/pg9.6/main"

if [ $failed_node_id = $old_primary_node_id ]; then
   echo "`date +%Y-%m-%d\ %H:%M:%S,%3N` pgpool: FATAL: [$failed_node_id,$new_master_host_name,$promote_command] will failover,please check immediate"
   /usr/bin/ssh -T $new_master_host_name $promote_command
else
   echo "`date +%Y-%m-%d\ %H:%M:%S,%3N` pgpool: FATAL: [$failed_node_id,$new_master,$promote_command] postgresql slave is down,please check immediate"
fi

exit 0;

$ chmod 700 /data/pg9.6/main/pgpool_failover_stream

尽量使用 pg_ctl promote 命令提升从库.

参考:
http://www.pgpool.net/docs/latest/en/html/example-cluster.html
http://www.pgpool.net/docs/37/en/html/runtime-config-failover.html

你可能感兴趣的:(#,postgresql,ha,pgpool)