MySQL mmm 方案 Master-Master Replication Manager for mysql
mysql-mmm的监管端会提供多个虚拟IP(VIP),包括一个可写VIP,多个可读VIP,通过监管的管理,这些IP会绑定在可用mysql之上,当某一台mysql宕机时,监管会将VIP迁移至其他mysql
MMM即Master-Master Replication Manager for MySQL(mysql主主复制管理器)关于mysql主主复制配置的监控、故障转移和管理的一套可伸缩的脚本套件(在任何时候只有一个节点可以被写入),这个套件也能对居于标准的主从配置的任意数量的从服务器进行读负载均衡,所以你可以用它来在一组居于复制的服务器启动虚拟ip,除此之外,它还有实现数据备份、节点之间重新同步功能的脚本
Mmm主要功能由下面三个脚本提供
mmm_mond 负责所有的监控工作的监控守护进程,决定节点的移除等等
mmm_agentd 运行在mysql服务器上的代理守护进程,通过简单远程服务集提供给监 控节点
mmm_control 通过命令行管理mmm_mond进程
1.配置2台DB之间互为master 模式
2.需要安装epel包
下载:http://rpmfind.net/linux/rpm2html/search.php?query=epel-release
http://dl.fedoraproject.org/pub/epel/6/i386/
3.安装mysql-mmm包
yum -y install mysql-mmm*
4.二进制安装包
wget http://mysql-mmm.org/_media/:mmm2:mysql-mmm-2.2.1.tar.gz
# mv :mmm2:mysql-mmm-2.2.1.tar.gz mysql-mmm-2.2.1.tar.gz
# tar -zxvf mysql-mmm-2.2.1.tar.gz
# cd mysql-mmm-2.2.1
# make install
5.配置 agent
配置MYSQL-MMM-AGENTD
添加数据库权限
server1,server2,server3
grant super,replication client,process on *.* to 'mmm_agent'@'192.168.146.%' identified by 'mmm_agent';
flush privileges;
6.配置mysql-mmm (注释值要去掉,否则会失败,/var/log/mysql-mmm/mmm_agentd.log)
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 mm #同步的帐号
replication_password mm@123 #同步的密码
agent_user mmm_agent #mmm-agent用户名
ageord mmm_agent #mmm-agent用户密码
</hnt_passwost>
<host mysql_master_1> #db1的ip
ip 192.168.146.142
mode master
peer mysql_master_2
</host>
<host mysql_master_2> #db2的ip
ip 192.168.146.144
mode master
peer mysql_master_1
</host>
#<host db3>
# ip 192.168.100.51
# mode slave
#</host>
<role writer>
hosts mysql_master_1, mysql_master_2
ips 192.168.146.143 #设置写如的虚拟IP
mode exclusive
</role>
<role reader>
hosts mysql_master_1, mysql_master_2
ips 192.168.146.145 #设置读取的虚拟IP
mode balanced
</role>
7.编辑DB机器上 /etc/mysql-mmm/mmm_agent.conf文件
修改this db1 改成设定的值
8.编辑监控机上 /etc/mysql-mmm/mmm_mon.conf
server1,server2,server3
grant replication client on *.* to 'mmm_monitor'@'192.168.146.%' identified by 'mmm_monitor';
flush privileges;
文件内容:
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.146.143,192.168.146.145 #监控服务器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_monitor
monitor_password mmm_monitor
</host>
debug 0
9.启动代理:
配置权限:chmod 640 /etc/mysql-mmm/*
/etc/default/mysql-mmm-agent
ENABLED=1
/etc/init.d/mysql-mmm-agent start
错误1:
Can not locate Proc/Daemon.pm
yum install -y perl-*
10.启动监控机
/etc/init.d/mysql-mmm-monitor start
11.停止进程
ps -ef|grep mmm|awk '{print $2}'|xargs kill -9
12.显示控制列表
mmm_control show
mmm_control help
Valid commands are:
help - show this message
#查看帮助信息
ping - ping monitor
#ping监控
show - show status
#查看状态信息
checks [|all [|all]] - show checks status
#显示检查状态,包括(ping、mysql、rep_threads、rep_backlog)
set_online - set host online
#设置某host为online状态
set_offline - set host offline
#设置某host为offline状态
mode - print current mode.
#打印当前的模式,是ACTIVE、MANUAL、PASSIVE?
#默认ACTIVE模式
set_active - switch into active mode.
#更改为active模式
set_manual - switch into manual mode.
#更改为manual模式
set_passive - switch into passive mode.
#更改为passive模式
move_role [--force] - move exclusive role to host
#更改host的模式,比如更改处于slave的mysql数据库角色为write
(Only use --force if you know what you are doing!)
set_ip - set role with ip to host
#为host设置ip,只有passive模式的时候才允许更改!
问题:Can't connect to MySQL server on 'ip' (13)
解决方法1、:setsebool -P httpd_can_network_connect_db=1
解决方法2、:修改/etc/selinux/config SELINUX=enforcing 为 SELINUX=disabled
log_slave_updates = 1
问题:无法绑定VIP到网卡
cpan Net/ARP.pm
Copyright © 2024 妖气游戏网 www.17u1u.com All Rights Reserved