[pgpool-general: 5874] Re: failover command

Tatsuo Ishii ishii at sraoss.co.jp
Fri Jan 19 07:39:01 JST 2018


> I have a pgpool running on server3, master on server1 and hotstandby
> on server2. Pgpool is set up reach out to both server1 and 2. pgpool
> starts fine and seems to be doing its job, but if the master dies,
> pgpool breaks.
> 
> I am using a failover command in pgpool.conf that runs:
> 
> backend0 : 10.0.0.1
> 
> backend1: 10.0.0.2
> 
> '/home/postgres/pool_heartbeat/bin/failover.sh %H %R'
> 
> the script failover.sh runs:
> 
> NEW_PRIMARY=$1          # %H
> PGDATA=$2               # %R
> 
> 
> echo "NEW_PRIMARY [$NEW_PRIMARY] [$1]" > /home/postgres/failover.log
> echo "PGDATA [$PGDATA] [$2]" >> /home/postgres/failover.log
> echo "ssh -T postgres@${NEW_PRIMARY} /usr/pgsql-9.6/bin/pg_ctl -D
> $PGDATA promote" >> /home/postgres/failover.log
> ssh -T postgres@${NEW_PRIMARY} /usr/pgsql-9.6/bin/pg_ctl -D $PGDATA
> promote
> 
> 
> 
> the log shows it putting out:
> 
> NEW_PRIMARY [10.0.0.1] [10.0.0.1]
> PGDATA [/var/lib/pgsql/9.6/data] [/var/lib/pgsql/9.6/data]
> ssh -T postgres at 10.16.0.121 /usr/pgsql-9.5/bin/pg_ctl -D
> /var/lib/pgsql/9.6/data promote
> 
> 
> I don't understand why it is being passed the master IP as well as it
> somehow changes my /usr/pgsql-9.6/bin/pg_ctl to
> /usr/pgsql-9.5/bin/pg_ctl. Any thoughts to why it doesn't this on
> failover?

%H is "host name of the new master node", which means the first live
backend host name. For example if you have backend_hostname0,
backend_hostname1, backend_hostname2 and backend_hostname0 goes down,
then %H = backend_hostname1. You need to promote the standby only if
your primary node goes down. If the standby goes down, you don't need
to promote the live primary.

You can check the down node by looking at %h.

Best regards,
--
Tatsuo Ishii
SRA OSS, Inc. Japan
English: http://www.sraoss.co.jp/index_en.php
Japanese:http://www.sraoss.co.jp


More information about the pgpool-general mailing list