The upcoming version of MySQL (5.6) has some neat features to simplify and automate the management of clusters of replicated databases (See ).
MySQL now provides utilities () to automatically detect the failure of a master database and automatically promote the most viable slave to take over. It is also easy to perform controlled switch over for maintenance purposes.
I had been wondering about writing a simple utility using Scala (because I quite like that language) and Zookeeper for creating self-healing clusters of replicated databases. In short, I was planning on doing the following:
- Keep track of slaves statuses in Zookeeper.
- Detect a failure of the master database, either by detecting a failure of the node itself, or by detecting that the MySQL process is no longer running.
- Handle fail-over to most up-to-date slave. This would use a custom ZK leader election algorithm.
- Manage cluster virtual IP address. When the master DB changes, the machine on which it is running can acquire the Virtual IP address assigned to the DB cluster.
I am looking forward to trying out those new features.