I am learning Postgres and I have installed 3 VMs as follows:

node1 - Installed Postgres and etcd here

node2 - Installed Postgres and etcd here

node3 - Installed etcd here

I have setup streaming replication between node1 and node2 and it worked fine (even etcd health showed as fine for all 3 nodes).

Then I installed and configured Patroni on node1 and node2 and when I first started it node2 was promoted to master and node1 was acting as a slave. At the time I could access psql from both nodes but a change (I inserted a row in a table) I did in the master was not propagated to the slave.

I then stopped Patroni on node1 (slave) and restarted it but postgres on the slave is not starting and I cannot access psql on the slave either now. I don't know whether I should be able to access the DB from the slave or not when using Patroni (I could with streaming replication), i.e. should the postgres service remain switched off by design on the slave when you have Patroni? As from my understanding if it finds that there is a master holding a lock, postgres on the slave will fail to start.

I then stopped postgres on master as I thought that it will failover to node 1 (and node1 to become a master) but no automatic failover occurred. Furthermore, postgres service is not starting on either now (not even on node2 - but I can connect using psql on node2 - which still seems to be the master). Should postgres service be showing as running on the master or it also fails to start by design and one should only check the status of Patroni? Patroni is active and running on both nodes.

enter image description here

When I try to start postgres on node2 (the node holding the lock): enter image description here

enter image description here

Log on node1 (the slave): enter image description here

etcd is working fine: enter image description here

From my research I found that pg_rewind might help to get the slave in sync with my master, however, I'm not sure whether that is even my issue.

What do I need to do to fix this situation?

  1. I mainly need to start postgres on the master (I have no idea how I can use psql but postgres service is failing to start on the master).
  2. I need the slave to be able to promote itself to master (through Patroni), if the master fails.

My config files seem fine (especially since it was working fine prior to trying to switch off one instance for a failover to occur)

1 Answer 1


Stop and disable the postgresql service. Patroni is responsible for starting and stopping postgresql. If both services up you may end up brain split scenarios.

After that you can recreate your stand by with

patronictl -c "configfile" reinit "clustername" "nodename"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.