1.关闭主库MySQL实例

在Master上:service mysqld stop,查看MHA manager日志:

Sun  Aug 14 11:51:14 2016 - [warning] Got error on MySQL select ping: 2006 (MySQL  server has gone away)

Sun  Aug 14 11:51:14 2016 - [info] Executing SSH check script: exit 0

Sun  Aug 14 11:51:14 2016 - [info] HealthCheck: SSH to 192.168.1.103 is reachable.

Sun  Aug 14 11:51:15 2016 - [warning] Got error on MySQL connect: 2013 (Lost  connection to MySQL server at 'reading initial communication packet', system  error: 111)

Sun  Aug 14 11:51:15 2016 - [warning] Connection failed 2 time(s)..

Sun  Aug 14 11:51:16 2016 - [warning] Got error on MySQL connect: 2013 (Lost  connection to MySQL server at 'reading initial communication packet', system  error: 111)

Sun  Aug 14 11:51:16 2016 - [warning] Connection failed 3 time(s)..

Sun  Aug 14 11:51:17 2016 - [warning] Got error on MySQL connect: 2013 (Lost  connection to MySQL server at 'reading initial communication packet', system  error: 111)

Sun  Aug 14 11:51:17 2016 - [warning] Connection failed 4 time(s)..

Sun  Aug 14 11:51:17 2016 - [warning] Master is not reachable from health checker!

Sun Aug 14 11:51:17 2016 - [warning] Master  192.168.1.103(192.168.1.103:3306) is not reachable!

Sun  Aug 14 11:51:17 2016 - [warning] SSH is reachable.

Sun  Aug 14 11:51:17 2016 - [info] Connecting to a master server failed. Reading  configuration file /etc/masterha_default.cnf and /etc/mha/app1.cnf again, and  trying to connect to all servers to check server status..

Sun  Aug 14 11:51:17 2016 - [warning] Global configuration file  /etc/masterha_default.cnf not found. Skipping.

Sun  Aug 14 11:51:17 2016 - [info] Reading application default configuration from  /etc/mha/app1.cnf..

Sun  Aug 14 11:51:17 2016 - [info] Reading server configuration from  /etc/mha/app1.cnf..

Sun Aug 14 11:51:17 2016 - [info] GTID failover mode = 1

Sun Aug  14 11:51:17 2016 - [info] Dead Servers:

Sun  Aug 14 11:51:17 2016 - [info]    192.168.1.103(192.168.1.103:3306)

Sun  Aug 14 11:51:17 2016 - [info] Alive Servers:

Sun  Aug 14 11:51:17 2016 - [info]    192.168.1.104(192.168.1.104:3306)

Sun  Aug 14 11:51:17 2016 - [info] Alive Slaves:

Sun  Aug 14 11:51:17 2016 - [info]    192.168.1.104(192.168.1.104:3306)   Version=5.6.30-enterprise-commercial-advanced-log (oldest major  version between slaves) log-bin:enabled

Sun  Aug 14 11:51:17 2016 - [info]     GTID  ON

Sun  Aug 14 11:51:17 2016 - [info]      Replicating from 192.168.1.103(192.168.1.103:3306)

Sun  Aug 14 11:51:17 2016 - [info]      Primary candidate for the new Master (candidate_master is set)

Sun  Aug 14 11:51:17 2016 - [info] Checking slave configurations..

Sun  Aug 14 11:51:17 2016 - [info]   read_only=1 is not set on slave 192.168.1.104(192.168.1.104:3306).

Sun  Aug 14 11:51:17 2016 - [info] Checking replication filtering settings..

Sun  Aug 14 11:51:17 2016 - [info]   Replication filtering check ok.

Sun  Aug 14 11:51:17 2016 - [info] Master is down!

Sun  Aug 14 11:51:17 2016 - [info] Terminating monitoring script.

Sun  Aug 14 11:51:17 2016 - [info] Got exit code 20 (Master dead).

Sun  Aug 14 11:51:17 2016 - [info] MHA::MasterFailover version 0.56.

Sun  Aug 14 11:51:17 2016 - [info] Starting master failover.

Sun  Aug 14 11:51:17 2016 - [info]

Sun  Aug 14 11:51:17 2016 - [info] * Phase 1: Configuration Check Phase..

Sun  Aug 14 11:51:17 2016 - [info]

Sun  Aug 14 11:51:17 2016 - [info] GTID failover mode = 1

Sun  Aug 14 11:51:17 2016 - [info] Dead Servers:

Sun  Aug 14 11:51:17 2016 - [info]    192.168.1.103(192.168.1.103:3306)

Sun  Aug 14 11:51:17 2016 - [info] Checking master reachability via MySQL(double  check)...

Sun  Aug 14 11:51:17 2016 - [info]  ok.

Sun  Aug 14 11:51:17 2016 - [info] Alive Servers:

