MHA failover流程

MHA manager启动后,启动流程以及failover流程如下:


1. 启动前准备情况

2. 检查数据库服务器状态,获取相关的配置参数

3. 测试SSH连接是否成功

4. 测试MHA node是否可用

5. 开始检查SLAVE的差异日志应用权限

6. 确定当前的复制架构

7. 调试master_ip_failover_script脚本

8. 调试shutdown_script

9. 设置二次检查的主机masterha_secondary_check

10. MHA启动完毕,进入检测过程

11. 检测到MASTER挂了

12. 通过定义的二次检测,确认MASTER是否真的挂了

13. 确认MASTER挂了,开始执行failover流程

14. 再次尝试连接MASTER和MASTER 的SSH

15. 再次检查SLAVE的配置是否有变化,是否符合failover条件

16. 正式开始failover

17. 再次对SLAVE的配置做检查

18. 对原Master的master_ip_failover_script和shutdown_script的做操作,关闭SSH或者关闭数据库

19. 开始做差异日志的恢复,获取SLAVE最后得到的binlog位置

20. 获取原MASTER的binlog日志

21. 确定新的MASTER

22. 在新的MASTER上应用差异的binlog日志

23. 获取新MASTER的binlog位置

24. 如果有master_ip_failover,那么给新master设置VIP或者设置域名

25. 开始回去其他SLAVE,也是从原MASTER的binlog对比来做恢复

26. 差异日志应用完毕后,切换所有的slave到新MASTER

27. failover操作完成,生成failover报告

28. master manager退出



其中:

    

#master_ip_failover_script:
首先启动的时候会调用这个脚本--检测status
/opt/master_ip_failover_script.sh –command=status –ssh_user=root –orig_master_host=192.168.153.150 –orig_master_ip=192.168.153.150 –orig_master_port=3306
然后在正式failover过程中的第二步,Dead Master Shutdown Phase阶段会在次执行。  第18步,综合shutdown_script关闭数据库或者服务器
/opt/master_ip_failover_script.sh –orig_master_host=192.168.153.150 –orig_master_ip=192.168.153.150 –orig_master_port=3306 –command=stopssh –ssh_user=root
在正式failover过程中的第3.4步骤中(选举新的master以后,应用差异的binlog后),会再次执行。在第24步,执行VIP或者域名切换操作
/opt/master_ip_failover_script.sh –command=start –ssh_user=root –orig_master_host=192.168.153.150 –orig_master_ip=192.168.153.150 –orig_master_port=3306 –new_master_host=192.168.153.151 –new_master_ip=192.168.153.151 –new_master_port=3306 –new_master_user=’mha’ –new_master_password=’mha’


#shutdown_script:
首先启动的时候会执行这个脚本,执行时间紧跟着master_ip_failover_script第一次执行后面
/opt/shutdown_script.sh –command=status –ssh_user=root –host=192.168.153.150 –ip=192.168.153.150
第二次执行是在master_ip_failover_script第二次执行后面
/opt/shutdown_script.sh –command=stopssh –ssh_user=root –host=192.168.153.150 –ip=192.168.153.150 –port=3306

#report_script=”" //通知脚本
在masterha_manager自动切换完成的最后会调用一次这个脚本。
report_script.sh –orig_master_host=(dead master’s hostname) –new_master_host=(new master’s hostname) –new_slave_hosts=(new slaves’ hostnames, delimited by commas) –subject=(mail subject) –body=(body)


#master_ip_online_change_script:
在使用masterha_master_switch –conf=/etc/app1.cnf –master_state=alive –new_master_host=192.168.153.151主动切换mysql master的时候会调用.
在online切换的第二阶段,拒绝写入原master的时候执行。
/opt/master_ip_online_change_script.sh –command=stop –orig_master_host=192.168.153.150 –orig_master_ip=192.168.153.150 –orig_master_port=3306 –orig_master_user=’mha’ –orig_master_password=’mha’ –new_master_host=192.168.153.151 –new_master_ip=192.168.153.151 –new_master_port=3306 –new_master_user=’mha’ –new_master_password=’mha’
然后会在new master上执行
/opt/master_ip_online_change_script.sh –command=start –orig_master_host=192.168.153.150 –orig_master_ip=192.168.153.150 –orig_master_port=3306 –orig_master_user=’mha’ –orig_master_password=’mha’ –new_master_host=192.168.153.151 –new_master_ip=192.168.153.151 –new_master_port=3306 –new_master_user=’mha’ –new_master_password=’mha’


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值