Postgresql replication: How to convert the old master to the new slave

Hi, I followed this tutorial ( to create a replication scheme between to postgresql servers (v9.5 on Ubuntu 16.04).

The only difference is that for the initial database replication I used this:

sudo -u postgres pg_basebackup -h -D /var/lib/postgresql/9.5/main -U [username] -v -P -x

Then I tried to test the failover process.

  1. I stopped the master server
  2. I ‘touched’ the trigger file on the Server to make it read-write (it worked)
  3. Added some test data on the Slave’s (now Master) database (it worked)
  4. I switched to the old master server and (a) did a pg_basebackup from the new master and (b) created a recovery.conf file (ir worked)
  5. restarted the new slave (no problems)

However whatever change I make on the new Master, it won’t be coped to the new slave. Also the new slave is not read-only.

Can someone explain to me what did I do wrong?


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!