0
votes

I have created a replicated Postgresql database (Master - Slave). I did this with an already existing Ansible Playbook (Role) , which I don't fully understand yet. The cluster currently consists of only 2 databases on different VMs.

So I want to test this replication now. Unfortunately I have little experience with Postgresql.

How can I control whether they connect stable? If the slave really takes over the task if the master should fail?

Many thanks for any information, tips & tricks.

Postgresql v. 9.6

1
unplug the cable :D - Jaisus
Shutdown the master and do some updates, queries, etc. See, if that works. Then restart the master and shutdown the slave. Do some updates, etc. Restart the slave (make sure both are running), give it some time and see if both databases get synched. If you want to check load balancing/slave updates fire up two terminals ans used the 'top' command to watch while you do queries, updates, etc. You will see the 'postmaster' become active... - Mr. de Silva

1 Answers

0
votes

Official PostgreSQL does not yet support automatic failover (Although there are multiple third-party projects which support this feature). Therefore if the deployment you have mentioned is only official PostgreSQL, after master failure, none of replicas take over the write task. But they can answer read queries if they are configured as hot_standby.

If you want to check the state of replication, in master you can check out pg_stat_replication in master.

Also these official docs would help you understand Postgres streaming replication & failover better: https://www.postgresql.org/docs/9.6/warm-standby.html#STREAMING-REPLICATION https://www.postgresql.org/docs/9.6/warm-standby-failover.html