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 :: - [info] MHA::MasterRotate version 0.56.
Mon May :: - [info] Starting online master switch..
Mon May :: - [info]
Mon May :: - [info] * Phase : Configuration Check Phase..
Mon May :: - [info]
Mon May :: - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
Mon May :: - [info] Reading application default configuration from /etc/masterha/app1.conf..
Mon May :: - [info] Reading server configuration from /etc/masterha/app1.conf..
Mon May :: - [debug] Connecting to servers..
Mon May :: - [debug] Connected to: server1(10.24.220.232:), user=root
Mon May :: - [debug] Number of slave worker threads on host server1(10.24.220.232:):
Mon May :: - [debug] Connected to: slave1(10.24.220.70:), user=root
Mon May :: - [debug] Number of slave worker threads on host slave1(10.24.220.70:):
Mon May :: - [debug] Connected to: slave2(10.169.214.33:), user=root
Mon May :: - [debug] Number of slave worker threads on host slave2(10.169.214.33:):
Mon May :: - [debug] Comparing MySQL versions..
Mon May :: - [debug] Comparing MySQL versions done.
Mon May :: - [debug] Connecting to servers done.
Mon May :: - [info] GTID failover mode =
Mon May :: - [info] Current Alive Master: server1(10.24.220.232:)
Mon May :: - [info] Alive Slaves:
Mon May :: - [info] slave1(10.24.220.70:) Version=5.7.-log (oldest major version between slaves) log-bin:enabled
Mon May :: - [info] GTID ON
Mon May :: - [debug] Relay log info repository: FILE
Mon May :: - [info] Replicating from 10.24.220.232(10.24.220.232:)
Mon May :: - [info] Primary candidate for the new Master (candidate_master is set)
Mon May :: - [info] slave2(10.169.214.33:) Version=5.7.-log (oldest major version between slaves) log-bin:enabled
Mon May :: - [info] GTID ON
Mon May :: - [debug] Relay log info repository: FILE
Mon May :: - [info] Replicating from 10.24.220.232(10.24.220.232:)
Mon May :: - [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:)? (YES/no): YES
Mon May :: - [info] Executing FLUSH NO_WRITE_TO_BINLOG TABLES. This may take long time..
Mon May :: - [info] ok.
Mon May :: - [info] Checking MHA is not monitoring or doing failover..
Mon May :: - [info] Checking replication health on slave1..
Mon May :: - [info] ok.
Mon May :: - [info] Checking replication health on slave2..
Mon May :: - [info] ok.
Mon May :: - [info] slave1 can be new master.
Mon May :: - [info]
From:
server1(10.24.220.232:) (current master)
+--slave1(10.24.220.70:)
+--slave2(10.169.214.33:)
To:
slave1(10.24.220.70:) (new master)
+--slave2(10.169.214.33:)
+--server1(10.24.220.232:)
Starting master switch from server1(10.24.220.232:) to slave1(10.24.220.70:)? (yes/NO): YES
Mon May :: - [info] Checking whether slave1(10.24.220.70:) is ok for the new master..
Mon May :: - [info] ok.
Mon May :: - [info] server1(10.24.220.232:): SHOW SLAVE STATUS returned empty result. To check replication filtering rules, temporarily executing CHANGE MASTER to a dummy host.
Mon May :: - [info] server1(10.24.220.232:): Resetting slave pointing to the dummy host.
Mon May :: - [info] ** Phase : Configuration Check Phase completed.
Mon May :: - [info]
Mon May :: - [debug] Disconnected from server1(10.24.220.232:)
Mon May :: - [info] * Phase : Rejecting updates Phase..
Mon May :: - [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 :: - [info] Locking all tables on the orig master to reject updates from everybody (including root):
Mon May :: - [info] Executing FLUSH TABLES WITH READ LOCK..
Mon May :: - [info] ok.
Mon May :: - [info] Orig master binlog:pos is log.:.
Mon May :: - [debug] Fetching current slave status..
Mon May :: - [debug] Fetching current slave status done.
Mon May :: - [info] Waiting to execute all relay logs on slave1(10.24.220.70:)..
Mon May :: - [info] master_pos_wait(log.:) completed on slave1(10.24.220.70:). Executed events.
Mon May :: - [info] done.
Mon May :: - [debug] Stopping SQL thread on slave1(10.24.220.70:)..
Mon May :: - [debug] done.
Mon May :: - [info] Getting new master's binlog name and position..
Mon May :: - [info] log.:
Mon May :: - [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=, MASTER_AUTO_POSITION=, MASTER_USER='repl', MASTER_PASSWORD='xxx';
Mon May :: - [info] Setting read_only= on slave1(10.24.220.70:)..
Mon May :: - [info] ok.
Mon May :: - [info]
Mon May :: - [info] * Switching slaves in parallel..
Mon May :: - [info]
Mon May :: - [info] -- Slave switch on host slave2(10.169.214.33:) started, pid:
Mon May :: - [info]
Mon May :: - [info] Log messages from slave2 ...
Mon May :: - [info]
Mon May :: - [info] Waiting to execute all relay logs on slave2(10.169.214.33:)..
Mon May :: - [info] master_pos_wait(log.:) completed on slave2(10.169.214.33:). Executed events.
Mon May :: - [info] done.
Mon May :: - [debug] Stopping SQL thread on slave2(10.169.214.33:)..
Mon May :: - [debug] done.
Mon May :: - [info] Resetting slave slave2(10.169.214.33:) and starting replication from the new master slave1(10.24.220.70:)..
Mon May :: - [debug] Stopping slave IO/SQL thread on slave2(10.169.214.33:)..
Mon May :: - [debug] done.
Mon May :: - [info] Executed CHANGE MASTER.
Mon May :: - [debug] Starting slave IO/SQL thread on slave2(10.169.214.33:)..
Mon May :: - [debug] done.
Mon May :: - [info] Slave started.
Mon May :: - [info] End of log messages from slave2 ...
Mon May :: - [info]
Mon May :: - [info] -- Slave switch on host slave2(10.169.214.33:) succeeded.
Mon May :: - [info] Unlocking all tables on the orig master:
Mon May :: - [info] Executing UNLOCK TABLES..
Mon May :: - [info] ok.
Mon May :: - [info] Starting orig master as a new slave..
Mon May :: - [info] Resetting slave server1(10.24.220.232:) and starting replication from the new master slave1(10.24.220.70:)..
Mon May :: - [info] Executed CHANGE MASTER.
Mon May :: - [debug] Starting slave IO/SQL thread on server1(10.24.220.232:)..
Mon May :: - [debug] done.
Mon May :: - [info] Slave started.
Mon May :: - [debug] ok.
Mon May :: - [info] All new slave servers switched successfully.
Mon May :: - [info]
Mon May :: - [info] * Phase : New master cleanup phase..
Mon May :: - [info]
Mon May :: - [debug] Clearing slave info..
Mon May :: - [debug] Stopping slave IO/SQL thread on slave1(10.24.220.70:)..
Mon May :: - [debug] done.
Mon May :: - [debug] SHOW SLAVE STATUS shows new master does not replicate from anywhere. OK.
Mon May :: - [info] slave1: Resetting slave info succeeded.
Mon May :: - [info] Switching master to slave1(10.24.220.70:) completed successfully.
Mon May :: - [debug] Disconnected from server1(10.24.220.232:)
Mon May :: - [debug] Disconnected from slave1(10.24.220.70:)
Mon May :: - [debug] Disconnected from slave2(10.169.214.33:)
[root@monitor app1]#