Tuesday, December 20, 2011

Postgresql - pgpool + failover

This is the provided script for failover in the example I'm following.
http://pgpool.projects.postgresql.org/contrib_docs/simple_sr_setting/failover.sh

#----------------------------------------------------------------------------------------------------------
#!/bin/sh
# Execute command by failover.
# special values:  %d = node id
#                  %h = host name
#                  %p = port number
#                  %D = database cluster path
#                  %m = new master node id
#                  %M = old master node id
#                  %H = new master node host name
#                  %P = old primary node id
#                  %% = '%' character
failed_node_id=$1
failed_host_name=$2
failed_port=$3
failed_db_cluster=$4
new_master_id=$5
old_master_id=$6
new_master_host_name=$7
old_primary_node_id=$8
trigger=/var/log/pgpool/trigger/trigger_file1

if [ $failed_node_id = $old_primary_node_id ];then    # master failed
    touch $trigger    # let standby take over
fi

#---------------------------------------------------------------------------------------------------------

The reasoning behind the trigger file is that when the standby server finds the file it will decide to promote to primary. It's the health check process the one that will determine whether the primary is down.

Doubts:
1.Where is specified the order in which the parameters are given, where is it documented? Well, I guess that I'll take his word for it, as he's a guy from the development team.
2.  In case I have  another slave server, which one will be promoted?

No comments:

Post a Comment