I want to setup a HA postgres database. I setup master and slave database with synchronous streaming replication on different physical servers. When there is an error in the replication, the slave db triggers a script which switches the slave db to master db.

Both servers have an additional virtual ip address configured, in normal operation this interface is down on the slave db server. In case of a failure, the script will shutdown this interface on the master db server and start the corresponding one on the slave db server. Then the script executes some arp commands to let the LAN know that the IP address mapping has changed. When db clients reconnect they connect to the slave server which runs know as master on the same ip.

This works do far, but there are scenarios where it runs into trouble.

If I pull the network plug of the master machine, the failover mechanism will trigger. The slave db becomes master db on the same IP. However the script cannot shutdown the interface with the virtual IP on the (old) master, because the network is down. If I then put the network plug back in, there will be an ip address conflict on the virtual ip.

Are there concepts to also deal with such kind of situations?


I think something like heartbeat is what you are looking for. I found a HowTo for a Simple IP Failover With HeartBeat which should give you one way of solving the problem.

I believe this kind of setup is referred to as using a floating vip (as in virtual ip)


| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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