MMM---MySQL高可用性解决方案
一.环境如下:文章源自运维生存时间-https://www.ttlsa.com/mysql/mmm-mysql-master-master/
MMM_monitor: 192.168.1.1文章源自运维生存时间-https://www.ttlsa.com/mysql/mmm-mysql-master-master/
MySQL_master: 192.168.1.2, 192.168.1.3文章源自运维生存时间-https://www.ttlsa.com/mysql/mmm-mysql-master-master/
VIP_write: 192.168.1.11文章源自运维生存时间-https://www.ttlsa.com/mysql/mmm-mysql-master-master/
VIP_read: 192.168.1.22, 192.168.1.33文章源自运维生存时间-https://www.ttlsa.com/mysql/mmm-mysql-master-master/
MMM介绍参见: https://www.ttlsa.com/html/1208.html文章源自运维生存时间-https://www.ttlsa.com/mysql/mmm-mysql-master-master/
二.安装配置文章源自运维生存时间-https://www.ttlsa.com/mysql/mmm-mysql-master-master/
1.安装MMM文章源自运维生存时间-https://www.ttlsa.com/mysql/mmm-mysql-master-master/
rpm -ivh http://mirrors.ustc.edu.cn/fedora/epel/6/x86_64/epel-release-6-5.noarch.rpm文章源自运维生存时间-https://www.ttlsa.com/mysql/mmm-mysql-master-master/
yum install mysql-mmm文章源自运维生存时间-https://www.ttlsa.com/mysql/mmm-mysql-master-master/
yum install mysql mysql-server文章源自运维生存时间-https://www.ttlsa.com/mysql/mmm-mysql-master-master/
2.授权文章源自运维生存时间-https://www.ttlsa.com/mysql/mmm-mysql-master-master/
mysql> GRANT FILE, REPLICATION SLAVE ON *.* TO 'repl'@'192.168.1.%' IDENTIFIED BY 'www.ttlsa.com'文章源自运维生存时间-https://www.ttlsa.com/mysql/mmm-mysql-master-master/
mysql> GRANT PROCESS, SUPER, REPLICATION CLIENT ON *.* TO 'mmm_agent'@'192.168.1.%' IDENTIFIED BY 'www.ttlsa.com'文章源自运维生存时间-https://www.ttlsa.com/mysql/mmm-mysql-master-master/
mysql> GRANT REPLICATION CLIENT ON *.* TO 'mmm_monitor'@'192.168.1.1' IDENTIFIED BY 'www.ttlsa.com'文章源自运维生存时间-https://www.ttlsa.com/mysql/mmm-mysql-master-master/
3.两台数据库服务器配置成互为主主文章源自运维生存时间-https://www.ttlsa.com/mysql/mmm-mysql-master-master/
配置参见: https://www.ttlsa.com/html/1208.html文章源自运维生存时间-https://www.ttlsa.com/mysql/mmm-mysql-master-master/
[192.168.1.2]文章源自运维生存时间-https://www.ttlsa.com/mysql/mmm-mysql-master-master/
log_bin=mysql-bin文章源自运维生存时间-https://www.ttlsa.com/mysql/mmm-mysql-master-master/
log_bin_index=mysql-bin.index文章源自运维生存时间-https://www.ttlsa.com/mysql/mmm-mysql-master-master/
relay_log=mysql-relay-bin
relay_log_index=mysql-relay-bin.index
binlog_format=mixed
expire_logs_days =7
max_binlog_size = 100M
server-id = 2
auto-increment-increment = 2
auto-increment-offset = 2
[192.168.1.3]
log_bin=mysql-bin
log_bin_index=mysql-bin.index
relay_log=mysql-relay-bin
relay_log_index=mysql-relay-bin.index
binlog_format=mixed
expire_logs_days =7
max_binlog_size = 100M
server-id = 3
auto-increment-increment = 2
auto-increment-offset = 1
4.在数据库服务器上配置mmm监控代理服务
[192.168.1.2]# vi 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 www.ttlsa.com
agent_user mmm_agent
agent_password www.ttlsa.com
</host>
<host db1>
ip 192.168.1.2
mode master
peer db2
</host>
<host db2>
ip 192.168.1.3
mode master
peer db1
</host>
<role writer>
hosts db1,db2
ips 192.168.1.11
mode exclusive
</role>
<role reader>
hosts db1,db2
ips 192.168.1.22,192.168.1.33
mode balanced
</role>
[192.168.1.2]# vi mmm_agent.conf
include mmm_common.conf
this db1
[192.168.1.2]# /etc/init.d/mysql-mmm-agent start
[192.168.1.3]# vi 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 www.ttlsa.com
agent_user mmm_agent
agent_password www.ttlsa.com
</host>
<host db1>
ip 192.168.1.2
mode master
peer db2
</host>
<host db2>
ip 192.168.1.3
mode master
peer db1
</host>
<role writer>
hosts db1,db2
ips 192.168.1.11
mode exclusive
</role>
<role reader>
hosts db1,db2
ips 192.168.1.22,192.168.1.33
mode balanced
</role>
[192.168.1.3]# vi mmm_agent.conf
include mmm_common.conf
this db2
[192.168.1.3]# /etc/init.d/mysql-mmm-agent start
[192.168.1.1]# vi 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 www.ttlsa.com
agent_user mmm_agent
agent_password www.ttlsa.com
</host>
<host db1>
ip 192.168.1.2
mode master
peer db2
</host>
<host db2>
ip 192.168.1.3
mode master
peer db1
</host>
<role writer>
hosts db1,db2
ips 192.168.1.11
mode exclusive
</role>
<role reader>
hosts db1,db2
ips 192.168.1.22,192.168.1.33
mode balanced
</role>
[192.168.1.1]# 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 192.168.1.2,192.168.1.3
auto_set_online 60
</monitor>
<host default>
monitor_user mmm_monitor
monitor_password www.ttlsa.com
</host>
debug 0
[192.168.1.1]# /etc/init.d/mysql-mmm-monitor start
[192.168.1.1]# mmm_control show
slave1(192.168.1.2) master/ONLINE. Roles: reader(192.168.1.22)
slave2(192.168.1.3) master/ONLINE. Roles: reader(192.168.1.33), writer(192.168.1.11)
[192.168.1.1]# mmm_control checks all
评论