pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Tom Loder <tom.loder@servelec-technologies.com>
To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: Failover replication building a new master
Date: Wed, 6 Jun 2018 07:20:53 -0700
Message-ID: <32f5d09a-3989-1c68-18c2-cdf21cd7d8ad@aklaver.com> (raw)
In-Reply-To: <ED127BEF191D73498D32229AD28B3554BF60764F@GSH-EXD-02.cse-servelec.com>
References: <ED127BEF191D73498D32229AD28B3554BF60764F@GSH-EXD-02.cse-servelec.com>

On 06/05/2018 05:43 AM, Tom Loder wrote:
> I am using Postgres 10.4, and using replication, I have managed to set up four servers, with one running as a master and the other three running with streaming replication from the master.
> 
> I have used the  command:
> psql -c "ALTER SYSTEM SET synchronous_standby_names TO  'FIRST 1(S2,S3,S4)';" so that at least one of the three slave clusters are SYNCED to the master.
> 
> If I run the following command I get the following back:
> 
> SELECT pid, usename, application_name as name,state, client_addr, sent_lsn, write_lsn, flush_lsn, replay_lsn, sync_priority, sync_state FROM pg_stat_replication;
> 
>    pid  | usename | name  |   state   | sent_lsn  | write_lsn | flush_lsn | replay_lsn | sync_priority | sync_state
> -------+---------+-------+-----------+-------------+-----------+-----------+-----------+------------+---------------+------------
>   26215 | replica | S3 | streaming | 0/6000000 | 0/6000000 | 0/6000000 | 0/6000000  |             2 | potential
>   26200 | replica | S4 | streaming | 0/6000000 | 0/6000000 | 0/6000000 | 0/6000000  |             3 | potential
>   26186 | replica | S2 | streaming |  0/6000000 | 0/6000000 | 0/6000000 | 0/6000000  |             1 | sync
> 
> When I take out my master server (S1) I setup S2 as the master using a bash script and I update the recovery.conf files on the other two servers to change the replication to run from S2.

I am not sure what is going on here as I am not that familiar with 
synchronous replication. I do think it would aid those that can help if 
you provided the contents of :

1) The Bash script

2) The recovery.conf file.

Also are there relevant log entries for S2, S3 and S4?

> I have changed the setting for synchronouse_standby_names using:
> 
> psql -c "ALTER SYSTEM SET synchronous_standby_names TO  'FIRST 1(S1,S3,S4)';" hoping that one of the remaining two or possibly the old master will SYNC to the new master (S2).
> 
> However when I check on S2 I get the following output from pg_stat_replication:
> 
> pid  | usename | name  |  state  | sent_lsn  | write_lsn | flush_lsn | replay_lsn | sync_priority | sync_state
> ------+---------+-------+---------+-------------+-----------+-----------+-----------+------------+---------------+------------
>   6418 | replica | S4 | startup | 0/D000098 | 0/D000098 | 0/D000098 | 0/D000098  |             3 | potential
>   6417 | replica | S3 | startup | 0/D000098 | 0/D000098 | 0/D000098 | 0/D000098  |             2 | potential
> 
> If I also get the original master (S1) running and set it up as a Slave this also will not "SYNC". How can I get the standby servers to SYNC to the new Master (S2) without doing a new BaseBackup from S2 to the other servers?
> 
> Thanks
> 
> Tom
> 
> 
> 
> 
> 
> 
> 
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com




view thread (2+ messages)

Message-ID: <32f5d09a-3989-1c68-18c2-cdf21cd7d8ad@aklaver.com>
Permalink:  ../32f5d09a-3989-1c68-18c2-cdf21cd7d8ad@aklaver.com/
Also on:    postgresql.org/message-id/32f5d09a-3989-1c68-18c2-cdf21cd7d8ad@aklaver.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: adrian.klaver@aklaver.com, tom.loder@servelec-technologies.com
  Subject: Re: Failover replication building a new master
  In-Reply-To: <32f5d09a-3989-1c68-18c2-cdf21cd7d8ad@aklaver.com>
  References: <ED127BEF191D73498D32229AD28B3554BF60764F@GSH-EXD-02.cse-servelec.com> <32f5d09a-3989-1c68-18c2-cdf21cd7d8ad@aklaver.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox