Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So, I setup master-slave replication in MySQL on two virtual machines in two different physical servers. The problem that I am scratching my head at now, is, when the master goes down, how do the clients switch to the slave to do reads?

For example:

Master (
Slave  (

All clients currently connect to, how in the world do I configure this? Seems like I need IP-Failover, or some DNS magic. A DNS magic record that was that always pointed to the MySQL server that is up or master, would be perfect.

share|improve this question

You can use Heartbeat : It can manage a virtual IP address between your two nodes. Your clients will use this vip to connect to mysql - If the master fails, heartbeat detects it and ups the vip on the second node. Be careful not to set the auto-failover on the primary node when it comes back, because obviously his data will be outdated

share|improve this answer

If you want to go for "DNS magic", then choose Round Robin DNS.

This is only a partial solution: what about MySQL updates since the slave is read-only? Maybe MySQL master-master replication is a better solution in this situation.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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