Sun  Aug 14 11:51:17 2016 - [info]    192.168.1.104(192.168.1.104:3306)

Sun  Aug 14 11:51:17 2016 - [info] Alive Slaves:

Sun  Aug 14 11:51:17 2016 - [info]    192.168.1.104(192.168.1.104:3306)   Version=5.6.30-enterprise-commercial-advanced-log (oldest major  version between slaves) log-bin:enabled

Sun  Aug 14 11:51:17 2016 - [info]     GTID  ON

Sun  Aug 14 11:51:17 2016 - [info]      Replicating from 192.168.1.103(192.168.1.103:3306)

Sun  Aug 14 11:51:17 2016 - [info]      Primary candidate for the new Master (candidate_master is set)

Sun  Aug 14 11:51:17 2016 - [info] Starting GTID based failover.

Sun  Aug 14 11:51:17 2016 - [info]

Sun  Aug 14 11:51:17 2016 - [info] ** Phase 1: Configuration Check Phase  completed.

Sun  Aug 14 11:51:17 2016 - [info]

Sun Aug  14 11:51:17 2016 - [info] * Phase 2: Dead Master Shutdown Phase..

Sun  Aug 14 11:51:17 2016 - [info]

Sun  Aug 14 11:51:17 2016 - [info] Forcing shutdown so that applications never  connect to the current master..

Sun  Aug 14 11:51:17 2016 - [info] Executing master IP deactivation script:

Sun  Aug 14 11:51:17 2016 - [info]    /etc/mha/master_ip_failover --orig_master_host=192.168.1.103  --orig_master_ip=192.168.1.103 --orig_master_port=3306 --command=stopssh  --ssh_user=root

IN  SCRIPT TEST====/sbin/ifconfig eth1:1 down==/sbin/ifconfig eth1:1  192.168.1.108;/sbin/arping -I eth1 -c 3 -s 192.168.1.108 192.168.1.1  >/dev/null 2>&1===

Disabling  the VIP on old master if the server is still UP: 192.168.1.103

Sun  Aug 14 11:51:17 2016 - [info]  done.

Sun  Aug 14 11:51:17 2016 - [warning] shutdown_script is not set. Skipping  explicit shutting down of the dead master.

Sun  Aug 14 11:51:17 2016 - [info] * Phase 2: Dead Master Shutdown Phase  completed.

Sun  Aug 14 11:51:17 2016 - [info]

Sun  Aug 14 11:51:17 2016 - [info] * Phase 3: Master Recovery Phase..

Sun  Aug 14 11:51:17 2016 - [info]

Sun  Aug 14 11:51:17 2016 - [info] * Phase 3.1: Getting Latest Slaves Phase..

Sun  Aug 14 11:51:17 2016 - [info]

Sun  Aug 14 11:51:17 2016 - [info] The latest binary log file/position on all  slaves is bin.000014:231

Sun  Aug 14 11:51:17 2016 - [info] Latest slaves (Slaves that received relay log  files to the latest):

Sun  Aug 14 11:51:17 2016 - [info]    192.168.1.104(192.168.1.104:3306)   Version=5.6.30-enterprise-commercial-advanced-log (oldest major  version between slaves) log-bin:enabled

Sun  Aug 14 11:51:17 2016 - [info]     GTID  ON

Sun  Aug 14 11:51:17 2016 - [info]      Replicating from 192.168.1.103(192.168.1.103:3306)

Sun  Aug 14 11:51:17 2016 - [info]      Primary candidate for the new Master (candidate_master is set)

Sun  Aug 14 11:51:17 2016 - [info] The oldest binary log file/position on all  slaves is bin.000014:231

Sun  Aug 14 11:51:17 2016 - [info] Oldest slaves:

Sun  Aug 14 11:51:17 2016 - [info]    192.168.1.104(192.168.1.104:3306)   Version=5.6.30-enterprise-commercial-advanced-log (oldest major  version between slaves) log-bin:enabled

Sun  Aug 14 11:51:17 2016 - [info]     GTID  ON

Sun  Aug 14 11:51:17 2016 - [info]      Replicating from 192.168.1.103(192.168.1.103:3306)

Sun  Aug 14 11:51:17 2016 - [info]      Primary candidate for the new Master (candidate_master is set)

Sun  Aug 14 11:51:17 2016 - [info]

Sun  Aug 14 11:51:17 2016 - [info] * Phase 3.3: Determining New Master Phase..

Sun  Aug 14 11:51:17 2016 - [info]

Sun  Aug 14 11:51:17 2016 - [info] Searching new master from slaves..

Sun  Aug 14 11:51:17 2016 - [info]   Candidate masters from the configuration file:

Sun  Aug 14 11:51:17 2016 - [info]    192.168.1.104(192.168.1.104:3306)   Version=5.6.30-enterprise-commercial-advanced-log (oldest major  version between slaves) log-bin:enabled

