[root@mysql3 soft]# masterha_master_switch --master_state=alive --conf=/etc/masterha_default.cnf
Mon Jun10 06:33:03 2019 - [info] MHA::MasterRotate version 0.58.
Mon Jun10 06:33:03 2019 - [info] Starting online master switch..
Mon Jun10 06:33:03 2019 - [info]
Mon Jun10 06:33:03 2019 - [info] * Phase 1: Configuration Check Phase..
Mon Jun10 06:33:03 2019 - [info]
Mon Jun10 06:33:03 2019 - [info] Reading default configuration from /etc/masterha_default.cnf..
Mon Jun10 06:33:03 2019 - [info] Reading application default configuration from /etc/masterha_default.cnf..
Mon Jun10 06:33:03 2019 - [info] Reading server configuration from /etc/masterha_default.cnf..
Mon Jun10 06:33:03 2019 - [info] GTID failover mode = 1Mon Jun10 06:33:03 2019 - [info] Current Alive Master: mysql1(192.168.20.81:3306)
Mon Jun10 06:33:03 2019 - [info] Alive Slaves:
Mon Jun10 06:33:03 2019 - [info] mysql2(192.168.20.82:3306) Version=8.0.16 (oldest major version between slaves) log-bin:enabled
Mon Jun10 06:33:03 2019 - [info] GTID ON
Mon Jun10 06:33:03 2019 - [info] Replicating from 192.168.20.81(192.168.20.81:3306)
Mon Jun10 06:33:03 2019 - [info] Primary candidate forthe new Master (candidate_master is set)
Mon Jun10 06:33:03 2019 - [info] mysql3(192.168.20.83:3306) Version=8.0.16 (oldest major version between slaves) log-bin:enabled
Mon Jun10 06:33:03 2019 - [info] GTID ON
Mon Jun10 06:33:03 2019 - [info] Replicating from 192.168.20.81(192.168.20.81:3306)
Mon Jun10 06:33:03 2019 - [info] Not candidate forthe new Master (no_master is set)
Mon Jun10 06:33:03 2019 - [info] mysql4(192.168.20.84:3306) Version=8.0.16 (oldest major version between slaves) log-bin:enabled
Mon Jun10 06:33:03 2019 - [info] GTID ON
Mon Jun10 06:33:03 2019 - [info] Replicating from 192.168.20.81(192.168.20.81:3306)
Mon Jun10 06:33:03 2019 - [info] Not candidate forthe 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 mysql1(192.168.20.81:3306)? (YES/no): YES
Mon Jun10 06:34:00 2019 - [info] Executing FLUSH NO_WRITE_TO_BINLOG TABLES. This may take long time..
Mon Jun10 06:34:00 2019 - [info] ok.
Mon Jun10 06:34:00 2019 - [info] Checking MHA is not monitoring or doing failover..
Mon Jun10 06:34:00 2019 - [info] Checking replication health on mysql2..
Mon Jun10 06:34:00 2019 - [info] ok.
Mon Jun10 06:34:00 2019 - [info] Checking replication health on mysql3..
Mon Jun10 06:34:00 2019 - [info] ok.
Mon Jun10 06:34:00 2019 - [info] Checking replication health on mysql4..
Mon Jun10 06:34:00 2019 - [info] ok.
Mon Jun10 06:34:00 2019 - [info] Searching new master from slaves..
Mon Jun10 06:34:00 2019 - [info] Candidate masters from the configuration file:
Mon Jun10 06:34:00 2019 - [info] mysql1(192.168.20.81:3306) Version=8.0.16 log-bin:enabled
Mon Jun10 06:34:00 2019 - [info] GTID ON
Mon Jun10 06:34:00 2019 - [info] mysql2(192.168.20.82:3306) Version=8.0.16 (oldest major version between slaves) log-bin:enabled
Mon Jun10 06:34:00 2019 - [info] GTID ON
Mon Jun10 06:34:00 2019 - [info] Replicating from 192.168.20.81(192.168.20.81:3306)
Mon Jun10 06:34:00 2019 - [info] Primary candidate forthe new Master (candidate_master is set)
Mon Jun10 06:34:00 2019 - [info] Non-candidate masters:
Mon Jun10 06:34:00 2019 - [info] mysql3(192.168.20.83:3306) Version=8.0.16 (oldest major version between slaves) log-bin:enabled
Mon Jun10 06:34:00 2019 - [info] GTID ON
Mon Jun10 06:34:00 2019 - [info] Replicating from 192.168.20.81(192.168.20.81:3306)
Mon Jun10 06:34:00 2019 - [info] Not candidate forthe new Master (no_master is set)
Mon Jun10 06:34:00 2019 - [info] mysql4(192.168.20.84:3306) Version=8.0.16 (oldest major version between slaves) log-bin:enabled
Mon Jun10 06:34:00 2019 - [info] GTID ON
Mon Jun10 06:34:00 2019 - [info] Replicating from 192.168.20.81(192.168.20.81:3306)
Mon Jun10 06:34:00 2019 - [info] Not candidate forthe new Master (no_master is set)
Mon Jun10 06:34:00 2019 - [info] Searching from candidate_master slaves whichhave received the latest relay log events..
Mon Jun10 06:34:00 2019 - [info]
From:
mysql1(192.168.20.81:3306) (current master)+--mysql2(192.168.20.82:3306)+--mysql3(192.168.20.83:3306)+--mysql4(192.168.20.84:3306)
To:
mysql2(192.168.20.82:3306) (new master)+--mysql3(192.168.20.83:3306)+--mysql4(192.168.20.84:3306)
Starting master switch from mysql1(192.168.20.81:3306) to mysql2(192.168.20.82:3306)? (yes/NO): yes
Mon Jun10 06:35:02 2019 - [info] Checking whether mysql2(192.168.20.82:3306) is ok forthe new master..
Mon Jun10 06:35:02 2019 - [info] ok.
Mon Jun10 06:35:02 2019 - [info] ** Phase 1: Configuration Check Phase completed.
Mon Jun10 06:35:02 2019 - [info]
Mon Jun10 06:35:02 2019 - [info] * Phase 2: Rejecting updates Phase..
Mon Jun10 06:35:02 2019 - [info]
FLUSH NO_WRITE_TO_BINLOG TABLES is not defined. If youdo not disable writes on the current master manually, applications keep writing on the current master. Is it ok to proceed? (yes/NO): yes
Mon Jun10 06:35:53 2019 - [info] Locking all tables on the orig master to reject updates from everybody (including root):
Mon Jun10 06:35:53 2019 - [info] Executing FLUSH TABLES WITH READ LOCK..
Mon Jun10 06:35:53 2019 - [info] ok.
Mon Jun10 06:35:53 2019 - [info] Orig master binlog:pos is binlog.000017:1285.
Mon Jun10 06:35:53 2019 - [info] Waiting to execute all relay logs on mysql2(192.168.20.82:3306)..
Mon Jun10 06:35:53 2019 - [info] master_pos_wait(binlog.000017:1285) completed on mysql2(192.168.20.82:3306). Executed 0events.
Mon Jun10 06:35:53 2019 - [info] done.
Mon Jun10 06:35:54 2019 - [info] Getting new master's binlog name and position..
Mon Jun 10 06:35:54 2019 - [info] binlog.000015:235Mon Jun10 06:35:54 2019 - [info] All other slaves should start replication from here. Statement should be: CHANGE MASTER TO MASTER_HOST='mysql2 or 192.168.20.82', MASTER_PORT=3306, MASTER_AUTO_POSITION=1, MASTER_USER='rep', MASTER_PASSWORD='xxx';
Mon Jun10 06:35:54 2019 - [info] Setting read_only=0 on mysql2(192.168.20.82:3306)..
Mon Jun10 06:35:54 2019 - [info] ok.
Mon Jun10 06:35:54 2019 - [info]
Mon Jun10 06:35:54 2019 - [info] * Switching slaves inparallel..
Mon Jun10 06:35:54 2019 - [info]
Mon Jun10 06:35:54 2019 - [info] -- Slave switch on host mysql3(192.168.20.83:3306) started, pid: 9450Mon Jun10 06:35:54 2019 - [info]
Mon Jun10 06:35:54 2019 - [info] -- Slave switch on host mysql4(192.168.20.84:3306) started, pid: 9451Mon Jun10 06:35:54 2019 - [info]
Mon Jun10 06:35:54 2019 - [info] Log messages from mysql3 ...
Mon Jun10 06:35:54 2019 - [info]
Mon Jun10 06:35:54 2019 - [info] Waiting to execute all relay logs on mysql3(192.168.20.83:3306)..
Mon Jun10 06:35:54 2019 - [info] master_pos_wait(binlog.000017:1285) completed on mysql3(192.168.20.83:3306). Executed 0events.
Mon Jun10 06:35:54 2019 - [info] done.
Mon Jun10 06:35:54 2019 - [info] Resetting slave mysql3(192.168.20.83:3306) and starting replication from the new master mysql2(192.168.20.82:3306)..
Mon Jun10 06:35:54 2019 - [info] Executed CHANGE MASTER.
Mon Jun10 06:35:54 2019 - [info] Slave started.
Mon Jun10 06:35:54 2019 - [info] End of log messages from mysql3 ...
Mon Jun10 06:35:54 2019 - [info]
Mon Jun10 06:35:54 2019 - [info] -- Slave switch on host mysql3(192.168.20.83:3306) succeeded.
Mon Jun10 06:35:54 2019 - [info] Log messages from mysql4 ...
Mon Jun10 06:35:54 2019 - [info]
Mon Jun10 06:35:54 2019 - [info] Waiting to execute all relay logs on mysql4(192.168.20.84:3306)..
Mon Jun10 06:35:54 2019 - [info] master_pos_wait(binlog.000017:1285) completed on mysql4(192.168.20.84:3306). Executed 0events.
Mon Jun10 06:35:54 2019 - [info] done.
Mon Jun10 06:35:54 2019 - [info] Resetting slave mysql4(192.168.20.84:3306) and starting replication from the new master mysql2(192.168.20.82:3306)..
Mon Jun10 06:35:54 2019 - [info] Executed CHANGE MASTER.
Mon Jun10 06:35:54 2019 - [info] Slave started.
Mon Jun10 06:35:54 2019 - [info] End of log messages from mysql4 ...
Mon Jun10 06:35:54 2019 - [info]
Mon Jun10 06:35:54 2019 - [info] -- Slave switch on host mysql4(192.168.20.84:3306) succeeded.
Mon Jun10 06:35:54 2019 - [info] Unlocking all tables on the orig master:
Mon Jun10 06:35:54 2019 - [info] Executing UNLOCK TABLES..
Mon Jun10 06:35:54 2019 - [info] ok.
Mon Jun10 06:35:54 2019 - [info] All new slave servers switched successfully.
Mon Jun10 06:35:54 2019 - [info]
Mon Jun10 06:35:54 2019 - [info] * Phase 5: New master cleanup phase..
Mon Jun10 06:35:54 2019 - [info]
Mon Jun10 06:35:54 2019 - [info] mysql2: Resetting slave infosucceeded.
Mon Jun10 06:35:54 2019 - [info] Switching master to mysql2(192.168.20.82:3306) completed successfully.