52.129',MASTER_USER='repl',MASTER_PASSWORD='repl_1234',MASTER_LOG_FILE='mysql-bin.000208',MASTER_LOG_POS=1248;
START SLAVE;
SHOW SLAVE STATUS\G;
检查到双Yes和0就OK了。
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Seconds_Behind_Master: 0
?
5.2 再建立db2到db1的复制
查看db2(192.168.52.128)的master状况,然后建立复制链接
mysql> show master status;
+------------------+----------+--------------+--------------------------------------------------+-------------------+
| File | Position | Binlog_Do_DB |Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+--------------------------------------------------+-------------------+
| mysql-bin.000066 | 1477 | user_db |mysql,test,information_schema,performance_schema | |
+------------------+----------+--------------+--------------------------------------------------+-------------------+
1 row in set (0.04 sec)
?
mysql>
然后建立db2到db1的复制链接:
STOP SLAVE;
CHANGE MASTER TO MASTER_HOST='192.168.52.128',MASTER_USER='repl',MASTER_PASSWORD='repl_1234',MASTER_LOG_FILE='mysql-bin.000066',MASTER_LOG_POS=1477;
START SLAVE;
SHOW SLAVE STATUS\G;
检查到双Yes和0就OK了。
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Seconds_Behind_Master: 0
6,启动agent服务
分别在db1、db2、db3上启动agent服务
[root@data01 mysql-mmm]#/etc/init.d/mysql-mmm-agent start
Daemon bin: '/usr/sbin/mmm_agentd'
Daemon pid: '/var/run/mmm_agentd.pid'
Starting MMM Agent daemon... Ok
[root@data01 mysql-mmm]#
?
7,启动monitor服务
?
在monit服务器192.168.52.131上启动monitor服务:
添加进系统后台:chkconfig --add /etc/rc.d/init.d/mysql-mmm-monitor
开始启动:service mysql-mmm-monitor start
[root@oraclem1 ~]# servicemysql-mmm-monitor start
Daemon bin: '/usr/sbin/mmm_mond'
Daemon pid: '/var/run/mmm_mond.pid'
Starting MMM Monitor daemon: Ok
[root@oraclem1 ~]#
?
8,一些管理操作
查看状态:
[root@oraclem1 mysql-mmm]# mmm_control show
db1(192.168.52.129) master/AWAITING_RECOVERY. Roles:
db2(192.168.52.128) master/AWAITING_RECOVERY. Roles:
db3(192.168.52.131) slave/AWAITING_RECOVERY. Roles:
?
[root@oraclem1 mysql-mmm]#
?
8.1 设置online:
[root@oraclem1 mysql-mmm]# mmm_control show
db1(192.168.52.129) master/AWAITING_RECOVERY. Roles:
db2(192.168.52.128) master/AWAITING_RECOVERY. Roles:
db3(192.168.52.131) slave/AWAITING_RECOVERY. Roles:
?
[root@oraclem1 mysql-mmm]# mmm_controlset_online db1
OK: State of 'db1' changed to ONLINE. Nowyou can wait some time and check its new roles!
[root@oraclem1 mysql-mmm]# mmm_controlset_online db2
OK: State of 'db2' changed to ONLINE. Nowyou can wait some time and check its new roles!
[root@oraclem1 mysql-mmm]# mmm_controlset_online db3
OK: State of 'db3' changed to ONLINE. Nowyou can wait some time and check its new roles!
[root@oraclem1 mysql-mmm]#
?
8.2 check所有db
[root@oraclem1 mysql-mmm]# mmm_controlchecks
db2 ping [last change:2015/04/14 00:10:57] OK
db2 mysql [last change:2015/04/14 00:10:57] OK
db2 rep_threads [last change:2015/04/14 00:10:57] OK
db2 rep_backlog [last change:2015/04/14 00:10:57] OK: Backlog is null
db3 ping [last change:2015/04/14 00:10:57] OK
db3 mysql [last change:2015/04/14 00:10:57] OK
db3 rep_threads [last change:2015/04/14 00:10:57] OK
db3 rep_backlog [last change:2015/04/14 00:10:57] OK: Backlog is null
db1 ping [last change:2015/04/14 00:10:57] OK
db1 mysql [last change:2015/04/14