Re: the master has two sync slave, which slave can promote to master and the other slave as the new master's slave?

From: Lucas Possamai <drum(dot)lucas(at)gmail(dot)com>
To: lin <jluwln(at)163(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: the master has two sync slave, which slave can promote to master and the other slave as the new master's slave?
Date: 2017-03-19 06:09:15
Message-ID: CAE_gQfWwV6c0Usvc1dGd22RRmGHCbwakQHda=X3MAtsnqsqGJA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

2017-03-19 17:52 GMT+13:00 lin <jluwln(at)163(dot)com>:

> Hi,
> everyone. I am puzzled
> <https://www.baidu.com/link?url=jInEDezMLuMV_corXvCP8CETViLH7RBG45m-C91WcPScwzYDdIWsiKilkG-4jIwgFGyxoIYaKbkbt5ijJc4m1qnl5ESOYdXggHLBeBmpDmC&wd=&eqid=b06a8963001f680e0000000358ce0b14> about
> the question: the master A has two slave slave_1 , slave_2 , the version of
> postgres is 9.3. I want to promote one slave to master, and the other slave
> as the new master's slave, but which slave should can promote ?
>
> get the master-slave information from old master:
> postgres=# select * from pg_stat_replication;
> -[ RECORD 1 ]----+------------------------------
> pid | 15377
> usesysid | 10
> usename | postgres
> *application_name | slave_1*
> client_addr | 10.20.16.201
> client_hostname |
> client_port | 46086
> backend_start | 2017-03-19 12:42:02.026278+08
> state | streaming
> sent_location | 1/34FB0000
> write_location | 1/34EB0000
> flush_location | 1/34DB0000
> replay_location | 1/34C4FFD8
> sync_priority | 0
> sync_state | async
> -[ RECORD 2 ]----+------------------------------
> pid | 15411
> usesysid | 10
> usename | postgres
> *application_name | slave_2*
> client_addr | 10.20.16.200
> client_hostname |
> client_port | 51102
> backend_start | 2017-03-19 12:42:12.477886+08
> state | streaming
> sent_location | 1/414FD320
> write_location | 1/414FD320
> flush_location | 1/414FD320
> replay_location | 1/3DD91468
> sync_priority | 0
> sync_state | async
>
> 1. which one can promote to master ,slave_1 or slave_2 ?
> :: I think it is slave_2, because write_location slave_2 1/414FD320 >
> slave_1 (1/34FB0000), it is right?
>
> 2. If the slave_1 is sync state, which one can promote to master? I am
> puzzled.
>
>
You can promote any slave server to become a master server. It's up to you
which one to do it; more info can be found here [1].

*Example:*

slave_1 will be the new master and slave_2 will be the slave of that new
master.

Make sure to have all the wal files and history files copied to the
slave_2 server otherwise it won't be able to switch timeline.

[1] https://www.postgresql.org/docs/9.3/static/warm-standby-failover.html

Lucas

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Sylvain Marechal 2017-03-19 08:54:50 Re: Best way to alter a foreign constraint
Previous Message lin 2017-03-19 04:52:50 the master has two sync slave, which slave can promote to master and the other slave as the new master's slave?