MySQL High Availability Architectures: Master-Slave, MHA, MMM, and MGR Compared
This article explains MySQL high availability architectures including master-slave replication (async and semi-sync), MHA for automated failover, MMM for dual-master VIP switching, and MGR based on Paxos for strong consistency, detailing their principles, trade-offs, and use cases.
1. Master-Slave Replication
Normal operation: only Master handles writes; Master and Slave stay consistent via replication. On Master failure, a Slave is promoted.
Replication principle:
Master writes changes to binlog.
Slave IO thread connects to Master, reads binlog.
Slave IO thread writes to relay log.
Slave SQL thread executes SQL from relay log to replay data.
MySQL replication is asynchronous; Master commits transaction and returns immediately, risking data loss.
MySQL 5.5 introduced semi-synchronous replication:
Master waits for at least one Slave to acknowledge receipt of binlog (written to relay log, not necessarily executed) before committing.
Replication storm: Master overwhelmed by many Slaves. Solution: Slave-to-Slave replication.
2. MHA (Master High Availability)
Detects node failures and performs master-slave failover.
Components:
MHA Manager: decision layer, auto-detects Master failure, checks replication status, executes automatic failover.
MHA Node: deployed on each MySQL server, repairs master-slave data differences.
Failover process:
MHA Manager periodically probes Master heartbeat; 4 consecutive missed heartbeats triggers failover.
Manager compares Slaves' binlog positions; the Slave with binlog closest to Master becomes candidate Master.
MHA Node attempts SSH to Master server: if reachable, sync missing data; if unreachable, Slaves compare relay logs to sync differences.
Manager establishes new master-slave topology, promotes candidate to Master, other Slaves replicate from new Master.
3. MMM (Multi-Master Replication Manager for MySQL)
MMM is a dual-master failover and management script component with two Masters providing high availability.
MMM switches Master by moving virtual IP. When Master 1 fails, Master 2 takes over immediately, transparent to clients. However, MMM is outdated, does not support MySQL GTID, low community activity, and is unmaintained.
4. MGR (MySQL Group Replication)
MGR is based on the Paxos protocol, providing strong consistency across nodes and zero data loss. In a group of 2N+1 nodes, MGR tolerates N node failures, offering high fault tolerance.
Trade-off: strong consistency requires each write to communicate with a majority of nodes, so write performance is lower than asynchronous or semi-synchronous replication. MGR suits scenarios demanding strong consistency with moderate write load.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
