MySQL Master to Master Replication Setup with Automatic Failover

database-designMySQLreplication

Thanks in advance.

I have always worked with SQL Server and never really had any exposure to MySQL. I now have to determine the preferred setup for MySQL when there are four servers involved. Ideally, the solution needs to allow for Master to Master replication/automatic failover with each Master replicated to its own Slave. The Slave does not need to be promoted to a Master in any scenario, but it does need to be updated from its Master.

In .Net, and with SQL Server, it was always easy to set up mirroring/failover with a witness and then simply incorporating the "failover" server directly in the configuration file's connection string. MySQL seems to be much more involved.

I've read a good bit about MySQL replication and the potential pitfalls it may include and I would like to avoid those if possible. I've also started looking into MySQL clustering, but I'm not sure that is the best solution here since the servers are setup to be separate from each other in a primary/secondary set (with the Master in each being replicated).

Ultimately, it is just Primary Master <-> Secondary Master and then a Slave behind each Master. If there is a better solution such as using all four servers (even though separated by Primary/Secondary domains) with clustering etc. please reply also – just trying to determine the best setup.

I should note that this is for installation on Windows Server 2012 R2.

It is difficult to find this setup anywhere through searching!

Any help is greatly appreciated!

Best Answer

  • MHA orchestrates the reconnection of slaves as needed.

  • Orchestrator orchestrates the reconnection of slaves as needed.

  • Galera (PXC, MariaDB) eliminates the need for failover by having all nodes writable, plus automatic repair of nodes that were offline.

  • Fabric is another way.

  • Doing the task yourself is possible, but complex, risky, etc, etc.