MYSQL-3m架构回顾
时间:2022-03-10 18:08
grant replication client,process,super on *.* to " identified by "agent";
在所有主机上编辑mmm_common.conf 文件
[root@localhost mysql-mmm]# cat /etc/mysql-mmm/mmm_common.conf
active_master_role writer
<host default>
cluster_interface eth0
pid_path /var/run/mmm_agentd.pid
bin_path /usr/lib/mysql-mmm/
replication_user slave
replication_password slave
agent_user agent
agent_password agent
</host>
<host db10>
ip 192.168.10.10
mode master
peer db20
</host>
<host db20>
ip 192.168.10.20
mode master
peer db10
</host>
<host db30>
ip 192.168.10.30
mode slave
</host>
<host db40>
ip 192.168.10.40
mode slave
</host>
<role writer>
hosts db10, db20
ips 192.168.10.110 #指定负责写操作数据库服务器使用的虚拟ip
mode exclusive
</role>
<role reader>
hosts db20, db30,db40
ips 192.168.10.120, 192.168.10.130, 192.168.10.140 #指定负责读操作数据库服务器使用的虚拟ip
mode balanced
</role>
[root@localhost mysql-mmm]#
参数解释:
peer的意思是等同,表示db1与db2是同等的。
ips指定VIP
mode exclusive 只有两种模式:exclusive是排他,在这种模式下任何时候只能一个host拥有该角色
balanced模式下可以多个host同时拥有此角色。一般writer是exclusive,reader是balanced
在4台数据库服务器10、20、30、40上 编辑mmm_agent.conf (此文件监控主机上可以没有)
[root@localhost mysql-mmm]# cat /etc/mysql-mmm/mmm_agent.conf
include mmm_common.conf
this db10 #此处修改为当前数据库服务器的主机名(主机头名字即可)
在4台数据库服务器10、20、30、40上启动代理进程agent
[root@localhost ~ ]# /etc/init.d/mysql-mmm-agent start
Daemon bin: ‘/usr/sbin/mmm_agentd‘
Daemon pid: ‘/var/run/mmm_agentd.pid‘
Starting MMM Agent daemon... Ok
[root@localhost mysql-mmm]#ps aux | grep mmm_agentd 默认监听9989端口
编辑监控主机254的配置文件 mmm_mon.conf
[root@localhost mysql-mmm]# cat mmm_mon.conf
include mmm_common.conf
<monitor>
ip 192.168.10.254
pid_path /var/run/mmm_mond.pid
bin_path /usr/lib/mysql-mmm/
status_path /var/lib/misc/mmm_mond.status
ping_ips 192.168.10.10, 192.168.10.20, 192.168.10.30, 192.168.10.40 #4台数据库服务器的真实ip地址。
</monitor>
<host default>
monitor_user monitor
monitor_password monitor
</host>
debug 0
[root@localhost mysql-mmm]#
由于文件太多,在这里做下RP:
/etc/mysql-mmm/mmm_common.conf 所有主机,大家心里有数,有几台服务器,都扮演什么角色
/etc/mysql-mmm/mmm_agent.conf 被监控主机,告诉大家自己是什么角色.
/etc/init.d/mysql-mmm-agent start 被监控主机,运行agent进程
/etc/mysql-mmm/mmm_mon.conf 告诉mmm脚本,我是监控。
/etc/init.d/mysql-mmm-monitor start 监控主机,运行monitor进程。
在监控服务器104上查看4台数据库服务器的状态
监控名 mmm_control命令简介
[root@server3 mysql-mmm]# mmm_control help
help 查看帮助信息
ping ping监控
show 查看状态信息
checks [<host>|all [<check>|all]] 显示检查状态,包括(ping、mysql、rep_threads、rep_backlog)
set_online <host> 设置某host为online状态
set_offline <host> 设置某host为offline状态
mode 打印当前的模式,是ACTIVE、MANUAL、PASSIVE?默认ACTIVE模式
set_active 更改为active模式
set_manual 更改为manual模式
set_passive 更改为passive模式
move_role [--force] <role> <host> - move exclusive role <role> to host <host>
#更改host的模式,比如更改处于slave的mysql数据库角色为write
(Only use --force if you know what you are doing!)
set_ip <ip> <host> 为host设置ip,只有passive模式的时候才允许更改!
测试mysql mmm 配置:
1、在监控主机192.168.1.104上执行 mmm_control show
2、停止192.168.1.100 上的数据库服务,再执行mmm_control show命令,发现192.168.1.101 使用虚拟Ip 192.168.1.12
3、在slave角色的数据库服务器上 查看是否获取到监控主机分配的虚拟ip地址 ,执行命令 ip a 或 ip addr show
使用ifconfig 命令看不到网卡获取的虚拟Ip地址。
4、分别在2台,master角色的主机上做用户授权:grant all on *.* to " identified by "123";
在客户端访问master数据库服务器:mysql -h192.168.1.12 -uroot -p123 (能够登陆成功说明配置成功)
本文出自 “” 博客,请务必保留此出处