Databases 7 min read

Master-Master MySQL Replication with MMM: Setup, Configuration, and HA Testing

This guide explains how to use the Perl‑based MMM tool to monitor and manage MySQL master‑master replication, covering its advantages, working principle, detailed server configurations, connection steps, master‑slave testing, and high‑availability failover demonstrations.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Master-Master MySQL Replication with MMM: Setup, Configuration, and HA Testing

Introduction

MMM (Master‑Master replication manager for MySQL) is a flexible Perl script suite for monitoring MySQL replication, handling failover, and managing master‑master configurations where only one node is writable at a time.

Pros and Cons

Advantages: high availability, good scalability, automatic failover, and data consistency by allowing only one writable master.

Disadvantage: the monitor node is a single point of failure, which can be mitigated by combining with Keepalived for HA.

Working Principle

The MMM monitor provides multiple virtual IPs (VIPs), including one writable VIP and several readable VIPs. These IPs are bound to available servers; when a server fails, the monitor migrates the VIPs to other servers.

Experimental Topology

Topology diagram
Topology diagram

# Note: System environment CentOS 6.6 # VIP 172.16.10.30 is the writable VIP; the other three groups are readable VIPs. # Writable VIP switches only between masters; readable VIPs can switch between masters and slaves. # Front‑end applications connect to any readable VIP for reads and to the writable VIP for writes.

DB1 Configuration

[root@node1 ~]# vim /etc/mysql/my.cnf

datadir = /mydata/data
log-bin = /mydata/binlogs/master-bin   # binary log location
relay-log = /mydata/relaylogs/relay-bin # relay log location
binlog_format = mixed
server-id = 1
auto_increment_offset = 1   # start value for auto‑increment in dual‑master
auto_increment_increment = 2 # step for auto‑increment in dual‑master
log_slave_updates = 1      # enable writing updates from slaves to binary log
sync_binlog = 1            # ensure transaction log is flushed to disk
skip-name-resolve          # disable DNS reverse lookup
read_only = 1

[root@node1 ~]# service mysqld start

DB2 Configuration

[root@node2 ~]# vim /etc/mysql/my.cnf

datadir = /mydata/data
log-bin = /mydata/binlogs/master-bin
relay-log = /mydata/relaylogs/relay-bin
binlog_format = mixed
server-id = 11
auto_increment_offset = 2
auto_increment_increment = 2
log_slave_updates = 1
sync_binlog = 1
skip-name-resolve
read_only = 1

[root@node2 ~]# service mysqld start

DB3 Configuration

[root@scholar ~]# vim /etc/mysql/my.cnf

datadir = /mydata/data
relay-log = /mydata/relaylogs/relay-bin
server-id = 111
read_only = 1
skip-name-resolve

[root@scholar ~]# service mysqld start

Server Connections

DB1 ↔ DB2, DB1 ↔ DB3, DB2 ↔ DB1 connections are illustrated below:

DB1 to DB2 connection
DB1 to DB2 connection
DB2 to DB1 connection
DB2 to DB1 connection
DB3 to DB1 connection
DB3 to DB1 connection

Master‑Slave Test

Master‑slave test result
Master‑slave test result

Data consistency is verified; the master‑slave replication part is complete.

MMM Configuration

Installation Packages

Installation packages
Installation packages

Authorize Monitoring and Proxy Users

User authorization
User authorization

Monitor Configuration

Monitor config 1
Monitor config 1
Monitor config 2
Monitor config 2
Monitor config 3
Monitor config 3

DB1‑DB3 Configuration

DB1‑DB3 config
DB1‑DB3 config

Start Services

Start services
Start services

Check Current Status

Current status
Current status

Check Node VIP Status

VIP status
VIP status
VIP status detail
VIP status detail

High Availability Test

Simulating a failure of DB1 shows the VIP being transferred to another node, confirming failover functionality.

HA test after DB1 failure
HA test after DB1 failure

After the test, the VIP has moved to a different node. Further testing can be performed as needed.

Conclusion

This experiment demonstrates MySQL/MariaDB read/write splitting and high availability using MMM. Interested readers may explore integrating Keepalived for a highly available monitor, though that is beyond the scope of this guide.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

databasehigh availabilitymysqlReplicationMMMperl
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.