• MHA手动切换 原创2 (主参与复制)







    monitor 执行下面命令后,
    --orig_master_is_new_slave :原主变为新从,即server1变成了slave1的从.
    slave2跟据app1.conf中配制也变成了slave1的从


    [root@monitor app1]# masterha_master_switch --conf=/etc/masterha/app1.conf --master_state=alive --new_master_host=slave1 --orig_master_is_new_slave Mon May 16 14:24:16 2016 - [info] MHA::MasterRotate version 0.56. Mon May 16 14:24:16 2016 - [info] Starting online master switch.. Mon May 16 14:24:16 2016 - [info] Mon May 16 14:24:16 2016 - [info] * Phase 1: Configuration Check Phase.. Mon May 16 14:24:16 2016 - [info] Mon May 16 14:24:16 2016 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping. Mon May 16 14:24:16 2016 - [info] Reading application default configuration from /etc/masterha/app1.conf.. Mon May 16 14:24:16 2016 - [info] Reading server configuration from /etc/masterha/app1.conf.. Mon May 16 14:24:16 2016 - [debug] Connecting to servers.. Mon May 16 14:24:16 2016 - [debug] Connected to: server1(10.24.220.232:3306), user=root Mon May 16 14:24:16 2016 - [debug] Number of slave worker threads on host server1(10.24.220.232:3306): 0 Mon May 16 14:24:16 2016 - [debug] Connected to: slave1(10.24.220.70:3306), user=root Mon May 16 14:24:16 2016 - [debug] Number of slave worker threads on host slave1(10.24.220.70:3306): 0 Mon May 16 14:24:16 2016 - [debug] Connected to: slave2(10.169.214.33:3306), user=root Mon May 16 14:24:16 2016 - [debug] Number of slave worker threads on host slave2(10.169.214.33:3306): 0 Mon May 16 14:24:16 2016 - [debug] Comparing MySQL versions.. Mon May 16 14:24:16 2016 - [debug] Comparing MySQL versions done. Mon May 16 14:24:16 2016 - [debug] Connecting to servers done. Mon May 16 14:24:16 2016 - [info] GTID failover mode = 1 Mon May 16 14:24:16 2016 - [info] Current Alive Master: server1(10.24.220.232:3306) Mon May 16 14:24:16 2016 - [info] Alive Slaves: Mon May 16 14:24:16 2016 - [info] slave1(10.24.220.70:3306) Version=5.7.11-log (oldest major version between slaves) log-bin:enabled Mon May 16 14:24:16 2016 - [info] GTID ON Mon May 16 14:24:16 2016 - [debug] Relay log info repository: FILE Mon May 16 14:24:16 2016 - [info] Replicating from 10.24.220.232(10.24.220.232:3306) Mon May 16 14:24:16 2016 - [info] Primary candidate for the new Master (candidate_master is set) Mon May 16 14:24:16 2016 - [info] slave2(10.169.214.33:3306) Version=5.7.11-log (oldest major version between slaves) log-bin:enabled Mon May 16 14:24:16 2016 - [info] GTID ON Mon May 16 14:24:16 2016 - [debug] Relay log info repository: FILE Mon May 16 14:24:16 2016 - [info] Replicating from 10.24.220.232(10.24.220.232:3306) Mon May 16 14:24:16 2016 - [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 server1(10.24.220.232:3306)? (YES/no): YES Mon May 16 14:24:19 2016 - [info] Executing FLUSH NO_WRITE_TO_BINLOG TABLES. This may take long time.. Mon May 16 14:24:19 2016 - [info] ok. Mon May 16 14:24:19 2016 - [info] Checking MHA is not monitoring or doing failover.. Mon May 16 14:24:19 2016 - [info] Checking replication health on slave1.. Mon May 16 14:24:19 2016 - [info] ok. Mon May 16 14:24:19 2016 - [info] Checking replication health on slave2.. Mon May 16 14:24:19 2016 - [info] ok. Mon May 16 14:24:19 2016 - [info] slave1 can be new master. Mon May 16 14:24:19 2016 - [info] From: server1(10.24.220.232:3306) (current master) +--slave1(10.24.220.70:3306) +--slave2(10.169.214.33:3306) To: slave1(10.24.220.70:3306) (new master) +--slave2(10.169.214.33:3306) +--server1(10.24.220.232:3306) Starting master switch from server1(10.24.220.232:3306) to slave1(10.24.220.70:3306)? (yes/NO): YES Mon May 16 14:24:24 2016 - [info] Checking whether slave1(10.24.220.70:3306) is ok for the new master.. Mon May 16 14:24:24 2016 - [info] ok. Mon May 16 14:24:24 2016 - [info] server1(10.24.220.232:3306): SHOW SLAVE STATUS returned empty result. To check replication filtering rules, temporarily executing CHANGE MASTER to a dummy host. Mon May 16 14:24:24 2016 - [info] server1(10.24.220.232:3306): Resetting slave pointing to the dummy host. Mon May 16 14:24:24 2016 - [info] ** Phase 1: Configuration Check Phase completed. Mon May 16 14:24:24 2016 - [info] Mon May 16 14:24:24 2016 - [debug] Disconnected from server1(10.24.220.232:3306) Mon May 16 14:24:24 2016 - [info] * Phase 2: Rejecting updates Phase.. Mon May 16 14:24:24 2016 - [info] master_ip_online_change_script is not defined. If you do not disable writes on the current master manually, applications keep writing on the current master. Is it ok to proceed? (yes/NO): YES Mon May 16 14:24:26 2016 - [info] Locking all tables on the orig master to reject updates from everybody (including root): Mon May 16 14:24:26 2016 - [info] Executing FLUSH TABLES WITH READ LOCK.. Mon May 16 14:24:26 2016 - [info] ok. Mon May 16 14:24:26 2016 - [info] Orig master binlog:pos is log.000003:194. Mon May 16 14:24:26 2016 - [debug] Fetching current slave status.. Mon May 16 14:24:26 2016 - [debug] Fetching current slave status done. Mon May 16 14:24:26 2016 - [info] Waiting to execute all relay logs on slave1(10.24.220.70:3306).. Mon May 16 14:24:26 2016 - [info] master_pos_wait(log.000003:194) completed on slave1(10.24.220.70:3306). Executed 0 events. Mon May 16 14:24:26 2016 - [info] done. Mon May 16 14:24:26 2016 - [debug] Stopping SQL thread on slave1(10.24.220.70:3306).. Mon May 16 14:24:26 2016 - [debug] done. Mon May 16 14:24:26 2016 - [info] Getting new master's binlog name and position.. Mon May 16 14:24:26 2016 - [info] log.000003:194 Mon May 16 14:24:26 2016 - [info] All other slaves should start replication from here. Statement should be: CHANGE MASTER TO MASTER_HOST='slave1 or 10.24.220.70', MASTER_PORT=3306, MASTER_AUTO_POSITION=1, MASTER_USER='repl', MASTER_PASSWORD='xxx'; Mon May 16 14:24:26 2016 - [info] Setting read_only=0 on slave1(10.24.220.70:3306).. Mon May 16 14:24:26 2016 - [info] ok. Mon May 16 14:24:26 2016 - [info] Mon May 16 14:24:26 2016 - [info] * Switching slaves in parallel.. Mon May 16 14:24:26 2016 - [info] Mon May 16 14:24:26 2016 - [info] -- Slave switch on host slave2(10.169.214.33:3306) started, pid: 8031 Mon May 16 14:24:26 2016 - [info] Mon May 16 14:24:27 2016 - [info] Log messages from slave2 ... Mon May 16 14:24:27 2016 - [info] Mon May 16 14:24:26 2016 - [info] Waiting to execute all relay logs on slave2(10.169.214.33:3306).. Mon May 16 14:24:26 2016 - [info] master_pos_wait(log.000003:194) completed on slave2(10.169.214.33:3306). Executed 0 events. Mon May 16 14:24:26 2016 - [info] done. Mon May 16 14:24:26 2016 - [debug] Stopping SQL thread on slave2(10.169.214.33:3306).. Mon May 16 14:24:26 2016 - [debug] done. Mon May 16 14:24:26 2016 - [info] Resetting slave slave2(10.169.214.33:3306) and starting replication from the new master slave1(10.24.220.70:3306).. Mon May 16 14:24:26 2016 - [debug] Stopping slave IO/SQL thread on slave2(10.169.214.33:3306).. Mon May 16 14:24:26 2016 - [debug] done. Mon May 16 14:24:26 2016 - [info] Executed CHANGE MASTER. Mon May 16 14:24:26 2016 - [debug] Starting slave IO/SQL thread on slave2(10.169.214.33:3306).. Mon May 16 14:24:27 2016 - [debug] done. Mon May 16 14:24:27 2016 - [info] Slave started. Mon May 16 14:24:27 2016 - [info] End of log messages from slave2 ... Mon May 16 14:24:27 2016 - [info] Mon May 16 14:24:27 2016 - [info] -- Slave switch on host slave2(10.169.214.33:3306) succeeded. Mon May 16 14:24:27 2016 - [info] Unlocking all tables on the orig master: Mon May 16 14:24:27 2016 - [info] Executing UNLOCK TABLES.. Mon May 16 14:24:27 2016 - [info] ok. Mon May 16 14:24:27 2016 - [info] Starting orig master as a new slave.. Mon May 16 14:24:27 2016 - [info] Resetting slave server1(10.24.220.232:3306) and starting replication from the new master slave1(10.24.220.70:3306).. Mon May 16 14:24:27 2016 - [info] Executed CHANGE MASTER. Mon May 16 14:24:27 2016 - [debug] Starting slave IO/SQL thread on server1(10.24.220.232:3306).. Mon May 16 14:24:28 2016 - [debug] done. Mon May 16 14:24:28 2016 - [info] Slave started. Mon May 16 14:24:28 2016 - [debug] ok. Mon May 16 14:24:28 2016 - [info] All new slave servers switched successfully. Mon May 16 14:24:28 2016 - [info] Mon May 16 14:24:28 2016 - [info] * Phase 5: New master cleanup phase.. Mon May 16 14:24:28 2016 - [info] Mon May 16 14:24:28 2016 - [debug] Clearing slave info.. Mon May 16 14:24:28 2016 - [debug] Stopping slave IO/SQL thread on slave1(10.24.220.70:3306).. Mon May 16 14:24:28 2016 - [debug] done. Mon May 16 14:24:28 2016 - [debug] SHOW SLAVE STATUS shows new master does not replicate from anywhere. OK. Mon May 16 14:24:28 2016 - [info] slave1: Resetting slave info succeeded. Mon May 16 14:24:28 2016 - [info] Switching master to slave1(10.24.220.70:3306) completed successfully. Mon May 16 14:24:28 2016 - [debug] Disconnected from server1(10.24.220.232:3306) Mon May 16 14:24:28 2016 - [debug] Disconnected from slave1(10.24.220.70:3306) Mon May 16 14:24:28 2016 - [debug] Disconnected from slave2(10.169.214.33:3306) [root@monitor app1]#
  • 相关阅读:
    Linux 基本操作 (day2)
    Linux 简介(day1)
    python 反射、md5加密
    Python 简易版选课系统
    python 类与类之间的关系
    python 基本运算符
    python 基础操作--数据类型
    python初识
    生成器和生成器表达式
    SpringMvc测试框架详解----服务端测试
  • 原文地址:https://www.cnblogs.com/zengkefu/p/5497995.html
Copyright © 2020-2023  润新知