Sun  Aug 14 11:51:17 2016 - [info]     GTID  ON

Sun  Aug 14 11:51:17 2016 - [info]     Replicating from  192.168.1.103(192.168.1.103:3306)

Sun  Aug 14 11:51:17 2016 - [info]      Primary candidate for the new Master (candidate_master is set)

Sun  Aug 14 11:51:17 2016 - [info]   Non-candidate masters:

Sun  Aug 14 11:51:17 2016 - [info]  Searching  from candidate_master slaves which have received the latest relay log  events..

Sun  Aug 14 11:51:17 2016 - [info] New master is 192.168.1.104(192.168.1.104:3306)

Sun  Aug 14 11:51:17 2016 - [info] Starting master failover..

Sun  Aug 14 11:51:17 2016 - [info]

From:

192.168.1.103(192.168.1.103:3306)  (current master)

+--192.168.1.104(192.168.1.104:3306)

To:

192.168.1.104(192.168.1.104:3306)  (new master)

Sun  Aug 14 11:51:17 2016 - [info]

Sun  Aug 14 11:51:17 2016 - [info] * Phase 3.3: New Master Recovery Phase..

Sun  Aug 14 11:51:17 2016 - [info]

Sun  Aug 14 11:51:17 2016 - [info]  Waiting  all logs to be applied..

Sun  Aug 14 11:51:17 2016 - [info]   done.

Sun  Aug 14 11:51:17 2016 - [info] Getting new master's binlog name and position..

Sun  Aug 14 11:51:17 2016 - [info]   bin.000015:231

Sun  Aug 14 11:51:17 2016 - [info]  All  other slaves should start replication from here. Statement should be: CHANGE  MASTER TO MASTER_HOST='192.168.1.104', MASTER_PORT=3306,  MASTER_AUTO_POSITION=1, MASTER_USER='repl', MASTER_PASSWORD='xxx';

Sun  Aug 14 11:51:17 2016 - [info] Master Recovery succeeded.  File:Pos:Exec_Gtid_Set: bin.000015, 231,  1683955a-6102-11e6-8b6f-080027ca1592:1-8,

1c3a7f53-6102-11e6-8b6f-08002722cc6d:1-10

Sun  Aug 14 11:51:17 2016 - [info] Executing master IP activate script:

Sun  Aug 14 11:51:17 2016 - [info]    /etc/mha/master_ip_failover --command=start --ssh_user=root  --orig_master_host=192.168.1.103 --orig_master_ip=192.168.1.103  --orig_master_port=3306 --new_master_host=192.168.1.104  --new_master_ip=192.168.1.104 --new_master_port=3306 --new_master_user='root'  --new_master_password='111111'

IN  SCRIPT TEST====/sbin/ifconfig eth1:1 down==/sbin/ifconfig eth1:1  192.168.1.108;/sbin/arping -I eth1 -c 3 -s 192.168.1.108 192.168.1.1 >/dev/null  2>&1===

Enabling the VIP - 192.168.1.108 on the new master - 192.168.1.104

Sun  Aug 14 11:51:20 2016 - [info]  OK.

Sun  Aug 14 11:51:20 2016 - [info] ** Finished master recovery successfully.

Sun  Aug 14 11:51:20 2016 - [info] * Phase 3: Master Recovery Phase completed.

Sun  Aug 14 11:51:20 2016 - [info]

Sun  Aug 14 11:51:20 2016 - [info] * Phase 4: Slaves Recovery Phase..

Sun  Aug 14 11:51:20 2016 - [info]

Sun  Aug 14 11:51:20 2016 - [info]

Sun  Aug 14 11:51:20 2016 - [info] * Phase 4.1: Starting Slaves in parallel..

Sun  Aug 14 11:51:20 2016 - [info]

Sun  Aug 14 11:51:20 2016 - [info] All new slave servers recovered successfully.

Sun  Aug 14 11:51:20 2016 - [info]

Sun  Aug 14 11:51:20 2016 - [info] * Phase 5: New master cleanup phase..

Sun  Aug 14 11:51:20 2016 - [info]

Sun  Aug 14 11:51:20 2016 - [info] Resetting slave info on the new master..

Sun  Aug 14 11:51:20 2016 - [info]   192.168.1.104: Resetting slave info succeeded.

Sun  Aug 14 11:51:20 2016 - [info] Master failover to 192.168.1.104(192.168.1.104:3306)  completed successfully.

Sun  Aug 14 11:51:20 2016 - [info]

----- Failover Report -----

app1: MySQL Master failover 192.168.1.103(192.168.1.103:3306) to  192.168.1.104(192.168.1.104:3306) succeeded

Master 192.168.1.103(192.168.1.103:3306) is down!

Check MHA Manager logs at lab1:/etc/mha/manager.log for details.

Started automated(non-interactive) failover.

Invalidated master IP address on 192.168.1.103(192.168.1.103:3306)

