目标
实现mysql的mmm架构
备注
- server[1-4]
- 用户名:dlq,密码:donglq
- server[1-3]每台部署3306实例
- server1、server2互为主从,server3为从
- server4部署mysql-mmm-monitor
- ip 10.89.10.230(写),10.89.10.231(读),10.89.10.232(读)
- 官方文档:http://mysql-mmm.org/doku.php
步骤
安装数据库
- 省略
设置主从复制
- 创建主从复制账户
GRANT REPLICATION SLAVE ON *.* to 'rep'@'ip' identified by 'replication';
- 查看主数据库当前执行位置,记录下File和Position
show master status;
- 从数据库执行同步语句
change master to master_host='ip',
master_port=33086,
master_user='rep', master_password='replication', master_log_file='mysql-bin.000004', master_log_pos=445;
- 启动slave
start slave;
MMM的安装与配置
- 安装mysql-mmm-monitor
sudo yum -y install mysql-mmm-monitor
- 每一个Mysql节点上安装mysql-mmm-agent
sudo yum -y install mysql-mmm-agent
- 在所有Mysql节点上创建MMM的两个账号
- mmm_monitor:所有mysql节点进行健康检查
- mmm_agent:切换只读模式和同步Master信息
GRANT REPLICATION CLIENT ON *.* TO 'mmm_monitor'@'ip' IDENTIFIED BY 'donglq';
GRANT SUPER, REPLICATION CLIENT, PROCESS ON *.* TO 'mmm_agent'@'ip' IDENTIFIED BY 'donglq';
- 为eth0增加虚拟ip
server1: sudo ip addr add 10.89.10.230/24 dev eth0
server2: sudo ip addr add 10.89.10.231/24 dev eth0
server3: sudo ip addr add 10.89.10.232/24 dev eth0
ip addr show //查看
-
配置文件,在/etc/mysql-mmm下
-
日志在/var/log/mysql-mmm/下
-
在每个mysql服务器上启动agent
sudo /etc/init.d/mysql-mmm-agent @6 start
- 在monitor服务器上启动monitor
sudo /etc/init.d/mysql-mmm-monitor @6 start
- 查看状态
sudo mmm_control @6 show
- 设置db上线
sudo mmm_control @6 set_online db2
- 查看mmm-agent端口进程
sudo netstat -pna|grep 端口
网友评论