MHA故障切換方案
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 看提示就可以了。
MHA故障切換方案