Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I convert a postgres 9.3 Slave to read-write without Impacting the Master

I have a Postgres 9.3 Master-Slave stream replication setup on Ubuntu.
I would like to just convert the Slave into read-write by breaking the replication. However, I do not want the Master to be impacted in any way, as its a critical Production. All I want is to have a clone of the Master, so that I can test pg_upgrade.

Can I just run a "pg_ctl promote" on the slave, and open the Slave for read/writes? Does running "pg_ctl promote" on the Slave have any impact on the Master?

Thanks very much.

like image 405
Murali Avatar asked Oct 25 '25 04:10

Murali


1 Answers

from docs:

To trigger failover of a log-shipping standby server, run pg_ctl promote or create a trigger file with the file name and path specified by the trigger_file setting in recovery.conf. If you're planning to use pg_ctl promote to fail over, trigger_file is not required.

so both pg_ctl promote -D data_dir and touch trigger_file promote slave equally. Master is affected by slave being promoted in sense that sender stops sending. Other slaves streaming from master are affected in same manner. Promoting is a standard action.

The only specific case would be cascaded replication:

If an upstream standby server is promoted to become new master, downstream servers will continue to stream from the new master if recovery_target_timeline is set to 'latest'.

If you don't have any downstream "subslaves", promote it with courage.

like image 118
Vao Tsun Avatar answered Oct 26 '25 20:10

Vao Tsun



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!