您的位置:首页 > 博客中心 > 数据库 >

MHA 多VIP 多MySQL实例的支持

时间:2022-03-14 04:50

MHA 多VIP 多MySQL实例的支持


首先看power_manager 脚本

MHA Manager如果能够SSH到Master主机,会调用stopssh方法,stopssh方法根据master_pid_file来远程kill MySQL实例的进程,不管是 kill 成功还是失败,最后都要返回10,

至于kill掉所有mysql instance的代码直接去掉。


MHA Manager如果不能够SSH到Master主机,会调用stop方法,由于是MySQL多实例,stop方法就一定不能 shutdown Master主机,不管你怎样扩展stop方法,最后都要返回0,来告诉MHA Manager 启动failover。

这样 power_manager脚本仅用来kill MySQL实例。


扩展参数配置文件的[server default]部分,添加以下两个参数,以告诉MHA Manager来管理MySQL实例的vip.

master_vip_interface=eth0:2

master_vip=192.168.23.88


在下面这三个源文件中添加master_vip_interface 和 master_vip的参数项目内容:

Config.pm

MasterMonitor.pm

MasterFailover.pm


对于 master_ip_failover脚本,我们同样添加这两个参数,然后在stopssh 中远程shutdown vip,在start中 startup vip。


在自动failover的时候,master_ip_failover脚本的调用都会附加 master_vip_interface 和 master_vip 两个参数:

--check status Phase
Fri Jan  9 14:46:53 2015 - [info] Checking master_ip_failover_script status:
Fri Jan  9 14:46:53 2015 - [info]   /script/mha/master_ip_failover --command=status --ssh_user=root --orig_master_host=mha1 --orig_master_ip=192.168.23.64 --orig_master_port=3306 --master_vip=192.168.23.88 --master_vip_interface=eth0:2 

--stop or stopssh Phase 卸载VIP
Fri Jan  9 14:48:41 2015 - [info] Forcing shutdown so that applications never connect to the current master..
Fri Jan  9 14:48:41 2015 - [info] Executing master IP deactivation script:
Fri Jan  9 14:48:41 2015 - [info]   /script/mha/master_ip_failover --orig_master_host=mha1 --orig_master_ip=192.168.23.64 --orig_master_port=3306 --master_vip=192.168.23.88  --master_vip_interface=eth0:2 --command=stopssh --ssh_user=root  
或
Fri Jan  9 16:14:55 2015 - [info] Forcing shutdown so that applications never connect to the current master..
Fri Jan  9 16:14:55 2015 - [info] Executing master IP deactivation script:
Fri Jan  9 16:14:55 2015 - [info]   /script/mha/master_ip_failover --orig_master_host=mha1 --orig_master_ip=192.168.23.64 --orig_master_port=3306 --master_vip=192.168.23.88  --master_vip_interface=eth0:2 --command=stop 

--start Phase 添加VIP
Fri Jan  9 14:48:44 2015 - [info] Executing master IP activate script:
Fri Jan  9 14:48:44 2015 - [info]   /script/mha/master_ip_failover --command=start --ssh_user=root --orig_master_host=mha1 --orig_master_ip=192.168.23.64 --orig_master_port=3306 --new_master_host=mha2 --new_master_ip=192.168.23.66 --new_master_port=3306 --new_master_user=‘root‘ --new_master_password=‘123QWE3306‘ --master_vip=192.168.23.88  --master_vip_interface=eth0:2  
Set read_only=0 on the new master.
Enabling the VIP - 192.168.23.88 on the new master - mha2:eth0:2.


本文出自 “” 博客,请务必保留此出处

本类排行

今日推荐

热门手游