Selected 192.168.1.104(192.168.1.104:3306) as a new master.

192.168.1.104(192.168.1.104:3306): OK: Applying all logs  succeeded.

192.168.1.104(192.168.1.104:3306): OK: Activated master IP  address.

192.168.1.104(192.168.1.104:3306): Resetting slave info succeeded.

Master failover to 192.168.1.104(192.168.1.104:3306) completed  successfully.

从日志中可以看到,master切换至192.168.1.104 slave上,并且VIP也随之绑定到192.168.1.104

对应的网卡设备上。

2.主库服务器当机

(1)把192.168.1.03与192.168.1.104复制关系重新建立:

change master to master_host='192.168.1.104',master_user='repl',master_password='111111',master_auto_position=1;

start slave;

(2)重新启动MHA:

nohup masterha_manager  --conf=/etc/mha/app1.cnf < /dev/null >/etc/mha/app1.log 2>&1  &

(3)直接关闭192.168.1.104服务器,查看切换情况:

Shutdown –h now

对应MHA manager日志:

Sun Aug 14 11:59:09  2016 - [info] MHA::MasterMonitor version 0.56.

Sun Aug 14 11:59:09  2016 - [info] GTID failover mode = 1

Sun Aug 14 11:59:09  2016 - [info] Dead Servers:

Sun Aug 14 11:59:09  2016 - [info] Alive Servers:

Sun Aug 14 11:59:09  2016 - [info]    192.168.1.104(192.168.1.104:3306)

Sun Aug 14 11:59:09  2016 - [info]    192.168.1.103(192.168.1.103:3306)

Sun Aug 14 11:59:09  2016 - [info] Alive Slaves:

Sun Aug 14 11:59:09  2016 - [info]   192.168.1.103(192.168.1.103:3306)   Version=5.6.30-enterprise-commercial-advanced-log (oldest major  version between slaves) log-bin:enabled

Sun Aug 14 11:59:09  2016 - [info]     GTID ON

Sun Aug 14 11:59:09  2016 - [info]     Replicating from  192.168.1.104(192.168.1.104:3306)

Sun Aug 14 11:59:09  2016 - [info]     Primary candidate for  the new Master (candidate_master is set)

Sun Aug 14 11:59:09  2016 - [info] Current Alive Master: 192.168.1.104(192.168.1.104:3306)

Sun Aug 14 11:59:09  2016 - [info] Checking slave configurations..

Sun Aug 14 11:59:09  2016 - [info]  read_only=1 is not set  on slave 192.168.1.103(192.168.1.103:3306).

Sun Aug 14 11:59:09  2016 - [info] Checking replication filtering settings..

Sun Aug 14 11:59:09  2016 - [info]  binlog_do_db= ,  binlog_ignore_db=

Sun Aug 14 11:59:09  2016 - [info]  Replication filtering  check ok.

Sun Aug 14 11:59:09  2016 - [info] GTID (with auto-pos) is supported. Skipping all SSH and Node  package checking.

Sun Aug 14 11:59:09  2016 - [info] Checking SSH publickey authentication settings on the current  master..

Sun Aug 14 11:59:09  2016 - [info] HealthCheck: SSH to 192.168.1.104 is reachable.

Sun Aug 14 11:59:09  2016 - [info]

192.168.1.104(192.168.1.104:3306)  (current master)

+--192.168.1.103(192.168.1.103:3306)

Sun Aug 14 11:59:09  2016 - [info] Checking master_ip_failover_script status:

Sun Aug 14 11:59:09  2016 - [info]    /etc/mha/master_ip_failover --command=status --ssh_user=root  --orig_master_host=192.168.1.104 --orig_master_ip=192.168.1.104  --orig_master_port=3306

IN SCRIPT TEST====/sbin/ifconfig  eth1:1 down==/sbin/ifconfig eth1:1 192.168.1.108;/sbin/arping -I eth1 -c 3 -s  192.168.1.108 192.168.1.1 >/dev/null 2>&1===

Checking the Status of  the script.. OK

Sun Aug 14 11:59:12  2016 - [info]  OK.

Sun Aug 14 11:59:12  2016 - [warning] shutdown_script is not defined.

Sun Aug 14 11:59:12  2016 - [info] Set master ping interval 1 seconds.

Sun Aug 14 11:59:12  2016 - [warning] secondary_check_script is not defined. It is highly  recommended setting it to check master reachability from two or more routes.

Sun Aug 14 11:59:12  2016 - [info] Starting ping health check on  192.168.1.104(192.168.1.104:3306)..

Sun Aug 14 11:59:12  2016 - [info] Ping(SELECT) succeeded, waiting until MySQL doesn't respond..

Sun Aug 14 11:59:23  2016 - [warning] Got error on MySQL select ping: 2006 (MySQL server has gone  away)

Sun Aug 14 11:59:23  2016 - [info] Executing SSH check script: exit 0

