Mysql MHA部署中如何手动更换
发布时间:2022-01-13 14:20:16 所属栏目:MySql教程 来源:互联网
导读:这篇文章给大家介绍Mysql MHA部署中如何手动切换,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。 架构说明: Mysql MHA部署中如何手动切换 1 检查从库现有状态(188,223) ---show slave statusG 2 查看管理节点日志(222) 通过如下
这篇文章给大家介绍Mysql MHA部署中如何手动切换,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。 架构说明: Mysql MHA部署中如何手动切换 1 检查从库现有状态(188,223) ---show slave statusG 2 查看管理节点日志(222) 通过如下命令事实查看MHA当前状态 tail -f /etc/mha/manager/mha.log 3 关闭MHA的管理进程(222) [root@rac4 ~]# masterha_stop -conf=/etc/mha/mha.conf MHA Manager is not running on mha(2:NOT_RUNNING). ![]() 4.手动切换 相关命令如下: masterha_master_switch -master_state=alive –orig_master_is_new_slave –conf=/etc/mha/mha.conf -master_state=alive 代表告诉MHA原master还是存活的,不需要将其从配置文件删除 –orig_master_is_new_slave 参数代表原master会自动同步新的master --还有一些其他的参数如下 -running_updates_limit 如果主库的写操作时间超过了该参数,则退出切换 –interactive=0 代表直接确认,不需要输入YES 切换过程如下: [root@rac4 ~]# masterha_master_switch -master_state=alive -orig_master_is_new_slave -conf=/etc/mha/mha.conf Sat Mar 14 22:17:37 2020 - [info] MHA::MasterRotate version 0.56. Sat Mar 14 22:17:37 2020 - [info] Starting online master switch.. Sat Mar 14 22:17:37 2020 - [info] Sat Mar 14 22:17:37 2020 - [info] * Phase 1: Configuration Check Phase.. Sat Mar 14 22:17:37 2020 - [info] Sat Mar 14 22:17:37 2020 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping. Sat Mar 14 22:17:37 2020 - [info] Reading application default configuration from /etc/mha/mha.conf.. Sat Mar 14 22:17:37 2020 - [info] Reading server configuration from /etc/mha/mha.conf.. Sat Mar 14 22:17:38 2020 - [info] GTID failover mode = 1 Sat Mar 14 22:17:38 2020 - [info] Current Alive Master: rac1(192.168.2.187:3306) Sat Mar 14 22:17:38 2020 - [info] Alive Slaves: Sat Mar 14 22:17:38 2020 - [info] rac2(192.168.2.188:3306) Version=5.7.28-log (oldest major version between slaves) log-bin:enabled Sat Mar 14 22:17:38 2020 - [info] GTID ON Sat Mar 14 22:17:38 2020 - [info] Replicating from 192.168.2.187(192.168.2.187:3306) Sat Mar 14 22:17:38 2020 - [info] Primary candidate for the new Master (candidate_master is set) Sat Mar 14 22:17:38 2020 - [info] rac3(192.168.2.223:3306) Version=5.7.28-log (oldest major version between slaves) log-bin:enabled Sat Mar 14 22:17:38 2020 - [info] GTID ON Sat Mar 14 22:17:38 2020 - [info] Replicating from 192.168.2.187(192.168.2.187:3306) Sat Mar 14 22:17:38 2020 - [info] Not candidate for the new Master (no_master is set) It is better to execute FLUSH NO_WRITE_TO_BINLOG TABLES on the master before switching. Is it ok to execute on rac1(192.168.2.187:3306)? (YES/no): YES Sat Mar 14 22:19:01 2020 - [info] Executing FLUSH NO_WRITE_TO_BINLOG TABLES. This may take long time.. Sat Mar 14 22:19:01 2020 - [info] ok. Sat Mar 14 22:19:01 2020 - [info] Checking MHA is not monitoring or doing failover.. Sat Mar 14 22:19:01 2020 - [info] Checking replication health on rac2.. Sat Mar 14 22:19:01 2020 - [info] ok. Sat Mar 14 22:19:01 2020 - [info] Checking replication health on rac3.. Sat Mar 14 22:19:01 2020 - [info] ok. Sat Mar 14 22:19:01 2020 - [info] Searching new master from slaves.. Sat Mar 14 22:19:01 2020 - [info] Candidate masters from the configuration file: Sat Mar 14 22:19:01 2020 - [info] rac1(192.168.2.187:3306) Version=5.7.28-log log-bin:enabled Sat Mar 14 22:19:01 2020 - [info] GTID ON Sat Mar 14 22:19:01 2020 - [info] rac2(192.168.2.188:3306) Version=5.7.28-log (oldest major version between slaves) log-bin:enabled Sat Mar 14 22:19:01 2020 - [info] GTID ON Sat Mar 14 22:19:01 2020 - [info] Replicating from 192.168.2.187(192.168.2.187:3306) Sat Mar 14 22:19:01 2020 - [info] Primary candidate for the new Master (candidate_master is set) Sat Mar 14 22:19:01 2020 - [info] Non-candidate masters: Sat Mar 14 22:19:01 2020 - [info] rac3(192.168.2.223:3306) Version=5.7.28-log (oldest major version between slaves) log-bin:enabled Sat Mar 14 22:19:01 2020 - [info] GTID ON Sat Mar 14 22:19:01 2020 - [info] Replicating from 192.168.2.187(192.168.2.187:3306) Sat Mar 14 22:19:01 2020 - [info] Not candidate for the new Master (no_master is set) Sat Mar 14 22:19:01 2020 - [info] Searching from candidate_master slaves which have received the latest relay log events.. Sat Mar 14 22:19:01 2020 - [info] From: rac1(192.168.2.187:3306) (current master) +--rac2(192.168.2.188:3306) +--rac3(192.168.2.223:3306) (编辑:随州站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |