MySQL-mmm-two nodes(master)架构
- GRANT REPLICATION CLIENT ON *.* TO 'mmm_monitor'@'192.168.1.%'
- IDENTIFIED BY 'RepMonitor';
- GRANT SUPER, REPLICATION CLIENT, PROCESS ON *.* TO 'mmm_agent'@'192.168.1.%'
- IDENTIFIED BY 'RepAgent';
- active_master_role writer
- <host default>
- cluster_interface eth0
- pid_path /var/run/mysql-mmm/mmm_agentd.pid
- bin_path /usr/libexec/mysql-mmm/
- replication_user repl
- replication_password repl
- agent_user mmm_agent
- agent_password RepAgent
- </host>
- <host master>
- ip 192.168.1.106
- mode master
- peer slave1
- </host>
- <host slave1>
- ip 192.168.1.107
- mode master
- peer master
- </host>
- <role writer>
- hosts master, slave1
- ips 192.168.1.220
- mode exclusive
- </role>
- <role reader>
- hosts master, slave1
- ips 192.168.1.221, 192.168.1.222
- mode balanced
- </role>
4.数据库节点配置/etc/mysql-mmm/mmm_agent.conf
- include mmm_common.conf
- # The 'this' variable refers to this server. Proper operation requires
- # that 'this' server (db1 by default), as well as all other servers, have the
- # proper IP addresses set in mmm_common.conf.
- # 修改为主机名
- this master
5.monitor节点配置/etc/mysql-mmm/mmm_mon.conf
- include mmm_common.conf
- <monitor>
- ip 127.0.0.1
- pid_path /var/run/mysql-mmm/mmm_mond.pid
- bin_path /usr/libexec/mysql-mmm
- status_path /var/lib/mysql-mmm/mmm_mond.status
- ping_ips 192.168.1.1, 192.168.1.106, 192.168.1.107
- auto_set_online 60
- # The kill_host_bin does not exist by default, though the monitor will
- # throw a warning about it missing. See the section 5.10 "Kill Host
- # Functionality" in the PDF documentation.
- #
- # kill_host_bin /usr/libexec/mysql-mmm/monitor/kill_host
- #
- </monitor>
- <host default>
- monitor_user mmm_monitor
- monitor_password RepMonitor
- </host>
- debug 0
6.MySQL-mmm测试
- [root@monitor mysql-mmm]# mmm_control show
- master(192.168.1.106) master/ONLINE. Roles: reader(192.168.1.222), writer(192.168.1.220)
- slave1(192.168.1.107) master/ONLINE. Roles: reader(192.168.1.221)
- --关闭master主机上的mysql服务,角色成功切换
- [root@monitor mysql-mmm]# mmm_control show
- master(192.168.1.106) master/HARD_OFFLINE. Roles:
- slave1(192.168.1.107) master/ONLINE. Roles: reader(192.168.1.221), reader(192.168.1.222), writer(192.168.1.220)
- --启动master主机上的mysql服务,角色成功切换
- [root@monitor mysql-mmm]# mmm_control show
- master(192.168.1.106) master/ONLINE. Roles: reader(192.168.1.221)
- slave1(192.168.1.107) master/ONLINE. Roles: reader(192.168.1.222), writer(192.168.1.220)
7.常用命令
- [root@monitor mysql-mmm]# mmm_control show
- [root@monitor mysql-mmm]# mmm_control set_online slave1
- [root@monitor mysql-mmm]# mmm_control set_offline slave1