[pgpool-general: 928] Re: the "master" role in pgpool

Lazáro Rubén García Martínez lgarciam at vnz.uci.cu
Wed Aug 29 23:07:08 JST 2012


>In the view of pgpool, is the first alive server the master?

No necessarily because tow servers, could be alive. The master server is determinated by the function pg_is_in_recovery(). For instance. There are two nodes. Node A is the master and node B is the standby or slave node, because into the data directory of node B there is a recovery.conf file with these properties:

standby_mode = 'on'
primary_conninfo = 'node A'
trigger_file = '/tmp/trigger_file'

These two nodes are up, and when pgpool is started it verify what is the primary server or master node, executing the function pg_is_in_recovery() in each server.

Then, when pgpool knows which server is master and which is standby, the queries that modify the database are send to the primary (master) node only, and the other queries are balanced if load balance function is active.

When the master is down (A), pgpool promote the standby node (B) as a new master, then when node A is recovered, this node is not promoted as master, because now this node is running as standby. For controling the jump from standby to master, you need to configure the property failover_command in the pgpool.conf file like this:

failover_command = '/opt/pgpool/bin/failover_stream.sh %d %P %H /tmp/trigger_file0'

*************************************************************
#! /bin/sh
# Failover command for streaming replication.

ID_DETACHED_NODE=$1
OLD_PRIMARY_NODE_ID=$2
IP_DIR_NEW_MASTER=$3
TRIGGER_FILE=$4

if [ $ID_DETACHED_NODE = $OLD_PRIMARY_NODE_ID ]; then
        # Create the trigger file.
        /usr/bin/ssh -T postgres@$IP_DIR_NEW_MASTER /bin/touch $TRIGGER_FILE
fi

exit 0;

************************************************

Regards.


________________________________________
From: pgpool-general-bounces at pgpool.net [pgpool-general-bounces at pgpool.net] On Behalf Of Kent Tong [kent.tong.mo at gmail.com]
Sent: Wednesday, August 29, 2012 6:33 AM
To: pgpool-general at pgpool.net
Subject: [pgpool-general: 927] the "master" role in pgpool

Hi,

In the view of pgpool, is the first alive server the master? So, it doesn't know which is the master in the PostgreSQL streaming replication relation? If so, it is possible for pgpool to treat the PQ slave as the pgpool master and send the write queries to it? For example, if backend0 is the PQ master and backend1 the PQ slave. If backend0 dies, backend1 is promoted into the PQ master. Later backend0 is recovered as a PQ slave. Now, backend0 is alive again, so pgpool will treat it as the new master?

--
Kent Tong
IT author and consultant, child educator


________________________________
Fin a la injusticia, LIBERTAD AHORA A NUESTROS CINCO COMPATRIOTAS QUE SE ENCUENTRAN INJUSTAMENTE EN PRISIONES DE LOS EEUU!
http://www.antiterroristas.cu
http://justiciaparaloscinco.wordpress.com

Fin a la injusticia, LIBERTAD AHORA A NUESTROS CINCO COMPATRIOTAS QUE SE ENCUENTRAN INJUSTAMENTE EN PRISIONES DE LOS EEUU!
http://www.antiterroristas.cu
http://justiciaparaloscinco.wordpress.com


More information about the pgpool-general mailing list