xpanta
By:
xpanta

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

February 19, 2017 346 views
PostgreSQL Ubuntu 16.04

Hi, I followed this tutorial (https://www.digitalocean.com/community/tutorials/how-to-set-up-master-slave-replication-on-postgresql-on-an-ubuntu-12-04-vps#configure-the-slave-server) 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 1.2.3.4 -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?

Be the first one to answer this question.