MHA 自动切换步骤及过程剖析(二)

2015-07-16 12:09:30 · 作者: · 浏览: 2
b 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:45 2015 - [info] Checking master_ip_failover_script status:
Mon Apr 20 14:27:45 2015 - [info]? /tmp/master_ip_failover --command=status --ssh_user=root --orig_master_host=vdbsrv1
? --orig_master_ip=192.168.1.6 --orig_master_port=3306


IN SCRIPT TEST====/sbin/ifconfig eth0:0 down==/sbin/ifconfig eth0:0 192.168.1.13/24===


Checking the Status of the script.. OK
Mon Apr 20 14:27:45 2015 - [info]? OK.
Mon Apr 20 14:27:45 2015 - [warning] shutdown_script is not defined.
Mon Apr 20 14:27:45 2015 - [info] Set master ping interval 1 seconds.
Mon Apr 20 14:27:45 2015 - [warning] secondary_check_script is not defined. It is highly recommended setting it to check master
? ? ? ? ? reachability from two or more routes.
Mon Apr 20 14:27:45 2015 - [info] Starting ping health check on vdbsrv1(192.168.1.6:3306)..
Mon Apr 20 14:27:45 2015 - [info] Ping(SELECT) succeeded, waiting until MySQL doesn't respond..
Mon Apr 20 14:30:19 2015 - [warning] Got error on MySQL select ping: 2013 (Lost connection to MySQL server during query) ###侦测到错误
Mon Apr 20 14