Sun Aug 14 11:59:23  2016 - [warning] HealthCheck: SSH to 192.168.1.104 is NOT reachable.

Sun Aug 14 11:59:24  2016 - [warning] Got error on MySQL connect: 2013 (Lost connection to MySQL  server at 'reading initial communication packet', system error: 111)

Sun Aug 14 11:59:24  2016 - [warning] Connection failed 2 time(s)..

Sun Aug 14 11:59:25  2016 - [warning] Got error on MySQL connect: 2013 (Lost connection to MySQL  server at 'reading initial communication packet', system error: 111)

Sun Aug 14 11:59:25  2016 - [warning] Connection failed 3 time(s)..

Sun Aug 14 11:59:26  2016 - [warning] Got error on MySQL connect: 2013 (Lost connection to MySQL  server at 'reading initial communication packet', system error: 111)

Sun Aug 14 11:59:26  2016 - [warning] Connection failed 4 time(s)..

Sun Aug 14 11:59:26  2016 - [warning] Master is not reachable from health checker!

Sun Aug 14 11:59:26  2016 - [warning] Master 192.168.1.104(192.168.1.104:3306) is not reachable!

Sun Aug 14 11:59:26  2016 - [warning] SSH is NOT reachable.

Sun Aug 14 11:59:26  2016 - [info] Connecting to a master server failed. Reading configuration file  /etc/masterha_default.cnf and /etc/mha/app1.cnf again, and trying to connect  to all servers to check server status..

Sun Aug 14 11:59:26  2016 - [warning] Global configuration file /etc/masterha_default.cnf not  found. Skipping.

Sun Aug 14 11:59:26  2016 - [info] Reading application default configuration from  /etc/mha/app1.cnf..

Sun Aug 14 11:59:26  2016 - [info] Reading server configuration from /etc/mha/app1.cnf..

Sun Aug 14 11:59:27  2016 - [info] GTID failover mode = 1

Sun Aug 14 11:59:27  2016 - [info] Dead Servers:

Sun Aug 14 11:59:27  2016 - [info]    192.168.1.104(192.168.1.104:3306)

Sun Aug 14 11:59:27  2016 - [info] Alive Servers:

Sun Aug 14 11:59:27  2016 - [info]    192.168.1.103(192.168.1.103:3306)

Sun Aug 14 11:59:27  2016 - [info] Alive Slaves:

Sun Aug 14 11:59:27  2016 - [info]    192.168.1.103(192.168.1.103:3306)   Version=5.6.30-enterprise-commercial-advanced-log (oldest major  version between slaves) log-bin:enabled

Sun Aug 14 11:59:27  2016 - [info]     GTID ON

Sun Aug 14 11:59:27  2016 - [info]     Replicating from  192.168.1.104(192.168.1.104:3306)

Sun Aug 14 11:59:27  2016 - [info]     Primary candidate for  the new Master (candidate_master is set)

Sun Aug 14 11:59:27  2016 - [info] Checking slave configurations..

Sun Aug 14 11:59:27  2016 - [info]  read_only=1 is not set  on slave 192.168.1.103(192.168.1.103:3306).

Sun Aug 14 11:59:27  2016 - [info] Checking replication filtering settings..

Sun Aug 14 11:59:27  2016 - [info]  Replication filtering  check ok.

Sun Aug 14 11:59:27  2016 - [info] Master is down!

Sun Aug 14 11:59:27  2016 - [info] Terminating monitoring script.

Sun Aug 14 11:59:27  2016 - [info] Got exit code 20 (Master dead).

Sun Aug 14 11:59:27  2016 - [info] MHA::MasterFailover version 0.56.

Sun Aug 14 11:59:27  2016 - [info] Starting master failover.

Sun Aug 14 11:59:27  2016 - [info]

Sun Aug 14 11:59:27  2016 - [info] * Phase 1: Configuration Check Phase..

Sun Aug 14 11:59:27  2016 - [info]

Sun Aug 14 11:59:27  2016 - [info] GTID failover mode = 1

Sun Aug 14 11:59:27  2016 - [info] Dead Servers:

Sun Aug 14 11:59:27  2016 - [info]    192.168.1.104(192.168.1.104:3306)

Sun Aug 14 11:59:27  2016 - [info] Checking master reachability via MySQL(double check)...

Sun Aug 14 11:59:28  2016 - [info]  ok.

Sun Aug 14 11:59:28  2016 - [info] Alive Servers:

Sun Aug 14 11:59:28  2016 - [info]    192.168.1.103(192.168.1.103:3306)

Sun Aug 14 11:59:28  2016 - [info] Alive Slaves:

Sun Aug 14 11:59:28  2016 - [info]    192.168.1.103(192.168.1.103:3306)   Version=5.6.30-enterprise-commercial-advanced-log (oldest major  version between slaves) log-bin:enabled

Sun Aug 14 11:59:28  2016 - [info]     GTID ON

