mha故障切换
当master 挂掉后会自动切换到slave01上去,可以看 tailf /var/mha_log/manager.log
4个问题:
1,切换后且原master01mysql服务启动OK,如何加入到以slave01为主的mha架构中?
grep -i change /var/mha_log/manager.log
Fri Dec 25 04:07:32 2015 - [info] All other slaves should start replication from here. Statement should be: CHANGE MASTER TO MASTER_HOST=‘db-95-15 or 192.xx.xx.xx‘, MASTER_PORT=3306, MASTER_LOG_FILE=‘mysql-bin.000001‘, MASTER_LOG_POS=403, MASTER_USER=‘repl‘, MASTER_PASSWORD=‘xxx‘;
复制即可解决。
2,如果我想关闭下主数据库不想切换怎么办?
/usr/local/bin/masterha_stop --conf=/etc/mha.cnf --停止自动切换
MHA Manager is not running on mha(2:NOT_RUNNING).
3,数据库故障,我想将原来的master01变成主怎么办?
/usr/local/bin/masterha_stop --conf=/etc/mha.cnf --停止自动切换
MHA Manager is not running on mha(2:NOT_RUNNING).
改切换脚本
vim /mha/sh/mha_mfailover.sh
masterha_master_switch --conf=/etc/mha.cnf --master_state=dead --ignore_last_failover --dead_master_host=db-95-14.dshamc.com --dead_master_ip=192.xx.xx.14 --dead_master_port=12345
改成
masterha_master_switch --conf=/etc/mha.cnf --master_state=dead --ignore_last_failover --dead_master_host=db-95-15 --dead_master_ip=192.xx.xx.xx --dead_master_port=12345
运行脚本
cd /mha/sh &&./mha_mfailover.sh > /tmp/mha_qihua_log --找到change master
检查切换结果
将slave01加入mha架构。
4,如何在线切换主从?
/mha/sh/mha_onlinechange.sh 看提示就可以了。
原文:http://www.cnblogs.com/liang545621/p/7517944.html