Jephe Wu - http://linuxtechres.blogspot.com
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
Steps:
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: 172.17.7.1 master
db2: 172.17.7.2 master
db3: 172.17.7.3 slave
master exclusive ip: 172.17.7.4
slave balanced ip addresses: 172.17.7.5, 172.17.7.6, 172.17.7.7
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/mmm_agentd.pid
bin_path /usr/libexec/mysql-mmm/
replication_user replication
replication_password replication_password
agent_user mmm_agent
agent_password agent_password
</host>
<host db1>
ip 172.17.7.1
mode master
peer db2
</host>
<host db2>
ip 172.17.7.2
mode master
peer db1
</host>
<host db3>
ip 172.17.7.3
mode slave
</host>
<role writer>
hosts db1, db2
ips 172.17.7.4
mode exclusive
</role>
<role reader>
hosts db1, db2, db3
ips 172.17.7.5, 172.17.7.6, 172.17.7.7
mode balanced
</role>
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(172.17.7.1) slave/REPLICATION_DELAY. Roles:
db2(172.17.7.2) master/ONLINE. Roles: reader(172.17.7.5), reader(172.17.7.6)
db3(172.17.7.3) master/ONLINE. Roles: reader(172.17.7.7), writer(172.17.7.4)
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.
Tuesday, January 10, 2012
How to setup MMM control under CentOS 6.1
Posted by
Jephe Wu
at
1/10/2012 10:20:00 AM
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment