How to setup MMM control under CentOS 6.1

Jephe Wu -

Environment: CentOs 6.1, MMM 2.2.1, MySQL 5.1.52
Objective: setup MMM among the databases to gain HA and load balance for read access


1. install required packages for mmm agent on database servers
yum -y install perl-Config-IniFiles
yum -y install mysql-mmm mysql-mmm-agent mysql-mmm-tools mysql-proxy

2. install required packages for mmm monitor on monitoring host

yum -y install mysql-mmm-monitor

chkconfig mysql-mmm-agent on
chkconfig mysql-mmm-monitor on

3. preparing ips for databases
db1: master
db2: master
db3: slave

master exclusive ip:
slave balanced ip addresses:,,

4. setup /etc/mysql-mmm/mmm_agent.conf to change 'this' line to db1/db2 or db3

5. setup /etc/mysql-mmm/mmm_common.conf for all monitor and agents

# more /etc/mysql-mmm/mmm_common.conf
active_master_role          writer

<host default>
    cluster_interface       bond0

    pid_path                /var/run/mysql-mmm/
    bin_path                /usr/libexec/mysql-mmm/

    replication_user        replication
    replication_password    replication_password

    agent_user              mmm_agent
    agent_password          agent_password

<host db1>
    mode                    master
    peer                    db2

<host db2>
    mode                    master
    peer                    db1

<host db3>
    mode                    slave

<role writer>
    hosts                   db1, db2
    mode                    exclusive

<role reader>
    hosts                   db1, db2, db3
    ips           ,,
    mode                    balanced

6. start up agents on database servers first

on db1,db2 then db3, to start up mmm agent: /etc/init.d/mysql-mmm-agent start

7. start up monitor process on monitoring host

on mon01, to start up: /etc/init.d/mysql-mmm-monitor start

8. bring up them online from mon01

mon01# mmm_control set_online db1
mon01# mmm_control set_online db2
mon01# mmm_control set_online db3

root@mon01:/etc/mysql-proxy/ # mmm_control show
  db1( slave/REPLICATION_DELAY. Roles:
  db2( master/ONLINE. Roles: reader(, reader(
  db3( master/ONLINE. Roles: reader(, writer(

9. FAQ
a.   read_only (on/off) from show variables comand in mysql
if db2 and db3 are writer, when writer role goes to db3, mmm will set read_only flag for db2 to prevent any writing process, but only for normal user, not root.