分类: Mysql/postgreSQL
2018-06-15 18:09:58
手动failover,这种场景意味着在业务上没有启用MHA自动切换功能,当主服务器故障时,人工手动调用MHA来进行故障切换操作,具体命令如下:
? 先关闭mha进程,确保不会自动执行切换
[root@mycat ~]# masterha_stop --conf=/etc/app1.cnf
? 再关闭maser主库
[root@master ~]# /etc/init.d/mysql.server stop
Shutting down MySQL............ SUCCESS!
? 执行手动切换
[root@mycat ~]# masterha_master_switch --master_state=dead --conf=/etc/app1.cnf --
dead_master_host=master --dead_master_port=3308 --new_master_ip=192.168.237.131 --
new_master_port=3308
……
----- Failover Report -----
app1: MySQL Master failover master to slave1 succeeded
Master master is down!
Check MHA Manager logs at mycat for details.
Started manual(interactive) failover.
The latest slave slave1(192.168.237.130:3308) has all relay logs for recovery.
Selected slave1 as a new master.
slave1: OK: Applying all logs succeeded.
slave2: This host has the latest relay log events.
Generating relay diff files from the latest slave succeeded.
slave2: OK: Applying all logs succeeded. Slave started, replicating from slave1.
slave1: Resetting slave info succeeded.
Master failover to slave1(192.168.237.130:3308) completed successfully.