_common.conf data01:/etc/mysql-mmm/mmm_common.conf
scp /etc/mysql-mmm/mmm_common.conf data02:/etc/mysql-mmm/mmm_common.conf
?
4.3 配置mmm_agent.conf文件
在db1、db2、db3上面配置agent
db1(192.168.52.129):
[root@data01 mysql-mmm]# cat/etc/mysql-mmm/mmm_agent.conf
include mmm_common.conf
this db1
[root@data01 mysql-mmm]#
?
db2(192.168.52.128):
[root@data02 mysql-mmm-2.2.1]# vim/etc/mysql-mmm/mmm_agent.conf
?
include mmm_common.conf
this db2
?
db3(192.168.52.131):
[root@oraclem1 vendor_perl]# cat /etc/mysql-mmm/mmm_agent.conf
include mmm_common.conf
this db3
[root@oraclem1 vendor_perl]#
?
4.4 配置monitor
[root@oraclem1 vendor_perl]# cat /etc/mysql-mmm/mmm_mon.conf
include mmm_common.conf
ip 127.0.0.1
pid_path /var/run/mmm_mond.pid
bin_path /usr/lib/mysql-mmm/
status_path /var/lib/misc/mmm_mond.status
ping_ips 192.168.52.129, 192.168.52.128, 192.168.52.131
monitor_user mmm_monitor
monitor_password mmm_monitor_1234
debug 0
[root@oraclem1 vendor_perl]#
?
这里只在原有配置文件中的ping_ips添加了整个架构被监控主机的ip地址,而在
中配置了用于监控的用户。
?
4.5 创建监控用户
| 用户名 |
描述 |
权限 |
| Monitor user |
mmm的monitor端监控所有的mysql数据库的状态用户 |
REPLICATION CLIENT |
| Agent user |
主要是MMM客户端用于改变的master的read_only状态用 |
SUPER,REPLICATION CLIENT,PROCESS |
| repl复制账号 |
用于复制的用户 |
REPLICATION SLAVE |
?
在3台服务器(db1,db2,db3)进行授权,因为我之前做mha实验的时候mysql已经安装好了,而且复制账号repl也已经建立好了,repl账号语句:GRANT REPLICATION SLAVE ON*.* TO 'repl'@'192.168.52.%' IDENTIFIED BY 'repl_1234';monitor用户:GRANTREPLICATION CLIENT ON *.* TO 'mmm_monitor'@'192.168.0.%' IDENTIFIED BY'mmm_monitor_1234'; agent用户:GRANT SUPER, REPLICATION CLIENT, PROCESS ON *.* TO'mmm_agent'@'192.168.0.%' IDENTIFIED BY'mmm_agent_1234';如下所示:
mysql> GRANT REPLICATION CLIENT ON *.* TO 'mmm_monitor'@'192.168.52.%' IDENTIFIED BY 'mmm_monitor_1234';
Query OK, 0 rows affected (0.26 sec)
mysql> GRANT SUPER, REPLICATION CLIENT, PROCESS ON *.* TO 'mmm_agent'@'192.168.52.%' IDENTIFIED BY 'mmm_agent_1234';
Query OK, 0 rows affected (0.02 sec)
mysql>
?
如果是从头到尾从新搭建,则加上另外一个复制账户repl的grant语句(分别在3台服务器都需要执行这3条SQL):GRANT REPLICATION SLAVE ON *.* TO 'repl'@'192.168.52.%' IDENTIFIEDBY '123456'; 如下所示:
mysql> GRANT REPLICATION SLAVE ON *.* TO'repl'@'192.168.52.%' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.01 sec)
?
mysql>
?
5,搭建起db1、db2、db3之间的mms服务
db1、db2、db3已经安装好了,现在只需要搭建起mms的架构就可以了。
db1(192.168.52.129)-->db2(192.168.52.128)
db1(192.168.52.129)-->db3(192.168.52.131)
db2(192.168.52.128)—> db1(192.168.52.129)
?
5.1建立db1到db2、db3的复制
先去查看db1(192.168.52.129)上面的master状况:
mysql> show master status;
+------------------+----------+--------------+--------------------------------------------------+-------------------+
| File | Position | Binlog_Do_DB |Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+--------------------------------------------------+-------------------+
| mysql-bin.000208 | 1248 | user_db |mysql,test,information_schema,performance_schema | |
+------------------+----------+--------------+--------------------------------------------------+-------------------+
1 row in set (0.03 sec)
?
mysql>
?
然后在db2和db3上建立复制链接,步骤如下:
STOP SLAVE;
RESET SLAVE;
CHANGE MASTER TOMASTER_HOST='192.168.