Sun Aug 14 11:59:28  2016 - [info]     Replicating from  192.168.1.104(192.168.1.104:3306)

Sun Aug 14 11:59:28  2016 - [info]     Primary candidate for  the new Master (candidate_master is set)

Sun Aug 14 11:59:28  2016 - [info] Starting GTID based failover.

Sun Aug 14 11:59:28  2016 - [info]

Sun Aug 14 11:59:28  2016 - [info] ** Phase 1: Configuration Check Phase completed.

Sun Aug 14 11:59:28  2016 - [info]

Sun Aug 14 11:59:28  2016 - [info] * Phase 2: Dead Master Shutdown Phase..

Sun Aug 14 11:59:28  2016 - [info]

Sun Aug 14 11:59:28  2016 - [info] Forcing shutdown so that applications never connect to the  current master..

Sun Aug 14 11:59:28  2016 - [info] Executing master IP deactivation script:

Sun Aug 14 11:59:28  2016 - [info]    /etc/mha/master_ip_failover --orig_master_host=192.168.1.104  --orig_master_ip=192.168.1.104 --orig_master_port=3306 --command=stop

IN SCRIPT  TEST====/sbin/ifconfig eth1:1 down==/sbin/ifconfig eth1:1 192.168.1.108;/sbin/arping  -I eth1 -c 3 -s 192.168.1.108 192.168.1.1 >/dev/null 2>&1===

Disabling the VIP on  old master if the server is still UP: 192.168.1.104

Sun Aug 14 11:59:34  2016 - [info]  done.

Sun Aug 14 11:59:34  2016 - [warning] shutdown_script is not set. Skipping explicit shutting down  of the dead master.

Sun Aug 14 11:59:34  2016 - [info] * Phase 2: Dead Master Shutdown Phase completed.

Sun Aug 14 11:59:34  2016 - [info]

Sun Aug 14 11:59:34  2016 - [info] * Phase 3: Master Recovery Phase..

Sun Aug 14 11:59:34  2016 - [info]

Sun Aug 14 11:59:34  2016 - [info] * Phase 3.1: Getting Latest Slaves Phase..

Sun Aug 14 11:59:34  2016 - [info]

Sun Aug 14 11:59:34  2016 - [info] The latest binary log file/position on all slaves is  bin.000015:231

Sun Aug 14 11:59:34  2016 - [info] Latest slaves (Slaves that received relay log files to the  latest):

Sun Aug 14 11:59:34  2016 - [info]    192.168.1.103(192.168.1.103:3306)   Version=5.6.30-enterprise-commercial-advanced-log (oldest major  version between slaves) log-bin:enabled

Sun Aug 14 11:59:34  2016 - [info]     GTID ON

Sun Aug 14 11:59:34  2016 - [info]     Replicating from  192.168.1.104(192.168.1.104:3306)

Sun Aug 14 11:59:34  2016 - [info]     Primary candidate for  the new Master (candidate_master is set)

Sun Aug 14 11:59:34  2016 - [info] The oldest binary log file/position on all slaves is  bin.000015:231

Sun Aug 14 11:59:34  2016 - [info] Oldest slaves:

Sun Aug 14 11:59:34  2016 - [info]    192.168.1.103(192.168.1.103:3306)   Version=5.6.30-enterprise-commercial-advanced-log (oldest major  version between slaves) log-bin:enabled

Sun Aug 14 11:59:34  2016 - [info]     GTID ON

Sun Aug 14 11:59:34  2016 - [info]     Replicating from  192.168.1.104(192.168.1.104:3306)

Sun Aug 14 11:59:34  2016 - [info]     Primary candidate for  the new Master (candidate_master is set)

Sun Aug 14 11:59:34  2016 - [info]

Sun Aug 14 11:59:34  2016 - [info] * Phase 3.3: Determining New Master Phase..

Sun Aug 14 11:59:34  2016 - [info]

Sun Aug 14 11:59:34  2016 - [info] Searching new master from slaves..

Sun Aug 14 11:59:34  2016 - [info]  Candidate masters from  the configuration file:

Sun Aug 14 11:59:34  2016 - [info]    192.168.1.103(192.168.1.103:3306)   Version=5.6.30-enterprise-commercial-advanced-log (oldest major  version between slaves) log-bin:enabled

Sun Aug 14 11:59:34  2016 - [info]     GTID ON

Sun Aug 14 11:59:34  2016 - [info]     Replicating from  192.168.1.104(192.168.1.104:3306)

Sun Aug 14 11:59:34  2016 - [info]     Primary candidate for  the new Master (candidate_master is set)

Sun Aug 14 11:59:34  2016 - [info]  Non-candidate masters:

Sun Aug 14 11:59:34  2016 - [info]  Searching from  candidate_master slaves which have received the latest relay log events..

