2017-03-19 17:52 GMT+13:00 lin <jluwln@xxxxxxx>:
Hi,everyone. I am puzzled 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 | 15377usesysid | 10usename | postgresapplication_name | slave_1client_addr | 10.20.16.201client_hostname |client_port | 46086backend_start | 2017-03-19 12:42:02.026278+08state | streamingsent_location | 1/34FB0000write_location | 1/34EB0000flush_location | 1/34DB0000replay_location | 1/34C4FFD8sync_priority | 0sync_state | async-[ RECORD 2 ]----+------------------------------ pid | 15411usesysid | 10usename | postgresapplication_name | slave_2client_addr | 10.20.16.200client_hostname |client_port | 51102backend_start | 2017-03-19 12:42:12.477886+08state | streamingsent_location | 1/414FD320write_location | 1/414FD320flush_location | 1/414FD320replay_location | 1/3DD91468sync_priority | 0sync_state | async1. 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.
Lucas