> --mysql-db=replicatedb run
sysbench 0.4.12: multi-threaded system eva luation benchmark
###从库vdbsrv2停止io进程以模拟io滞后
[root@vdbsrv2 ~]# mysql -e 'stop slave io_thread'
[root@vdbsrv2 ~]# mysql -e 'show slave status\G' | egrep 'Slave_IO|Slave_SQL'
Slave_IO_State:
Slave_IO_Running: No ###Author : Leshami
Slave_SQL_Running: Yes ###Blog : http://blog.csdn.net/leshami
Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it
###2分钟后从库vdbsrv2启动io进程
[root@vdbsrv2 ~]# mysql -e 'start slave io_thread'
###从库vdbsrv3停止io进程以模拟io滞后
[root@vdbsrv3 ~]# mysql -e 'stop slave io_thread'
###模拟主库宕机
[root@vdbsrv4 ~]# ssh vdbsrv1 "killall -r mysqld"
###主库的sysbench被强制断开且伴随下列错误提示
[root@vdbsrv1 ~]#
.......
Doing OLTP test.
Running mixed OLTP test
Using Uniform distribution
Using "BEGIN" for starting transactions
Using auto_inc on the id column
Threads started!
ALERT: failed to execute mysql_stmt_execute(): Err1317 Query execution was interrupted
FATAL: database error, exiting...
ALERT: failed to execute mysql_stmt_execute(): Err1317 Query execution was interrupted
FATAL: database error, exiting...
###查看VIP漂移情况
[root@vdbsrv4 app1]# grep VIP /var/log/masterha/app1/manager.log
Disabling the VIP on old master: vdbsrv1
Enabling the VIP - 192.168.1.13/24 on the new master - vdbsrv2
###登陆到主机vdbsrv2 mysql
mysql> show variables like '%hostname%';
+---------------+---------+
| Variable_name | Value |
+---------------+---------+
| hostname | vdbsrv2 |
+---------------+---------+
1 row in set (0.00 sec)
###此时vdbsrv2已提升为master,vdbsrv3指向了vdbsrv2
mysql> show slave hosts;
+-----------+---------+------+-----------+--------------------------------------+
| Server_id | Host | Port | Master_id | Slave_UUID |
+-----------+---------+------+-----------+--------------------------------------+
| 1002 | vdbsrv3 | 3306 | 1001 | 091f79b8-e386-11e4-93d5-000c2943c830 |
+-----------+---------+------+-----------+--------------------------------------+
1 row in set (0.00 sec)
4、MHA日志初步剖析
[root@vdbsrv4 ~]# ls -hltr /var/log/masterha/*
total 32K
-rw-r--r-- 1 root root 143 Apr 20 14:30 saved_master_binlog_from_vdbsrv1_3306_20150420143022.binlog
-rw-r--r-- 1 root root 26K Apr 20 14:30 manager.log
-rw-r--r-- 1 root root 0 Apr 20 14:30 app1.failover.complete
###具体日志信息manager.log
Mon Apr 20 14:27:41 2015 - [info] MHA::MasterMonitor version 0.56.
Mon Apr 20 14:27:42 2015 - [info] GTID failover mode = 0
Mon Apr 20 14:27:42 2015 - [info] Dead Servers:
Mon Apr 20 14:27:42 2015 - [info] Alive Servers:
Mon Apr 20 14:27:42 2015 - [info] vdbsrv1(192.168.1.6:3306)
Mon Apr 20 14:27:42 2015 - [info] vdbsrv2(192.168.1.7:3306)
Mon Apr 20 14:27:42 2015 - [info] vdbsrv3(192.168.1.8:3306)
Mon Apr 20 14:27:42 2015 - [info] Alive Slaves:
Mon Apr 20 14:27:42 2015 - [info] vdbsrv2(192.168.1.7:3306) Version=5.6.22-log (oldest major version between slaves) log-bin:enabled
Mon Apr 20 14:27:42 2015 - [info] Replicating from 192.168.1.6(192.168.1.6:3306)
Mon Apr 20 14:27:42 2015 - [info] vdbsrv3(192.168.1.8:3306) Version=5.6.22-log (oldest major version between slaves) log-bin:enabled
Mon Apr 20 14:27:42 2015 - [info] Replicating from 192.168.1.6(192.168.1.6:3306)
Mon Apr 20 14:27:4