Sun Aug 14 11:59:34  2016 - [info] New master is 192.168.1.103(192.168.1.103:3306)

Sun Aug 14 11:59:34 2016  - [info] Starting master failover..

Sun Aug 14 11:59:34  2016 - [info]

From:

192.168.1.104(192.168.1.104:3306)  (current master)

+--192.168.1.103(192.168.1.103:3306)

To:

192.168.1.103(192.168.1.103:3306)  (new master)

Sun Aug 14 11:59:34  2016 - [info]

Sun Aug 14 11:59:34  2016 - [info] * Phase 3.3: New Master Recovery Phase..

Sun Aug 14 11:59:34  2016 - [info]

Sun Aug 14 11:59:34  2016 - [info]  Waiting all logs to be  applied..

Sun Aug 14 11:59:34  2016 - [info]   done.

Sun Aug 14 11:59:34  2016 - [info] Getting new master's binlog name and position..

Sun Aug 14 11:59:34  2016 - [info]  bin.000015:231

Sun Aug 14 11:59:34  2016 - [info]  All other slaves should  start replication from here. Statement should be: CHANGE MASTER TO  MASTER_HOST='192.168.1.103', MASTER_PORT=3306, MASTER_AUTO_POSITION=1,  MASTER_USER='repl', MASTER_PASSWORD='xxx';

Sun Aug 14 11:59:34  2016 - [info] Master Recovery succeeded. File:Pos:Exec_Gtid_Set: bin.000015,  231, 1683955a-6102-11e6-8b6f-080027ca1592:1-8,

1c3a7f53-6102-11e6-8b6f-08002722cc6d:1-10

Sun Aug 14 11:59:34  2016 - [info] Executing master IP activate script:

Sun Aug 14 11:59:34  2016 - [info]    /etc/mha/master_ip_failover --command=start --ssh_user=root  --orig_master_host=192.168.1.104 --orig_master_ip=192.168.1.104  --orig_master_port=3306 --new_master_host=192.168.1.103  --new_master_ip=192.168.1.103 --new_master_port=3306 --new_master_user='root'  --new_master_password='111111'

IN SCRIPT  TEST====/sbin/ifconfig eth1:1 down==/sbin/ifconfig eth1:1  192.168.1.108;/sbin/arping -I eth1 -c 3 -s 192.168.1.108 192.168.1.1  >/dev/null 2>&1===

Enabling the  VIP - 192.168.1.108 on the new master - 192.168.1.103

Sun Aug 14 11:59:37  2016 - [info]  OK.

Sun Aug 14 11:59:37  2016 - [info] ** Finished master recovery successfully.

Sun Aug 14 11:59:37  2016 - [info] * Phase 3: Master Recovery Phase completed.

Sun Aug 14 11:59:37  2016 - [info]

Sun Aug 14 11:59:37  2016 - [info] * Phase 4: Slaves Recovery Phase..

Sun Aug 14 11:59:37  2016 - [info]

Sun Aug 14 11:59:37  2016 - [info]

Sun Aug 14 11:59:37  2016 - [info] * Phase 4.1: Starting Slaves in parallel..

Sun Aug 14 11:59:37  2016 - [info]

Sun Aug 14 11:59:37  2016 - [info] All new slave servers recovered successfully.

Sun Aug 14 11:59:37  2016 - [info]

Sun Aug 14 11:59:37  2016 - [info] * Phase 5: New master cleanup phase..

Sun Aug 14 11:59:37  2016 - [info]

Sun Aug 14 11:59:37  2016 - [info] Resetting slave info on the new master..

Sun Aug 14 11:59:37  2016 - [info]  192.168.1.103: Resetting  slave info succeeded.

Sun Aug 14 11:59:37  2016 - [info] Master failover to 192.168.1.103(192.168.1.103:3306) completed  successfully.

Sun Aug 14 11:59:37  2016 - [info]

-----  Failover Report -----

app1: MySQL  Master failover 192.168.1.104(192.168.1.104:3306) to  192.168.1.103(192.168.1.103:3306) succeeded

Master  192.168.1.104(192.168.1.104:3306) is down!

Check MHA  Manager logs at lab1:/etc/mha/manager.log for details.

Started  automated(non-interactive) failover.

Invalidated  master IP address on 192.168.1.104(192.168.1.104:3306)

Selected  192.168.1.103(192.168.1.103:3306) as a new master.

192.168.1.103(192.168.1.103:3306):  OK: Applying all logs succeeded.

192.168.1.103(192.168.1.103:3306):  OK: Activated master IP address.

192.168.1.103(192.168.1.103:3306):  Resetting slave info succeeded.

Master  failover to 192.168.1.103(192.168.1.103:3306) completed successfully.

可以看到Master已经切换至192.168.1.103 上,VIP也绑定至192.168.1.103上。

