/usr/local/mha-manager/logs/test.log
Thu Apr 7 16:57:30 2016 - [info] * Phase 2: Dead Master Shutdown Phase..
Thu Apr 7 16:57:30 2016 - [info]
第二阶段:主库宕机
(这里就开始和alive不同了)
Thu Apr 7 16:57:30 2016 - [info] HealthCheck: SSH to 10.20.64.204 is reachable.
检测新主ssh通信
Thu Apr 7 16:57:31 2016 - [info] Forcing shutdown so that applications never connect to the current master..
强制停掉,应用不再连接当前主库(老主库)
Thu Apr 7 16:57:31 2016 - [warning] master_ip_failover_script is not set. Skipping invalidating dead master IP address.
Thu Apr 7 16:57:31 2016 - [warning] shutdown_script is not set. Skipping explicit shutting down of the dead master.
Thu Apr 7 16:57:31 2016 - [info] * Phase 2: Dead Master Shutdown Phase completed.
Thu Apr 7 16:57:31 2016 - [info]
第二阶段完成:确定老主库已停掉
Thu Apr 7 16:57:31 2016 - [info] * Phase 3: Master Recovery Phase..
Thu Apr 7 16:57:31 2016 - [info]
第三阶段:主库恢复阶段
Thu Apr 7 16:57:31 2016 - [info] * Phase 3.1: Getting Latest Slaves Phase..
Thu Apr 7 16:57:31 2016 - [info]
第三阶段第一步:获取执行到最接近最新的binlog和pos点的从库
Thu Apr 7 16:57:31 2016 - [info] The latest binary log file/position on all slaves is mysql-bin.000004:120
最新的是 mysql-bin.000004:120
Thu Apr 7 16:57:31 2016 - [info] Latest slaves (Slaves that received relay log files to the latest):
并且已接收到relay log中
Thu Apr 7 16:57:31 2016 - [info] 10.20.64.203(10.20.64.203:3306) Version=5.6.27-76.0-log (oldest major version between
slaves) log-bin:enabled
Thu Apr 7 16:57:31 2016 - [info] Replicating from 10.20.64.204(10.20.64.204:3306)
Thu Apr 7 16:57:31 2016 - [info] Primary candidate for the new Master (candidate_master is set)
Thu Apr 7 16:57:31 2016 - [info] 10.20.64.202(10.20.64.202:3306) Version=5.6.27-76.0-log (oldest major version between
slaves) log-bin:enabled
Thu Apr 7 16:57:31 2016 - [info] Replicating from 10.20.64.204(10.20.64.204:3306)
Thu Apr 7 16:57:31 2016 - [info] Primary candidate for the new Master (candidate_master is set)
Thu Apr 7 16:57:31 2016 - [info] 10.20.64.210(10.20.64.210:3306) Version=5.6.27-76.0-log (oldest major version between
slaves) log-bin:enabled
Thu Apr 7 16:57:31 2016 - [info] Replicating from 10.20.64.204(10.20.64.204:3306)
Thu Apr 7 16:57:31 2016 - [info] Not candidate for the new Master (no_master is set)
Thu Apr 7 16:57:31 2016 - [info] The oldest binary log file/position on all slaves is mysql-bin.000004:120
Thu Apr 7 16:57:31 2016 - [info] Oldest slaves:
Thu Apr 7 16:57:31 2016 - [info] 10.20.64.203(10.20.64.203:3306) Version=5.6.27-76.0-log (oldest major version between
slaves) log-bin:enabled
Thu Apr 7 16:57:31 2016 - [info] Replicating from 10.20.64.204(10.20.64.204:3306)
Thu Apr 7 16:57:31 2016 - [info] Primary candidate for the new Master (candidate_master is set)
Thu Apr 7 16:57:31 2016 - [info] 10.20.64.202(10.20.64.202:3306) Version=5.6.27-76.0-log (oldest major version between
slaves) log-bin:enabled
Thu Apr 7 16:57:31 2016 - [info] Replicating from 10.20.64.204(10.20.64.204:3306)
Thu Apr 7 16:57:31 2016 - [info] Primary candidate for the new Master (candidate_master is set)
Thu Apr 7 16:57:31 2016 - [info] 10.20.64.210(10.20.64.210:3306) Version=5.6.27-76.0-log (oldest major version between
slaves) log-bin:enabled
Thu Apr 7 16:57:31 2016 - [info] Replicating from 10.20.64.204(10.20.64.204:3306)
Thu Apr 7 16:57:31 2016 - [info] Not candidate for the new Master (no_master is set)
Thu Apr 7 16:57:31 2016 - [info]
这段常规从库检测
Thu Apr 7 16:57:31 2016 - [info] * Phase 3.2: Saving Dead Master's Binlog Phase..
Thu Apr 7 16:57:31 2016 - [info]
第三阶段第二步:保存老主库binlog阶段
Thu Apr 7 16:57:31 2016 - [info] Fetching dead master's binary logs..
开始获取主库binlog
Thu Apr 7 16:57:31 2016 - [info] Executing command on the dead master 10.20.64.204(10.20.64.204:3306): save_binary_logs -
-command=save --start_file=mysql-bin.000004 --start_pos=120 --binlog_dir=/data/mysqldata/3306/binlog --output_file=/usr/l
ocal/mha-node/apps/test/saved_master_binlog_from_10.20.64.204_3306_20160407165729.binlog --handle_raw_binlog=1 --disable_l
og_bin=0 --manager_version=0.56 --client_bindir=/usr/local/mysql/bin --client_libdir=/usr/local/mysql/lib
老主库本地脚本save_binary_logs读取最新的binlog和pos,将数据保存到node工作目录
Creating /usr/local/mha-node/apps/test if not exists.. ok.
Concat binary/relay logs from mysql-bin.000004 pos 120 to mysql-bin.000004 EOF into /usr/local/mha-node/apps/test/saved_m
aster_binlog_from_10.20.64.204_3306_20160407165729.binlog ..
Binlog Checksum enabled
Dumping binlog format description event, from position 0 to 120.. ok.
合并pos点120点到结尾的数据到save_master_binlog文件
Dumping effective binlog data from /data/mysqldata/3306/binlog/mysql-bin.000004 position 120 to tail(143).. ok.
Binlog Checksum enabled
Concat succeeded.
最终合并了pos点从120到143的数据
Thu Apr 7 16:57:31 2016 - [info] scp from mha@10.20.64.204:/usr/local/mha-node/apps/test/saved_master_binlog_from_10.20.6
4.204_3306_20160407165729.binlog to local:/usr/local/mha-manager/apps/test/saved_master_binlog_from_10.20.64.204_3306_2016
0407165729.binlog succeeded.
将老主库合并后的slave_master_binlog文件通过scp的方式,拿到manager的工作目录
Thu Apr 7 16:57:31 2016 - [info] HealthCheck: SSH to 10.20.64.203 is reachable.
Thu Apr 7 16:57:32 2016 - [info] HealthCheck: SSH to 10.20.64.202 is reachable.
Thu Apr 7 16:57:32 2016 - [info] HealthCheck: SSH to 10.20.64.210 is reachable.
Thu Apr 7 16:57:33 2016 - [info]
检测从库ssh通讯
Thu Apr 7 16:57:33 2016 - [info] * Phase 3.3: Determining New Master Phase..
Thu Apr 7 16:57:33 2016 - [info]
第三阶段第三步:确定新主阶段
Thu Apr 7 16:57:33 2016 - [info] Finding the latest slave that has all relay logs for recovering other slaves..
寻找所有从库节点中,relay log被恢复到最新pos的从库节点
Thu Apr 7 16:57:33 2016 - [info] All slaves received relay logs to the same position. No need to resync each other.
所有的从库全部恢复到同一个pos点。且不需要mha在从节点间做额外的binlog同步操作
Thu Apr 7 16:57:33 2016 - [info] 10.20.64.202 can be new master.
Thu Apr 7 16:57:33 2016 - [info] New master is 10.20.64.202(10.20.64.202:3306)
按照指定,node1为新主
Thu Apr 7 16:57:33 2016 - [info] Starting master failover..
Thu Apr 7 16:57:33 2016 - [info]
下面开始故障转移工作
From:
10.20.64.204(10.20.64.204:3306) (current master) (test master)
+--10.20.64.203(10.20.64.203:3306) (test standby)
+--10.20.64.202(10.20.64.202:3306) (test standby)
+--10.20.64.210(10.20.64.210:3306) (test slave)
阐述当前架构
To:
10.20.64.202(10.20.64.202:3306) (new master) (test standby)
+--10.20.64.203(10.20.64.203:3306) (test standby)
+--10.20.64.210(10.20.64.210:3306) (test slave)
阐述目标架构
Thu Apr 7 16:57:33 2016 - [info]
Thu Apr 7 16:57:33 2016 - [info] * Phase 3.3: New Master Diff Log Generation Phase..
Thu Apr 7 16:57:33 2016 - [info]
第三阶段第三步:新主库生成diff log
Thu Apr 7 16:57:33 2016 - [info] This server has all relay logs. No need to generate diff files from the latest slave.
manager服务器拥有全部的relay log,不需要从最近同步的从库生成diff relay log
(如果这里没有拿到主库的binlog差异,那么需要从最新的slave scp relay log到其他从库,并在其他从库上执行apply_diff_relay_log讲数据补齐)
Thu Apr 7 16:57:33 2016 - [info] Sending binlog..
这时,将save_binary_logs生成的老主库binlog推送到新主库的工作目录下
Thu Apr 7 16:57:33 2016 - [info] scp from local:/usr/local/mha-manager/apps/test/saved_master_binlog_from_10.20.64.204_33
06_20160407165729.binlog to mha@10.20.64.202:/usr/local/mha-node/apps/test/saved_master_binlog_from_10.20.64.204_3306_2016
0407165729.binlog succeeded.
通过scp方式推送到新主的工作目录下
Thu Apr 7 16:57:33 2016 - [info]
Thu Apr 7 16:57:33 2016 - [info] * Phase 3.4: Master Log Apply Phase..
Thu Apr 7 16:57:33 2016 - [info]
第三阶段第四步:主库binlog应用阶段
Thu Apr 7 16:57:33 2016 - [info] *NOTICE: If any error happens from this phase, manual recovery is needed.
提示:如果这个阶段发生报错,那么需要手动去执行apply log操作
Thu Apr 7 16:57:33 2016 - [info] Starting recovery on 10.20.64.202(10.20.64.202:3306)..
在新主库上开始执行save的老主库binlog内容
Thu Apr 7 16:57:33 2016 - [info] Generating diffs succeeded.
生成差异
Thu Apr 7 16:57:33 2016 - [info] Waiting until all relay logs are applied.
Thu Apr 7 16:57:33 2016 - [info] done.
这里需要等待新主库上,所有的relay log都已执行完
Thu Apr 7 16:57:33 2016 - [info] Getting slave status..
在新主库上,获取从库状态,来确定它执行和读取的老主库的binlog和pos点信息
Thu Apr 7 16:57:33 2016 - [info] This slave(10.20.64.202)'s Exec_Master_Log_Pos equals to Read_Master_Log_Pos(mysql-bin.0
00004:120). No need to recover from Exec_Master_Log_Pos.
这里表示执行和读取的位置相同,也就是说,没有延迟
Thu Apr 7 16:57:33 2016 - [info] Connecting to the target slave host 10.20.64.202, running recover script..
连接从库(也就是我们指定的新主库)去执行apply_diff_relay_logs脚本
Thu Apr 7 16:57:33 2016 - [info] Executing command: apply_diff_relay_logs --command=apply --slave_user='mha' --slave_host
=10.20.64.202 --slave_ip=10.20.64.202 --slave_port=3306 --apply_files=/usr/local/mha-node/apps/test/saved_master_binlog_f
rom_10.20.64.204_3306_20160407165729.binlog --workdir=/usr/local/mha-node/apps/test --target_version=5.6.27-76.0-log --tim
estamp=20160407165729 --handle_raw_binlog=1 --disable_log_bin=0 --manager_version=0.56 --client_bindir=/usr/local/mysql/bi
n --client_libdir=/usr/local/mysql/lib --slave_pass=xxx
这些是ssh到node1节点,本地执行apply_diff_relay_logs脚本
将老主库的pos点120-143的binlog内容应用到新主库
Thu Apr 7 16:57:33 2016 - [info]
MySQL client version is 5.6.27. Using --binary-mode.
Applying differential binary/relay log files /usr/local/mha-node/apps/test/saved_master_binlog_from_10.20.64.204_3306_2016
0407165729.binlog on 10.20.64.202:3306. This may take long time...
Applying log files succeeded.
根据binlog内容的不同,这个部分可能会执行很长时间
Thu Apr 7 16:57:33 2016 - [info] All relay logs were successfully applied.
(我这里为静态测试,所以很快执行完了,且无报错)
Thu Apr 7 16:57:33 2016 - [info] Getting new master's binlog name and position..
Thu Apr 7 16:57:33 2016 - [info] mysql-bin.000001:120
获取新主库的binlog和pos点信息(用来为后面自动重构主从做准备)
Thu Apr 7 16:57:33 2016 - [info] All other slaves should start replication from here. Statement should be: CHANGE MASTER
TO MASTER_HOST='10.20.64.202', MASTER_PORT=3306, MASTER_LOG_FILE='mysql-bin.000001', MASTER_LOG_POS=120, MASTER_USER='rep
l', MASTER_PASSWORD='xxx'
所有的从库重新change master到新主
Thu Apr 7 16:57:33 2016 - [warning] master_ip_failover_script is not set. Skipping taking over new master IP address.
(我们没有配置master_ip_failover_script脚本,这里也跳过了接管新主ip地址的操作)
Thu Apr 7 16:57:33 2016 - [info] ** Finished master recovery successfully.
成功完成新主库恢复操作(主要是将老主库应用到新主库,保证数据最新)
Thu Apr 7 16:57:33 2016 - [info] * Phase 3: Master Recovery Phase completed.
Thu Apr 7 16:57:33 2016 - [info]
到此新主库接管完毕
Thu Apr 7 16:57:33 2016 - [info] * Phase 4: Slaves Recovery Phase..
Thu Apr 7 16:57:33 2016 - [info]
第四阶段:从库恢复阶段
Thu Apr 7 16:57:33 2016 - [info] * Phase 4.1: Starting Parallel Slave Diff Log Generation Phase..
Thu Apr 7 16:57:33 2016 - [info]
第四阶段第一步:从库并行生成diff log
Thu Apr 7 16:57:33 2016 - [info] -- Slave diff file generation on host 10.20.64.203(10.20.64.203:3306) started, pid: 3026
在node2上生成diff log
2. Check tmp log /usr/local/mha-manager/apps/test/10.20.64.203_3306_20160407165729.log if it takes time..
3. Thu Apr 7 16:57:33 2016 - [info] -- Slave diff file generation on host 10.20.64.210(10.20.64.210:3306) started, pid: 3026
在node4上生成diff log
3. Check tmp log /usr/local/mha-manager/apps/test/10.20.64.210_3306_20160407165729.log if it takes time..
Thu Apr 7 16:57:34 2016 - [info]
从库本地生成diff log完成
Thu Apr 7 16:57:34 2016 - [info] Log messages from 10.20.64.210 ...
Thu Apr 7 16:57:34 2016 - [info]
Thu Apr 7 16:57:33 2016 - [info] This server has all relay logs. No need to generate diff files from the latest slave.
Thu Apr 7 16:57:34 2016 - [info] End of log messages from 10.20.64.210.
Thu Apr 7 16:57:34 2016 - [info] -- 10.20.64.210(10.20.64.210:3306) has the latest relay log events.
Thu Apr 7 16:57:34 2016 - [info]
node4节点返回的日志信息,relay log为最新的
Thu Apr 7 16:57:34 2016 - [info] Log messages from 10.20.64.203 ...
Thu Apr 7 16:57:34 2016 - [info]
Thu Apr 7 16:57:33 2016 - [info] This server has all relay logs. No need to generate diff files from the latest slave.
Thu Apr 7 16:57:34 2016 - [info] End of log messages from 10.20.64.203.
Thu Apr 7 16:57:34 2016 - [info] -- 10.20.64.203(10.20.64.203:3306) has the latest relay log events.
node2节点返回的日志信息,relay log为最新的
Thu Apr 7 16:57:34 2016 - [info] Generating relay diff files from the latest slave succeeded.
Thu Apr 7 16:57:34 2016 - [info]
从最新的从库生成diff log完成
Thu Apr 7 16:57:34 2016 - [info] * Phase 4.2: Starting Parallel Slave Log Apply Phase..
Thu Apr 7 16:57:34 2016 - [info]
第四阶段第二步:从库并行应用从库日志
Thu Apr 7 16:57:34 2016 - [info] -- Slave recovery on host 10.20.64.203(10.20.64.203:3306) started, pid: 30266. Check tmp
log /usr/local/mha-manager/apps/test/10.20.64.203_3306_20160407165729.log if it takes time..
Thu Apr 7 16:57:34 2016 - [info] -- Slave recovery on host 10.20.64.210(10.20.64.210:3306) started, pid: 30267. Check tmp
log /usr/local/mha-manager/apps/test/10.20.64.210_3306_20160407165729.log if it takes time..
Thu Apr 7 16:57:35 2016 - [info]
分别在2个节点进行恢复操作
Thu Apr 7 16:57:35 2016 - [info] Log messages from 10.20.64.203 ...
Thu Apr 7 16:57:35 2016 - [info]
Thu Apr 7 16:57:34 2016 - [info] Sending binlog..
Thu Apr 7 16:57:34 2016 - [info] scp from local:/usr/local/mha-manager/apps/test/saved_master_binlog_from_10.20.64.204_33
06_20160407165729.binlog to mha@10.20.64.203:/usr/local/mha-node/apps/test/saved_master_binlog_from_10.20.64.204_3306_2016
0407165729.binlog succeeded.
将老主库最后的binlog拷贝到node2节点
Thu Apr 7 16:57:34 2016 - [info] Starting recovery on 10.20.64.203(10.20.64.203:3306)..
Thu Apr 7 16:57:34 2016 - [info] Generating diffs succeeded.
Thu Apr 7 16:57:34 2016 - [info] Waiting until all relay logs are applied.
Thu Apr 7 16:57:34 2016 - [info] done.
在node2节点完成老主库binlog的恢复操作,如果内容比较多,恢复时间会比较长
Thu Apr 7 16:57:34 2016 - [info] Getting slave status..
Thu Apr 7 16:57:34 2016 - [info] This slave(10.20.64.203)'s Exec_Master_Log_Pos equals to Read_Master_Log_Pos(mysql-bin.0
00004:120). No need to recover from Exec_Master_Log_Pos.
获取从库同步信息,查看执行和读取的老主库binlog和pos点信息
Thu Apr 7 16:57:34 2016 - [info] Connecting to the target slave host 10.20.64.203, running recover script..
ssh连接到node2节点,并执行apply_diff_relay_logs脚本
Thu Apr 7 16:57:34 2016 - [info] Executing command: apply_diff_relay_logs --command=apply --slave_user='mha' --slave_host
=10.20.64.203 --slave_ip=10.20.64.203 --slave_port=3306 --apply_files=/usr/local/mha-node/apps/test/saved_master_binlog_f
rom_10.20.64.204_3306_20160407165729.binlog --workdir=/usr/local/mha-node/apps/test --target_version=5.6.27-76.0-log --tim
estamp=20160407165729 --handle_raw_binlog=1 --disable_log_bin=0 --manager_version=0.56 --client_bindir=/usr/local/mysql/bi
n --client_libdir=/usr/local/mysql/lib --slave_pass=xxx
Thu Apr 7 16:57:35 2016 - [info]
向从库执行老主库的binlog
MySQL client version is 5.6.27. Using --binary-mode.
Applying differential binary/relay log files /usr/local/mha-node/apps/test/saved_master_binlog_from_10.20.64.204_3306_2016
0407165729.binlog on 10.20.64.203:3306. This may take long time...
Applying log files succeeded.
Thu Apr 7 16:57:35 2016 - [info] All relay logs were successfully applied.
执行binlog完成,如果binlog内容多,执行时间会比较长
(这时node2节点和新主的数据一致,都恢复到老主库最新的binlog点上)
Thu Apr 7 16:57:35 2016 - [info] Resetting slave 10.20.64.203(10.20.64.203:3306) and starting replication from the new m
aster 10.20.64.202(10.20.64.202:3306)..
那么,这时可以进行reset slave操作,并建立新的主从关系
Thu Apr 7 16:57:35 2016 - [info] Executed CHANGE MASTER.
Thu Apr 7 16:57:35 2016 - [info] Slave started.
Thu Apr 7 16:57:35 2016 - [info] End of log messages from 10.20.64.203.
Thu Apr 7 16:57:35 2016 - [info] -- Slave recovery on host 10.20.64.203(10.20.64.203:3306) succeeded.
Thu Apr 7 16:57:35 2016 - [info]
到此,node2节点已和新主完成主从同步
(到这里,我们可以认为故障转移已完成,且非单点)
下面剩余从节点操作与node2节点操作相同
Thu Apr 7 16:57:35 2016 - [info] Log messages from 10.20.64.210 ...
Thu Apr 7 16:57:35 2016 - [info]
Thu Apr 7 16:57:34 2016 - [info] Sending binlog..
Thu Apr 7 16:57:34 2016 - [info] scp from local:/usr/local/mha-manager/apps/test/saved_master_binlog_from_10.20.64.204_33
06_20160407165729.binlog to mha@10.20.64.210:/usr/local/mha-node/apps/test/saved_master_binlog_from_10.20.64.204_3306_2016
0407165729.binlog succeeded.
Thu Apr 7 16:57:34 2016 - [info] Starting recovery on 10.20.64.210(10.20.64.210:3306)..
Thu Apr 7 16:57:34 2016 - [info] Generating diffs succeeded.
Thu Apr 7 16:57:34 2016 - [info] Waiting until all relay logs are applied.
Thu Apr 7 16:57:34 2016 - [info] done.
Thu Apr 7 16:57:34 2016 - [info] Getting slave status..
Thu Apr 7 16:57:34 2016 - [info] This slave(10.20.64.210)'s Exec_Master_Log_Pos equals to Read_Master_Log_Pos(mysql-bin.0
00004:120). No need to recover from Exec_Master_Log_Pos.
Thu Apr 7 16:57:34 2016 - [info] Connecting to the target slave host 10.20.64.210, running recover script..
Thu Apr 7 16:57:34 2016 - [info] Executing command: apply_diff_relay_logs --command=apply --slave_user='mha' --slave_host
=10.20.64.210 --slave_ip=10.20.64.210 --slave_port=3306 --apply_files=/usr/local/mha-node/apps/test/saved_master_binlog_f
rom_10.20.64.204_3306_20160407165729.binlog --workdir=/usr/local/mha-node/apps/test --target_version=5.6.27-76.0-log --tim
estamp=20160407165729 --handle_raw_binlog=1 --disable_log_bin=0 --manager_version=0.56 --client_bindir=/usr/local/mysql/bi
n --client_libdir=/usr/local/mysql/lib --slave_pass=xxx
Thu Apr 7 16:57:35 2016 - [info]
MySQL client version is 5.6.27. Using --binary-mode.
Applying differential binary/relay log files /usr/local/mha-node/apps/test/saved_master_binlog_from_10.20.64.204_3306_2016
0407165729.binlog on 10.20.64.210:3306. This may take long time...
Applying log files succeeded.
Thu Apr 7 16:57:35 2016 - [info] All relay logs were successfully applied.
Thu Apr 7 16:57:35 2016 - [info] Resetting slave 10.20.64.210(10.20.64.210:3306) and starting replication from the new m
aster 10.20.64.202(10.20.64.202:3306)..
Thu Apr 7 16:57:35 2016 - [info] Executed CHANGE MASTER.
Thu Apr 7 16:57:35 2016 - [info] Slave started.
Thu Apr 7 16:57:35 2016 - [info] End of log messages from 10.20.64.210.
Thu Apr 7 16:57:35 2016 - [info] -- Slave recovery on host 10.20.64.210(10.20.64.210:3306) succeeded.
Thu Apr 7 16:57:35 2016 - [info] All new slave servers recovered successfully.
Thu Apr 7 16:57:35 2016 - [info]
到此,新架构完成,所有从节点已与新主建立主从同步
Thu Apr 7 16:57:35 2016 - [info] * Phase 5: New master cleanup phase..
Thu Apr 7 16:57:35 2016 - [info]
第四阶段:新主库清理工作
Thu Apr 7 16:57:35 2016 - [info] Resetting slave info on the new master..
Thu Apr 7 16:57:35 2016 - [info] 10.20.64.202: Resetting slave info succeeded.
node1已经是主库身份,那么它不再隶属于谁,所以进行reset slave操作,清理同步信息
Thu Apr 7 16:57:35 2016 - [info] Master failover to 10.20.64.202(10.20.64.202:3306) completed successfully.
到此,故障转移成功完成
Thu Apr 7 16:57:35 2016 - [info] Deleted server1 entry from /usr/local/mha-manager/etc/test2.conf .
Thu Apr 7 16:57:35 2016 - [info]
清理配置文件中老主库信息,我们可以使用这个配置文件,再次启动masterha_manager脚本
----- Failover Report -----
这里会总结一个故障转移报告
test2: MySQL Master failover 10.20.64.204(10.20.64.204:3306) to 10.20.64.202(10.20.64.202:3306) succeeded
test2应用成功将204故障转移到202
Master 10.20.64.204(10.20.64.204:3306) is down!
老主库204:3306实例宕掉
Check MHA Manager logs at n-op-209.corp.ncfgroup.com:/usr/local/mha-manager/logs/test.log for details.
切换日志路径
Started automated(non-interactive) failover.
The latest slave 10.20.64.203(10.20.64.203:3306) has all relay logs for recovery.
203是最近的实例
Selected 10.20.64.202(10.20.64.202:3306) as a new master.
选择202作为新主(这个是我们用选项指定的)
10.20.64.202(10.20.64.202:3306): OK: Applying all logs succeeded.
老主库的binlog已成功应用于所有实例
10.20.64.210(10.20.64.210:3306): This host has the latest relay log events.
10.20.64.203(10.20.64.203:3306): This host has the latest relay log events.
210和203的relay log都是最新的事件
Generating relay diff files from the latest slave succeeded.
从最近的从节点获取relay log的diff成功
10.20.64.203(10.20.64.203:3306): OK: Applying all logs succeeded. Slave started, replicating from 10.20.64.202(10.20.64.20
2:3306)
node2将与新主node4的relay log的差异执行完成
10.20.64.210(10.20.64.210:3306): OK: Applying all logs succeeded. Slave started, replicating from 10.20.64.202(10.20.64.20
2:3306)
node5将与新主node4的relay log的差异执行完成
分别在从库执行diff relay log的内容,将数据补齐,并与新主建立主从同步
10.20.64.202(10.20.64.202:3306): Resetting slave info succeeded.
Master failover to 10.20.64.202(10.20.64.202:3306) completed successfully.
新主清理与老主同步关系
到此,故障转移成功完成