To reattach a master server once a replica has been promoted in PostgreSQL, you need to perform the following steps:
- On the new master server, edit the
postgresql.confconfiguration file and set thewal_levelparameter tohot_standby. This will enable the new master server to keep a sufficient amount of transaction log data (WAL) to allow the old master server to connect and apply the changes. - Restart the new master server for the changes to take effect.
- On the old master server, edit the
postgresql.confconfiguration file and set thehot_standbyparameter toon. This will enable the old master server to connect to the new master server and start receiving the changes. - In the
recovery.conffile on the old master server, add the following lines to specify the connection details for the new master server: