本机IP 虚拟IP 角色 10.201.100.213 10.201.100.250 mysql-control 10.201.100.214 10.201.100.251 mysql-master 10.201.100.215 10.201.100.252 mysql-master
在每台机器的配置文件更改主机名 /etc/sysconfig/network
rpm -ivh http://mirrors.ustc.edu.cn/fedora/epel/6/x86_64/epel-release-6-5.noarch.rpm yum install mysql-mmm (默认路径/etc/mysql-mmm) yum install mysql mysql-server 或者手动编译安装mysql
mysql-mmm软件如果是tar安装需要安装以下软件
yum -y install libproc-daemon-perl libalgorithm-diff-perl libdbi-perl libdbd-mysql-perl iproute
GRANT REPLICATION CLIENT ON *.* TO 'slave'@'10.201.100.%' IDENTIFIED BY 'slave'; Mysql主主配置操作略过.在完成数据同步之后继续下面操作。
GRANT SUPER, REPLICATION CLIENT, PROCESS ON *.* TO 'mmm_agent'@'10.201.100.%' IDENTIFIED BY 'mmm_agent'; flush privileges;
[root@master mysql-mmm]#vi /etc/mysql-mmm/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 slave ##mysql同步的账号 replication_password slave ###mysql同步的密码 agent_user mmm_agent ###监控代理的账号 agent_password mmm_agent ###监控代理的账号 </host> <host slave1> ###slave1为10.201.100.214主机名 ip 10.201.100.214 mode master peer slave2 ###slave2为10.201.100.215主机名 </host> <host slave2> ###slave2为10.201.100.215主机名 ip 10.201.100.215 mode master peer slave1 ###slave1为10.201.100.214主机名 </host> #<host db3> # ip 192.168.100.51 # mode slave #</host> <role writer> hosts slave1, slave2 ips 10.201.100.250 ###监控代理服务器的虚拟IP mode exclusive </role> <role reader> hosts slave1, slave2 ips 10.201.100.251, 10.201.100.252 ###两台主主服务器的虚拟IP mode balanced </role>
[root@master mysql-mmm]# cat 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 10.201.100.214,10.201.100.215 ###主主服务器IP 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_agent ###监控代理的账号 monitor_password mmm_agent ###监控代理的密码 </host> debug 0
[root@master mysql-mmm]# cat 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 slave1 ###主机名修改
/etc/init.d/mysql-mmm-agent start
/etc/init.d/mysql-mmm-monitor start
[root@master mysql-mmm]# mmm_control show slave1(10.201.100.214) master/ONLINE. Roles: reader(10.201.100.251) slave2(10.201.100.215) master/ONLINE. Roles: reader(10.201.100.252), writer(10.201.100.250)
本文出自 “柯小某” 博客,谢绝转载!