# Cluster interface
#cluster_interface eth0
# Debug mode
debug no
# Paths
bin_path /usr/local/mmm/bin
pid_path /usr/local/mmm/var/mmmd.pid
status_path /usr/local/mmm/var/mmmd.status
# Choose the default failover method [manual|wait|auto]
failover_method auto
# How many seconds to wait for both masters to become ONLINE
# before switching from WAIT to AUTO failover method, 0 = wait indefinitely
wait_for_other_master 2
# How many seconds to wait before switching node status from AWAITING_RECOVERY to ONLINE
# 0 = disabled
auto_set_online 1
# Logging setup
log mydebug
file /usr/local/mmm/var/mmm-debug.log
level debug
log mytraps
file /usr/local/mmm/var/mmm-traps.log
level trap
email yanjing.zhao@pcstars.com
email 15810370266@139.com
# Email notification settings
email notify
from_address mmm_control@example.com
from_name MMM Control
# Define roles
active_master_role writer
# MMMD command socket tcp-port
agent_port 9989
monitor_ip 127.0.0.1
# Cluster hosts addresses and access params
host db1
ip 211.100.97.246
port 3306
user rep_agent
password 123456
mode master
pear db2
host db2
ip 211.100.97.250
port 3306
user rep_agent
password 123456
mode master
pear db1
# Define roles that are assigned to the above hosts
# MySQL Reader role
role reader
mode balanced
servers db1, db2
ip 211.100.97.243,211.100.97.244
# Mysql Writer role
role writer
mode exclusive
servers db1, db2
ip 211.100.97.248
# Replication credentials used by slaves to connect to the master
replication_user replication
replication_password 123456
# Checks parameters
# Ping checker
check ping
check_period 1
trap_period 5
timeout 2
# Mysql checker
# (restarts after 10000 checks to prevent memory leaks)
check mysql
check_period 1
trap_period 2
timeout 2
restart_after 10000
# Mysql replication backlog checker
# (restarts after 10000 checks to prevent memory leaks)
check rep_backlog
check_period 5
trap_period 10
max_backlog 60
timeout 2
restart_after 10000
# Mysql replication threads checker
# (restarts after 10000 checks to prevent memory leaks)
check rep_threads
check_period 1
trap_period 5
timeout 2
restart_after 10000
--------------------------
五 启动进程
在db1和db2上配置完mmm_agent.conf和mmm_common.conf之后才能启动agent进程
启动 mmmd_agent进程
[root@XKWB5705 etc]# /usr/local/mmm/scripts/init.d/mmm_agent start
Starting MMM Agent daemon: MySQL Multi-Master Replication Manager
Version: 1.2.3
Ok
在monit上配置完mmm_mon.conf之后启动mon进程
[root@CentOS etc]# /usr/local/mmm/scripts/init.d/mmm_mon start
Daemon bin: '/usr/local/mmm/sbin/mmmd_mon'
Daemon pid: '/usr/local/mmm/var/mmmd.pid'
Starting MMM Monitor daemon: MySQL Multi-Master Replication Manager
Version: 1.2.3
Reading config file: 'mmm_mon.conf'
$VAR1 = {};
Ok
------------------------
db1和db2查看进程
[root@XKWB5510 etc]# ps aux |grep mmm
root 13702 0.4 0.4 107260 8444 ? S 15:21 0:03 /usr/bin/perl /usr/local/mmm/sbin/mmmd_agent
monit上查看进程
[root@CentOS etc]# ps aux |grep mmm
root 24608 0.6 1.9 258556 39352 ? Sl 15:17 0:04 perl /usr/local/mmm/sbin/mmmd_mon
root 24611 0.0 0.4 107392 8280 ? S 15:17 0:00 perl /usr/local/mmm/bin/check/checker rep_backlog
root 24613 0.1 0.4 107392 8252 ? S 15:17 0:00 perl /usr/local/mmm/bin/check/checker mysql
root 24615 0.2 0.2 91668 5368 ? S 15:17 0:01 perl /usr/local/mmm/bin/check/checker ping
root 24617 0.2 0.4 107392 8280 ? S 15:17 0:01 perl /usr/local/mmm/bin/check/checker rep_threads
连续观察了几次monit上的进程变化情况
从变化情况可以看出monitor用fping检测两个节点的存活状况
[root@CentOS etc]# ps aux |grep mmm
root 24608 0.6 1.9 258556 39356 ? Sl 15:17 0:07 perl /usr/local/mmm/sbin/mmmd_mon
root 24611 0.0 0.4 107392 8288 ? S 15:17 0:00 perl /usr/local/mmm/bin/check/checker rep_backlog
root 24613 0.1 0.4 107392 8264 ? S 15:17 0:01 perl /usr/local/mmm/bin/check/checker mysql
root 24615 0.2 0.2 91668 5368 ? S 15:17 0:02 perl /usr/local/mmm/bin/check/checker ping
root 24617 0.1 0.4 107392 8280 ? S 15:17 0:02 perl /usr/local/mmm/bin/check/checker rep_threads
[root@CentOS etc]# ps aux |grep mmm
root 24608 0.6 1.9 258556 39356 ? Sl 15:17 0:07 perl /usr/local/mmm/sbin/mmmd_mon
root 24611 0.0 0.4 107392 8288 ? S 15:17 0:00 perl /usr/local/mmm/bin/check/checker rep_backlog
root 24613 0.1 0.4 107392 8264 ? S 15:17 0:01 perl /usr/local/mmm/bin/check/checker mysql
root 24615 0.2 0.2 91668 5368 ? S 15:17 0:02 perl /usr/local/mmm/bin/check/checker ping
root 24617 0.1 0.4 107392 8280 ? S 15:17 0:02 perl /usr/local/mmm/bin/check/checker rep_threads
root 25887 0.0 0.0 1804 504 ? S 15:35 0:00 /usr/local/mmm/bin/sys/fping -q -u -t 500 -C 1 211.100.97.246
[root@CentOS etc]# ps aux |grep mmm
root 24608 0.6 1.9 258556 39356 ? Sl 15:17 0:07 perl /usr/local/mmm/sbin/mmmd_mon
root 24611 0.0 0.4 107392 8288 ? S 15:17 0:00 perl /usr/local/mmm/bin/check/checker rep_backlog
root 24613 0.1 0.4 107392 8264 ? S 15:17 0:01 perl /usr/local/mmm/bin/check/checker mysql
root 24615 0.2 0.2 91668 5368 ? S 15:17 0:02 perl /usr/local/mmm/bin/check/checker ping
root 24617 0.1 0.4 107392 8280 ? S 15:17 0:02 perl /usr/local/mmm/bin/check/checker rep_threads
root 25890 0.0 0.0 1804 504 ? S 15:35 0:00 /usr/local/mmm/bin/sys/fping -q -u -t 500 -C 1 211.100.97.250
连续观察db2上进程的变化情况
可以看到db2不断检测db1的读进程以及monit的写进程
[root@XKWB5705 etc]# ps aux |grep mmm
root 1613 0.3 0.2 107272 8440 ? S 15:18 0:04 /usr/bin/perl /usr/local/mmm/sbin/mmmd_agent
root 12026 0.0 0.1 99564 7056 ? S 15:38 0:00 perl /usr/local/mmm/bin/agent/check_role writer(211.100.97.248;)
root 12027 0.0 0.1 102200 7572 ? R 15:38 0:00 perl /usr/local/mmm/bin/mysql_allow_write
[root@XKWB5705 etc]# ps aux |grep mmm
root 1613 0.3 0.2 107272 8440 ? S 15:18 0:04 /usr/bin/perl /usr/local/mmm/sbin/mmmd_agent
root 12121 0.0 0.1 92552 6176 ? R 15:38 0:00 perl /usr/local/mmm/bin/agent/check_role writer(211.100.97.248;)
root 1613 0.3 0.2 107272 8440 ? S 15:18 0:04 /usr/bin/perl /usr/local/mmm/sbin/mmmd_agent
root 12202 0.0 0.1 90072 5744 ? R 15:38 0:00 perl /usr/local/mmm/bin/agent/check_role reader(211.100.97.244;)
[root@XKWB5705 etc]# ps aux |grep mmm
root 1613 0.3 0.2 107272 8440 ? S 15:18 0:04 /usr/bin/perl /usr/local/mmm/sbin/mmmd_agent
连续观察db1上进程的变化情况
可以看到db1不断检测db2的读进程
[root@XKWB5510 etc]# ps aux |grep mmm |grep -v grep
root 13702 0.4 0.4 107260 8444 ? S 15:21 0:06 /usr/bin/perl /usr/local/mmm/sbin/mmmd_agent
root 26820 0.0 0.3 97212 6712 ? R 15:44 0:00 perl /usr/local/mmm/bin/agent/check_role reader(211.100.97.243;)
[root@XKWB5510 etc]# ps aux |grep mmm |grep -v grep
root 13702 0.4 0.4 107260 8444 ? S 15:21 0:06 /usr/bin/perl /usr/local/mmm/sbin/mmmd_agent
----------------------------
