[pgpool-general: 8666] Re: One node always primary

Tatsuo Ishii ishii at sraoss.co.jp
Wed Mar 22 14:37:23 JST 2023


> Hi all,
> 
> I would like to know if there is a mechanism to ensure one node is always
> primary.
> I have seen the ALWAYS_PRIMARY flag in the config file but I couldn't make
> it work.
> I tried to put in the backend_flag the value
> "ALLOW_TO_FAILOVER|ALWAYS_PRIMARY" with no success.
> 
> I have two nodes with streaming replication (server1 and server2). Server1
> is primary but sometimes I have to power off it and the server2 will be the
> new master because of the failover. What I need is to make the server1 the
> new master when it is powered on again.

I assume you are using Pgpool-II 4.3.0 or higher.

1. Power off server1. This will trigger failover and server2 will
   become new primary.

2. Power on server1 but do not start pgpool and PostgreSQL.

3. Run pcp_recovery_node on server2 with target node server1 so that
   server1 becomes standby.
   e.g. pcp_recovery_node -p xxxx 0
   (assuming server1 is node 0)

4. Run pcp_promote_node on server2 with -s option and target node
   to server1 so that server1 becomes new primary.
   e.g. pcp_promote_node -p xxxx -s 0
   (assuming server1 is node 0)

Best reagards,
--
Tatsuo Ishii
SRA OSS LLC
English: http://www.sraoss.co.jp/index_en/
Japanese:http://www.sraoss.co.jp


More information about the pgpool-general mailing list