• MHA手动在线切换主 原创3(主不参与复制)




    monitor
    执行:slave2连接到slave1,server1 不做(主/从复制角色,停在那里)

    [root@monitor app1]# masterha_master_switch --conf=/etc/masterha/app1.conf --master_state=alive --new_master_host=slave1 Mon May 16 14:08:17 2016 - [info] MHA::MasterRotate version 0.56. Mon May 16 14:08:17 2016 - [info] Starting online master switch.. Mon May 16 14:08:17 2016 - [info] Mon May 16 14:08:17 2016 - [info] * Phase 1: Configuration Check Phase.. Mon May 16 14:08:17 2016 - [info] Mon May 16 14:08:17 2016 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping. Mon May 16 14:08:17 2016 - [info] Reading application default configuration from /etc/masterha/app1.conf.. Mon May 16 14:08:17 2016 - [info] Reading server configuration from /etc/masterha/app1.conf.. Mon May 16 14:08:17 2016 - [debug] Connecting to servers.. Mon May 16 14:08:17 2016 - [debug] Connected to: server1(10.24.220.232:3306), user=root Mon May 16 14:08:17 2016 - [debug] Number of slave worker threads on host server1(10.24.220.232:3306): 0 Mon May 16 14:08:17 2016 - [debug] Connected to: slave1(10.24.220.70:3306), user=root Mon May 16 14:08:17 2016 - [debug] Number of slave worker threads on host slave1(10.24.220.70:3306): 0 Mon May 16 14:08:17 2016 - [debug] Connected to: slave2(10.169.214.33:3306), user=root Mon May 16 14:08:17 2016 - [debug] Number of slave worker threads on host slave2(10.169.214.33:3306): 0 Mon May 16 14:08:17 2016 - [debug] Comparing MySQL versions.. Mon May 16 14:08:17 2016 - [debug] Comparing MySQL versions done. Mon May 16 14:08:17 2016 - [debug] Connecting to servers done. Mon May 16 14:08:17 2016 - [info] GTID failover mode = 1 Mon May 16 14:08:17 2016 - [info] Current Alive Master: server1(10.24.220.232:3306) Mon May 16 14:08:17 2016 - [info] Alive Slaves: Mon May 16 14:08:17 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:08:17 2016 - [info] GTID ON Mon May 16 14:08:17 2016 - [debug] Relay log info repository: FILE Mon May 16 14:08:17 2016 - [info] Replicating from 10.24.220.232(10.24.220.232:3306) Mon May 16 14:08:17 2016 - [info] Primary candidate for the new Master (candidate_master is set) Mon May 16 14:08:17 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:08:17 2016 - [info] GTID ON Mon May 16 14:08:17 2016 - [debug] Relay log info repository: FILE Mon May 16 14:08:17 2016 - [info] Replicating from 10.24.220.232(10.24.220.232:3306) Mon May 16 14:08:17 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:08:22 2016 - [info] Executing FLUSH NO_WRITE_TO_BINLOG TABLES. This may take long time.. Mon May 16 14:08:22 2016 - [info] ok. Mon May 16 14:08:22 2016 - [info] Checking MHA is not monitoring or doing failover.. Mon May 16 14:08:22 2016 - [info] Checking replication health on slave1.. Mon May 16 14:08:22 2016 - [info] ok. Mon May 16 14:08:22 2016 - [info] Checking replication health on slave2.. Mon May 16 14:08:22 2016 - [info] ok. Mon May 16 14:08:22 2016 - [info] slave1 can be new master. Mon May 16 14:08:22 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) Starting master switch from server1(10.24.220.232:3306) to slave1(10.24.220.70:3306)? (yes/NO): yes Mon May 16 14:08:34 2016 - [info] Checking whether slave1(10.24.220.70:3306) is ok for the new master.. Mon May 16 14:08:34 2016 - [info] ok. Mon May 16 14:08:34 2016 - [info] ** Phase 1: Configuration Check Phase completed. Mon May 16 14:08:34 2016 - [info] Mon May 16 14:08:34 2016 - [debug] Disconnected from server1(10.24.220.232:3306) Mon May 16 14:08:34 2016 - [info] * Phase 2: Rejecting updates Phase.. Mon May 16 14:08:34 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:08:38 2016 - [info] Locking all tables on the orig master to reject updates from everybody (including root): Mon May 16 14:08:38 2016 - [info] Executing FLUSH TABLES WITH READ LOCK.. Mon May 16 14:08:38 2016 - [info] ok. Mon May 16 14:08:38 2016 - [info] Orig master binlog:pos is log.000002:320. Mon May 16 14:08:38 2016 - [debug] Fetching current slave status.. Mon May 16 14:08:38 2016 - [debug] Fetching current slave status done. Mon May 16 14:08:38 2016 - [info] Waiting to execute all relay logs on slave1(10.24.220.70:3306).. Mon May 16 14:08:38 2016 - [info] master_pos_wait(log.000002:320) completed on slave1(10.24.220.70:3306). Executed 0 events. Mon May 16 14:08:38 2016 - [info] done. Mon May 16 14:08:38 2016 - [debug] Stopping SQL thread on slave1(10.24.220.70:3306).. Mon May 16 14:08:38 2016 - [debug] done. Mon May 16 14:08:38 2016 - [info] Getting new master's binlog name and position.. Mon May 16 14:08:38 2016 - [info] log.000002:320 Mon May 16 14:08:38 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:08:38 2016 - [info] Setting read_only=0 on slave1(10.24.220.70:3306).. Mon May 16 14:08:38 2016 - [info] ok. Mon May 16 14:08:38 2016 - [info] Mon May 16 14:08:38 2016 - [info] * Switching slaves in parallel.. Mon May 16 14:08:38 2016 - [info] Mon May 16 14:08:38 2016 - [info] -- Slave switch on host slave2(10.169.214.33:3306) started, pid: 8020 Mon May 16 14:08:38 2016 - [info] Mon May 16 14:08:39 2016 - [info] Log messages from slave2 ... Mon May 16 14:08:39 2016 - [info] Mon May 16 14:08:38 2016 - [info] Waiting to execute all relay logs on slave2(10.169.214.33:3306).. Mon May 16 14:08:38 2016 - [info] master_pos_wait(log.000002:320) completed on slave2(10.169.214.33:3306). Executed 0 events. Mon May 16 14:08:38 2016 - [info] done. Mon May 16 14:08:38 2016 - [debug] Stopping SQL thread on slave2(10.169.214.33:3306).. Mon May 16 14:08:38 2016 - [debug] done. Mon May 16 14:08:38 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:08:38 2016 - [debug] Stopping slave IO/SQL thread on slave2(10.169.214.33:3306).. Mon May 16 14:08:38 2016 - [debug] done. Mon May 16 14:08:38 2016 - [info] Executed CHANGE MASTER. Mon May 16 14:08:38 2016 - [debug] Starting slave IO/SQL thread on slave2(10.169.214.33:3306).. Mon May 16 14:08:39 2016 - [debug] done. Mon May 16 14:08:39 2016 - [info] Slave started. Mon May 16 14:08:39 2016 - [info] End of log messages from slave2 ... Mon May 16 14:08:39 2016 - [info] Mon May 16 14:08:39 2016 - [info] -- Slave switch on host slave2(10.169.214.33:3306) succeeded. Mon May 16 14:08:39 2016 - [info] Unlocking all tables on the orig master: Mon May 16 14:08:39 2016 - [info] Executing UNLOCK TABLES.. Mon May 16 14:08:39 2016 - [info] ok. Mon May 16 14:08:39 2016 - [info] All new slave servers switched successfully. Mon May 16 14:08:39 2016 - [info] Mon May 16 14:08:39 2016 - [info] * Phase 5: New master cleanup phase.. Mon May 16 14:08:39 2016 - [info] Mon May 16 14:08:39 2016 - [debug] Clearing slave info.. Mon May 16 14:08:39 2016 - [debug] Stopping slave IO/SQL thread on slave1(10.24.220.70:3306).. Mon May 16 14:08:39 2016 - [debug] done. Mon May 16 14:08:39 2016 - [debug] SHOW SLAVE STATUS shows new master does not replicate from anywhere. OK. Mon May 16 14:08:39 2016 - [info] slave1: Resetting slave info succeeded. Mon May 16 14:08:39 2016 - [info] Switching master to slave1(10.24.220.70:3306) completed successfully. Mon May 16 14:08:39 2016 - [debug] Disconnected from server1(10.24.220.232:3306) Mon May 16 14:08:39 2016 - [debug] Disconnected from slave1(10.24.220.70:3306) Mon May 16 14:08:39 2016 - [debug] Disconnected from slave2(10.169.214.33:3306) [root@monitor app1]#




    slave1 :上执行

    mysql> show variables like "read_only";
    +---------------+-------+
    | Variable_name | Value |
    +---------------+-------+
    | read_only | OFF |
    +---------------+-------+
    1 row in set (0.00 sec)

    注意已经由只读变为可写!!!!!!!!!

    server1 没有变化,还是 read_only=OFF

    在反复切换实验时注意读写状态

     
  • 相关阅读:
    在ASP.NET Core中怎么使用HttpContext.Current (转载)
    如何在.Net Core 2.0 App中读取appsettings.json
    ASP.NET CORE MVC 2.0 如何在Filter中使用依赖注入来读取AppSettings,及.NET Core控制台项目中读取AppSettings
    linux中shell变量$#,$@,$0,$1,$2的含义解释<转>
    ijkplayer阅读学习笔记之从代码上看播放流程
    ubuntu命令整理中
    Android SDK Android NDK Android Studio 官方下载地址<转>
    Ubuntu启动 卡在checking battery state 解决方案
    解决 ffmpeg 在avformat_find_stream_info执行时间太长
    ijkplayer阅读笔记系列<转>
  • 原文地址:https://www.cnblogs.com/zengkefu/p/5497947.html
Copyright © 2020-2023  润新知