五、配置MMM监控、代理服务
1. 在三台服务器修改mmm_common.conf配置文件(三台服务器此配置文件内容相同)
修改后的内容如下:
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 mmm_agent #前面创建的代理账号密码
</host>
<host MySQL-M1>
ip 192.168.8.32 #MySQL-M1服务器IP
mode master
peer MySQL-M2 #MySQL-M2服务器主机名
</host>
<host MySQL-M2>
ip 192.168.8.33
mode master
peer MySQL-M1
</host>
<role writer>
hosts MySQL-M1, MySQL-M2 #能够作为Write的服务器
ips 192.168.8.30 #Write节点虚拟IP,应用的写请求将直接连接到这个IP
mode exclusive #排它模式
</role>
<role reader>
hosts MySQL-M1, MySQL-M2 #作为Reader的服务器
ips 192.168.8.34, 192.168.8.35 #Reader节点虚拟IP,应用的读请求将直接连接到这些IP
</role>
说明:mode exclusive
这个地方有两种模式:
exclusive:在这种模式下任何时候只能一个主机拥有该角色
balanced : 该模式下可以多个主机同时拥有此角色。
通常情况下writer是exclusive,reader是balanced
2. 在MySQL-M1服务器上修改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 MySQL-M1
3. 在MySQL-M2服务器上修改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 MySQL-M2
4. 在MySQL-MON服务器上配置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.8.32,192.168.8.33 #可以ping的真实agent服务器的IP
auto_set_online 10 #发现节点丢失则过10秒进行切换
# 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 mmm_monitor #前面创建的监控账号密码
</host>
debug 0
5.启动代理(默认是启用,这里只是说明下)
[root@MySQL-M1 mysql-mmm]# cat /etc/default/mysql-mmm-agent
# mysql-mmm-agent defaults
ENABLED=1
[root@MySQL-M2 mysql-mmm]# cat /etc/default/mysql-mmm-agent
# mysql-mmm-agent defaults
ENABLED=1