mysql 5.6 gtid mha_MySQL 5.6 GTID+MHA相关推荐

  1. mysql 5.6 gtid mha_MySQL MHA--故障切换模式(GTID模式和非GTID模式)

    GTID和非GTID故障切换模式选择 MySQL 5.6版本引入GTID来解决主从切换时BINLOG位置点难定位的问题,MHA从0.56版本开始支持基于GTID的复制,在切换时可以采用GTID模式和非 ...

  2. mysql slave lock 跳过_处理 MySQL 因为 SLAVE 崩溃导致需要手动跳过 GTID 的问题 | 关于 GTID...

    今天发生了与之前某篇博客相似的问题,有同学在不同步的 binlog 库中使用语句 database.table 命令对表进行 drop 导致 master 丢弃该表但是从库并未能同步到该操作.并且后续 ...

  3. mysql gtid是什么_mysql gtid初探

    什么是GTID 什么是GTID呢, 简而言之,就是全局事务ID(global transaction identifier ) GTID的格式类似于: 7a07cd08-ac1b-11e2-9fcf- ...

  4. mysql gtid寻找位置_【MySQL】UUID与GTID以及如何根据GTID找寻filename和position

    Open Group于1997年10月发布,UUID遵从此协议. UUID被设计成一个在空间和时间上的唯一值.两次调用的UUID将产生两个不同的值,即使这些调用是在两个不连接的,彼此独立的计算机. 由 ...

  5. mysql gtid 主从_基于GTID搭建主从MySQL

    基于gtid搭建主从MySQL 一.GTID的使用 想让主从之间使用gtid的方式同步数据,需要我们在配置文件中开启mysql对gtid相关的配置信息 找到my.cnf ,在mysqld模块中加入如下 ...

  6. mysql gtid复制优缺点_MySQL GTID复制

    备注:测试数据库版本为MySQL 8.0 这个blog我们来聊聊MySQL 的主从GTID复制 Table of Contents 概述 GTID复制又叫全局事物ID(global transacti ...

  7. mysql gtid 复制_MySQL 使用GTID进行复制

    1. GTID的格式和存储 GTID即全局事务ID(global transaction identifier),GTID实际上是由server_uuid:transaction_id组成的.其中se ...

  8. mysql gtid 容灾_mysql GTID

    最近在学习mysql45讲这门课的时候,老师在27节讲到主库出问题了,从库怎么办? 在解决的过程中提到了GTID,是mysql5.6版本引入的,这个是哥什么呢? GTID是master生产的自增ID, ...

  9. mysql 5.6 开启gtid_MySQL 5.6 GTID 原理以及使用

    简介 GTID是MySQL 5.6的新特性,其全称是Global Transaction Identifier,可简化MySQL的主从切换以及Failover.GTID用于在binlog中唯一标识一个 ...

最新文章

  1. 【[AHOI2013]差异】
  2. HTML5表单元素禁用,禁用HTML5表单元素的验证
  3. 前向业务中间层的意义,架构,技能要求
  4. bzoj 3572 [Hnoi2014]世界树——虚树
  5. ASP.NET配置错误页面浅析
  6. iOS 混合网页开发 问题
  7. jdbc连接mysql传参_将参数传递给JDBC PreparedStatement
  8. 无锡c语言编程培训学校,无锡c语言培训班——C语言基础知识
  9. 如何梳理产品功能,才能既见森林又见树木?
  10. kafka 主动消费_Kafka消费组(consumer group)
  11. python为csv文件添加表头_python读csv文件时指定行为表头或无表头的方法
  12. 邬贺铨/余晓晖/田溯宁…千家从业者,数十位行业大咖共同烹制了一场怎样的AIoT“盛宴”?
  13. Oracle【IT实验室】数据库备份与恢复之三:OS备份/用户管理的备份与恢复
  14. informix php,连接到informix数据库 - PHP 方式
  15. 对WordCOM类工厂80070005和8000401a错误分析及解决办法(DCOM)的补充
  16. 导出DMP文件实现数据库备份、数据迁移流程
  17. Cisco简单配置(十三)—链路聚合
  18. 极域课堂忘记密码,解决方法,万能密码
  19. 怎样批量修改图片大小?
  20. iOS之KVC原理自定义KVC

热门文章

  1. dajngo_itsdjangerous_itsdangerous.exc.BadSignature: Signature bXXXXX' does not match
  2. 产品经理跨部门沟通的3点经验
  3. Linux下安装kettle及作业调度
  4. 全球及中国冲压空气涡轮(RAT)行业发展研究及未来前景预测报告2022-2028年版
  5. 今天比较烦,比较烦,比较烦,比较烦,比较烦......
  6. 融资融券个股交易数据获取
  7. IDEA安装与配置 (一) IntelliJ IDEA2018.2.7安装
  8. 用python写 祝你生日快乐英文_八种祝你生日快乐英文表达,太实用了!
  9. 音量控制程序制作手记 (及全部源码)
  10. Android 夜间模式的实现(一)