mysql 的 MHA 高可用集群
目录(1)从宕机崩溃的master保存二进制日志事件(binlog events);
(2)识别含有最新更新的slave;
(3)应用差异的中继日志(relay log)到其他 slave;
(4)应用从master保存的二进制日志事件(binlog events);
(5)提升一个slave为新master;
(6)使其他的slave连接新的master进行复制。
MHA架构
故障模拟
主库失效
备选主库成为主库
原故障主库恢复重新加入到MHA成为从库
实验拓扑
关闭防火墙和selinux
为 Master,slave1,slave2 节点安装mysql 5.7
hostnamectl set-hostname mysql1 #master hostnamectl set-hostname mysql2 #slave1 hostnamectl set-hostname mysql3 #slave2 #修改完之后重新连接 #所有mysql节点配置主机名映射 echo "192.168.23.103 mysql1" >> /etc/hosts echo "192.168.23.12 mysql2" >> /etc/hosts echo "192.168.23.13 mysql3" >> /etc/hosts
Master 节点
[root@mysql1 ~]# vim /etc/my.cnf ........ #将[client],[mysql],[mysqld]部分,字符集编吗注释或者删除 #default-character-set=utf8 .... [mysqld] ...... server-id = 1 log-bin=mysql-bin binlog_format=mixed log-slave-updates=true systemctl restart mysqld
Slave1,Slave2节点
vim /etc/my.cnf ..... #将[client],[mysql],[mysqld]部分,字符集编吗注释或者删除 #default-character-set=utf8 ....... [mysald] ...... server-id = 2 (slave3节点,则server-id=3。三台节点server-id不可重复) log_bin=mysql-bin relay-log=relay-log-bin relay-log-index=slave-relay-bin.index systemctl resart mysqld
这两个软连接必须创建。因为mha是从/usr/sbin/启动mysql
#所有mysql节点都要将 /usr/local/mysql/bin/目录下的执行文件mysql和mysqlbinlog 创建软连接到/usr/sbin [root@mysql03 ~]# ln -s /usr/local/mysql/bin/{mysql,mysqlbinlog} /usr/sbin/ [root@mysql03~ ]# ls /usr/sbin/mysql* /usr/sbin/mysql /usr/sbin/mysqlbinlog
#从库进行同步使用的用户 mysql> grant replication slave on *.* to 'myslave'@'192.168.23.%' identified by 'abc123'; Query OK, 0 rows affected, 1 warning (0.00 sec) #MHA-manager使用 mysql> grant all on *.* to 'mha'@'192.168.23.%' identified by 'abc123'; Query OK, 0 rows affected, 1 warning (0.00 sec) #防止从库通过主机名连接不上主库 mysql> grant all on *.* to 'mha'@'mysql1' identified by 'abc123'; mysql> grant all on *.* to 'mha'@'mysql2' identified by 'abc123'; mysql> grant all on *.* to 'mha'@'mysql3' identified by 'abc123';
mysql> show master status; +------------------+----------+--------------+------------------+-------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set | +------------------+----------+--------------+------------------+-------------------+ | mysql-bin.000009 | 1883 | | | | +------------------+----------+--------------+------------------+-------------------+ 1 row in set (0.00 sec)
mysql> change master to -> master_host='192.168.23.103', -> master_user='myslave', -> master_password='abc123', -> master_log_file='mysql-bin.000009', -> master_log_pos=1883; Query OK, 0 rows affected, 2 warnings (0.02 sec) #启动同步 mysql> start slave; Query OK, 0 rows affected (0.00 sec) #两个slave节点都需要 IO线程和 SQL 线程为yes状态 mysql> show slave status \G ........... Slave_IO_Running: Yes Slave_SQL_Running: Yes .........
#通过全局变量 read_only设置。设置值为1,或者on,表示开启。设置值为0或者off,表示关闭 mysql> set global read_only=1; Query OK, 0 rows affected (0.00 sec) mysql> show global variables like 'read_only'; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | read_only | ON | +---------------+-------+ 1 row in set (0.00 sec)
在master节点插入数据,测试是否同步
mysql> create database test02; Query OK, 1 row affected (0.00 sec) mysql> create table test02.test(id int); Query OK, 0 rows affected (0.01 sec) mysql> insert into test02.test values (1); Query OK, 1 row affected (0.04 sec)
mysql> select * from test02.test; +------+ | id | +------+ | 1 | +------+ 1 row in set (0.00 sec)
yum install epel-release --nogpgcheck -y yum install -y perl-DBD-MySQL \ perl-Config-Tiny \ perl-Log-Dispatch \ perl-Parallel-ForkManager \ perl-ExtUtils-CBuilder \ perl-ExtUtils-MakeMaker \ perl-CPAN
cd /opt/ tar -zxvf mha4mysql-node-0.57.tar.gz cd mha4mysql-node-0.57/ perl Makefile.PL make -j 2 && make install
node组件工具
node组件安装后会在/usr/local/bin下面生成几个脚本文件(这些工具通常由MHA Manager的脚本触发,无需人为操作)主要如下:
● save_binary_logs
保存和复制master的二进制日志
● apply_diff_relay_logs
识别差异的中继日志事件并将其差异的事件应用于其他的slave
● filter_mysqlbinlog
去除不必要的ROLLBACK事件(MHA已不再使用这个工具)
● purge_relay_logs
清除中继日志(不会阻塞SQL线程)
cd /opt/ tar zxvf mha4mysql-manager-0.57.tar.gz cd mha4mysql-manager-0.57/ perl Makefile.PL make -j 2 && make install
manager组件工具
manager组件安装后在/usr/local/bin下面会生成几个工具,主要包括以下几个:
● masterha_check_ssh
检查MHA的SSH配置状况
● masterha_check_repl
检查MySQL复制状况
● masterha_manger
启动manager的脚本
● masterha_check_status
检测当前MHA运行状态
● masterha_master_monitor
检测 master是否宕机
● masterha_master_switch
控制故障转移(自动或者手动)
● masterha_conf_host
添加或删除配置的server信息
● masterha_stop
关闭manager
#创建无密码密钥对 ssh-keygen #将每台主机的密钥对都传递到集群内所有主机上。让它们可以相互免密登录 ssh-copy-id 192.168.23.11 ssh-copy-id 192.168.23.12 ssh-copy-id 192.168.23.13 ssh-copy-id 192.168.23.103
[root@host11 ~]# cp -rp /opt/mha4mysql-manager-0.57/samples/scripts/ \ /usr/local/bin/ [root@host11 ~]# ll /usr/local/bin/scripts/ ...... master_ip_failover #自动切换时vip 管理脚本 ...... master_ip_online_change #在线切换时vip 的管理脚本 ...... power_manager #故障发生后关闭主机的脚本 ...... send_report #因故障切换后返送报警脚本
[root@host11 ~]# cp /usr/local/bin/scripts/master_ip_failover \ /usr/local/bin/
vim /usr/local/bin/master_ip_failover #删除原有内容,直接复制并修改vip相关参数 #!/usr/bin/env perl use strict; use warnings FATAL => 'all'; use Getopt::Long; my ( $command, $ssh_user, $orig_master_host, $orig_master_ip, $orig_master_port, $new_master_host, $new_master_ip, $new_master_port ); #############################添加内容部分######################################### my $vip = '192.168.23.200'; #指定vip地址,修改为自己的网段 my $brdc = '192.168.23.255'; #指定vip的广播地址,修改为自己的网段 my $ifdev = 'ens33'; #指定 vip 绑定的网卡 my $key = '1'; #指定vip绑定的虚拟网卡序列号 my $ssh_start_vip = "/sbin/ifconfig ens33:$key $vip"; my $ssh_stop_vip = "/sbin/ifconfig ens33:$key down"; my $exit_code = 0; #my $ssh_start_vip = "/usr/sbin/ip addr add $vip/24 brd $brdc dev $ifdev label $ifdev:$key;/usr/sbin/arping -q -A -c 1 -I $ifdev $vip;iptables -F;"; #my $ssh_stop_vip = "/usr/sbin/ip addr del $vip/24 dev $ifdev label $ifdev:$key"; ################################################################################## GetOptions( 'command=s' => \$command, 'ssh_user=s' => \$ssh_user, 'orig_master_host=s' => \$orig_master_host, 'orig_master_ip=s' => \$orig_master_ip, 'orig_master_port=i' => \$orig_master_port, 'new_master_host=s' => \$new_master_host, 'new_master_ip=s' => \$new_master_ip, 'new_master_port=i' => \$new_master_port, ); exit &main(); sub main { print "\n\nIN SCRIPT TEST====$ssh_stop_vip==$ssh_start_vip===\n\n"; if ( $command eq "stop" || $command eq "stopssh" ) { my $exit_code = 1; eval { print "Disabling the VIP on old master: $orig_master_host \n"; &stop_vip(); $exit_code = 0; }; if ($@) { warn "Got Error: $@\n"; exit $exit_code; } exit $exit_code; } elsif ( $command eq "start" ) { my $exit_code = 10; eval { print "Enabling the VIP - $vip on the new master - $new_master_host \n"; &start_vip(); $exit_code = 0; }; if ($@) { warn $@; exit $exit_code; } exit $exit_code; } elsif ( $command eq "status" ) { print "Checking the Status of the script.. OK \n"; exit 0; } else { &usage(); exit 1; } } sub start_vip() { `ssh $ssh_user\@$new_master_host \" $ssh_start_vip \"`; } ## A simple system call that disable the VIP on the old_master sub stop_vip() { `ssh $ssh_user\@$orig_master_host \" $ssh_stop_vip \"`; } sub usage { print "Usage: master_ip_failover --command=start|stop|stopssh|status --orig_master_host=host --orig_master_ip=ip --orig_master_port=port --new_master_host=host --new_master_ip=ip --new_master_port=port\n";
这里使用app1.cnf配置文件来管理mysql节点服务器
mkdir /etc/masterha cp /opt/mha4mysql-manager-0.57/samples/conf/app1.cnf /etc/masterha/ vim /etc/masterha/app1.cnf -------删除原有内容,复制一下内容,并修改-------- [server default] #manager日志 manager_log=/var/log/masterha/app1/manager.log #manager工作目录 manager_workdir=/var/log/masterha/app1 #master保存binlog的位置,这里的路径要与master里配置的binlog的路径一致,以便MHA能找到 master_binlog_dir=/usr/local/mysql/data #设置自动failover时候的切换脚本,也就是上面的那个脚本 master_ip_failover_script=/usr/local/bin/master_ip_failover #设置手动切换时候的切换脚本 master_ip_online_change_script=/usr/local/bin/master_ip_online_change #设置mysql中root用户的密码。mysql配置授权用户时,给mha使用的账户密码 password=abc123 #设置监控主库,发送ping包的时间间隔,默认是3秒,尝试三次没有回应的时候自动进行failover ping_interval=1 #设置远端mysql在发生切换时binlog的保存位置 remote_workdir=/tmp #设置复制用户的密码.myslq配置的授权用户,用来主从同步的账户 repl_password=abc123 #设置复制用户的用户 repl_user=myslave #指定检查的从服务器IP地址.有几个,就用-s选项加几个 secondary_check_script=/usr/local/bin/masterha_secondary_check -s 192.168.23.12 -s 192.168.23.13 #设置故障发生后关闭故障主机脚本(该脚本的主要作用是关闭主机防止发生脑裂,这里没有使用) shutdown_script="" #设置ssh的登录用户名 ssh_user=root #设置监控用户root.mysql数据库中配置授权用户时,给mha使用的账户 user=mha [server1] hostname=192.168.23.103 port=3306 [server2] candidate_master=1 check_repl_delay=0 hostname=192.168.23.12 port=3306 [server3] hostname=192.168.23.13 port=3306
candidate_master=1
设置为候选master,设置该参数以后,发生主从切换以后将会将此从库提升为主库,即使这个从库不是集群中最新的slave
check_repl_delay=0
默认情况下如果一个slave落后master 超过100M的relay logs的话,MHA将不会选择该slave作为一个新的master, 因为对于这个slave的恢复需要花费很长时间;通过设置check_repl_delay=0,MHA触发切换在选择一个新的master的时候将会忽略复制延时,这个参数对于设置了candidate_master=1的主机非常有用,因为这个候选主在切换的过程中一定是新的master
第一次配置需要在master节点上手动启动虚拟IP,标签要和master_ip_faioverl配置文件中my $key = '1'; 一样
[root@mysql1 ~]# /sbin/ifconfig ens33:1 192.168.23.200/24
masterha_check_ssh -conf=/etc/masterha/app1.cnf .... #需要都是ok,最后返回 successfully Mon Sep 13 13:14:57 2021 - [debug] Connecting via SSH from root@192.168.23.103(192.168.23.103:22) to root@192.168.23.12(192.168.23.12:22).. Mon Sep 13 13:14:57 2021 - [debug] ok. Mon Sep 13 13:14:57 2021 - [debug] Connecting via SSH from root@192.168.23.103(192.168.23.103:22) to root@192.168.23.13(192.168.23.13:22).. Mon Sep 13 13:14:57 2021 - [debug] ok. Mon Sep 13 13:14:59 2021 - [debug] Mon Sep 13 13:14:58 2021 - [debug] Connecting via SSH from root@192.168.23.13(192.168.23.13:22) to root@192.168.23.103(192.168.23.103:22).. Mon Sep 13 13:14:58 2021 - [debug] ok. Mon Sep 13 13:14:58 2021 - [debug] Connecting via SSH from root@192.168.23.13(192.168.23.13:22) to root@192.168.23.12(192.168.23.12:22).. Mon Sep 13 13:14:59 2021 - [debug] ok. Mon Sep 13 13:14:59 2021 - [debug] Mon Sep 13 13:14:57 2021 - [debug] Connecting via SSH from root@192.168.23.12(192.168.23.12:22) to root@192.168.23.103(192.168.23.103:22).. Mon Sep 13 13:14:58 2021 - [debug] ok. Mon Sep 13 13:14:58 2021 - [debug] Connecting via SSH from root@192.168.23.12(192.168.23.12:22) to root@192.168.23.13(192.168.23.13:22).. Mon Sep 13 13:14:58 2021 - [debug] ok. Mon Sep 13 13:14:59 2021 - [info] All SSH connection tests passed successfully. .....
masterha_check_repl -conf=/etc/masterha/app1.cnf ............. #需要不能有error Mon Sep 13 13:17:51 2021 - [info] Checking replication health on 192.168.23.12.. Mon Sep 13 13:17:51 2021 - [info] ok. Mon Sep 13 13:17:51 2021 - [info] Checking replication health on 192.168.23.13.. Mon Sep 13 13:17:51 2021 - [info] ok. Mon Sep 13 13:17:51 2021 - [info] Checking master_ip_failover_script status: Mon Sep 13 13:17:51 2021 - [info] /usr/local/bin/master_ip_failover --command=status --ssh_user=root --orig_master_host=192.168.23.103 --orig_master_ip=192.168.23.103 --orig_master_port=3306 IN SCRIPT TEST====/sbin/ifconfig ens33:1 down==/sbin/ifconfig ens33:1 192.168.23.200=== Checking the Status of the script.. OK Mon Sep 13 13:17:52 2021 - [info] OK. Mon Sep 13 13:17:52 2021 - [warning] shutdown_script is not defined. Mon Sep 13 13:17:52 2021 - [info] Got exit code 0 (Not master dead). MySQL Replication Health is OK.
[root@host11 ~]# nohup masterha_manager \ --conf=/etc/masterha/app1.cnf \ --remove_dead_master_conf \ --ignore_last_failover < /dev/null > /var/log/masterha/app1/manager.log 2>&1 &
--remove_dead_master_conf:该参数代表当发生主从切换后,老的主库的 ip 将会从配置文件中移除。
--manger_log:日志存放位置。
--ignore_last_failover:在缺省情况下,如果 MHA 检测到连续发生宕机,且两次宕机间隔不足 8 小时的话,则不会进行 Failover, 之所以这样限制是为了避免 ping-pong 效应。该参数代表忽略上次 MHA 触发切换产生的文件,默认情况下,MHA 发生切换后会在日志记目录,也就是上面设置的日志app1.failover.complete文件,下次再次切换的时候如果发现该目录下存在该文件将不允许触发切换,除非在第一次切换后收到删除该文件,为了方便,这里设置为--ignore_last_failover。
查看 MHA 状态,可以看到当前的 master 是 Mysql1 节点
[root@host11 ~]# masterha_check_status --conf=/etc/masterha/app1.cnf #显示当前master为 192.168.23.103 app1 (pid:66809) is running(0:PING_OK), master:192.168.23.103
查看 MHA 日志,也以看到当前的 master 是 192.168.23.103
[root@host11 ~]# cat /var/log/masterha/app1/manager.log | grep "current master" Mon Sep 13 13:22:54 2021 - [info] Checking SSH publickey authentication settings on the current master.. 192.168.23.103(192.168.23.103:3306) (current master)
查看 Mysql1 的 VIP 地址 192.168.23.200 是否存在,这个 VIP 地址不会因为 manager 节点停止 MHA 服务而消失。
[root@mysql1 ~]# ifconfig .... ens33:1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.23.200 netmask 255.255.255.0 broadcast 192.168.23.255 ether 00:0c:29:65:fc:83 txqueuelen 1000 (Ethernet
//若要关闭 manager 服务,可以使用如下命令。
masterha_stop --conf=/etc/masterha/app1.cnf
或者可以直接采用 kill 进程 ID 的方式关闭。
[root@host11 ~]# masterha_stop --conf=/etc/masterha/app1.cnf Stopped app1 successfully.
[root@mysql1 ~]# ifconfig .... ens33:1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.23.200 netmask 255.255.255.0 broadcast 192.168.23.255 ether 00:0c:29:65:fc:83 txqueuelen 1000 (Ethernet
#启动mha服务 [root@host11 ~]# nohup masterha_manager --conf=/etc/masterha/app1.cnf \ --remove_dead_master_conf \ --ignore_last_failover < /dev/null > /var/log/masterha/app1/manager.log 2>&1 & #动态跟踪日志 [root@host11 ~]# tail -f /var/log/masterha/app1/manager.log
[root@mysql1 ~]# systemctl stop mysqld
正常自动切换一次后,MHA 进程会退出。HMA 会自动修改 app1.cnf 文件内容,将宕机的 mysql1 节点删除。查看 mysql2 是否接管 VIP
[root@mysql2 data]# ifconfig
Mon Sep 13 21:13:49 2021 - [info] Executed CHANGE MASTER. Mon Sep 13 21:13:49 2021 - [info] Slave started. Mon Sep 13 21:13:50 2021 - [info] End of log messages from 192.168.23.13. Mon Sep 13 21:13:50 2021 - [info] -- Slave recovery on host 192.168.23.13(192.168.23.13:3306) succeeded. Mon Sep 13 21:13:50 2021 - [info] All new slave servers recovered successfully. Mon Sep 13 21:13:50 2021 - [info] Mon Sep 13 21:13:50 2021 - [info] * Phase 5: New master cleanup phase.. Mon Sep 13 21:13:50 2021 - [info] Mon Sep 13 21:13:50 2021 - [info] Resetting slave info on the new master.. Mon Sep 13 21:13:50 2021 - [info] 192.168.23.12: Resetting slave info succeeded. Mon Sep 13 21:13:50 2021 - [info] Master failover to 192.168.23.12(192.168.23.12:3306) completed successfully. Mon Sep 13 21:13:50 2021 - [info] Deleted server1 entry from /etc/masterha/app1.cnf . Mon Sep 13 21:13:50 2021 - [info] ----- Failover Report ----- app1: MySQL Master failover 192.168.23.103(192.168.23.103:3306) to 192.168.23.12(192.168.23.12:3306) succeeded Master 192.168.23.103(192.168.23.103:3306) is down! Check MHA Manager logs at host11:/var/log/masterha/app1/manager.log for details. Started automated(non-interactive) failover. Invalidated master IP address on 192.168.23.103(192.168.23.103:3306) The latest slave 192.168.23.12(192.168.23.12:3306) has all relay logs for recovery. Selected 192.168.23.12(192.168.23.12:3306) as a new master. 192.168.23.12(192.168.23.12:3306): OK: Applying all logs succeeded. 192.168.23.12(192.168.23.12:3306): OK: Activated master IP address. 192.168.23.13(192.168.23.13:3306): This host has the latest relay log events. Generating relay diff files from the latest slave succeeded. 192.168.23.13(192.168.23.13:3306): OK: Applying all logs succeeded. Slave started, replicating from 192.168.23.12(192.168.23.12:3306) 192.168.23.12(192.168.23.12:3306): Resetting slave info succeeded. Master failover to 192.168.23.12(192.168.23.12:3306) completed successfully.
vim /etc/masterha/app1.cnf
#将故障的mysql1重新启动 [root@mysql1 data]# systemctl start mysqld
先在当前的主库服务器mysql2上查看二进制日志和同步点
#mysql 2上 mysql> show master status; +------------------+----------+--------------+------------------+-------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set | +------------------+----------+--------------+------------------+-------------------+ | mysql-bin.000001 | 154 | | | | +------------------+----------+--------------+------------------+-------------------+ 1 row in set (0.00 sec)
再在原master服务器mysql1上执行同步操作
change master to master_host='192.168.23.12', master_user='myslave', master_password='abc123', master_log_file='mysql-bin.000001', master_log_pos=154; mysql> start slave; Query OK, 0 rows affected (0.01 sec) mysql> show slave status \G #需要看到io线程和sql线程都是yes Slave_IO_Running: Yes Slave_SQL_Running: Yes
vim /etc/masterha/app1.cnf #将server1的配置在添加回去 [server1] hostname=192.168.23.103 port=3306
#启动服务 [root@host11 ~]# nohup masterha_manager --conf=/etc/masterha/app1.cnf \ --remove_dead_master_conf --ignore_last_failover < /dev/null > \ /var/log/masterha/app1/manager.log 2>&1 & #查看状态。显示主是192.168.23.12 [root@host11 ~]# masterha_check_status --conf=/etc/masterha/app1.cnf app1 (pid:69519) is running(0:PING_OK), master:192.168.23.12
(1)MHA集群,故障切换时,vip 漂移到了备用主上,但是slave没有启用成功。MHA日志发现如下信息
Applying all logs succeeded. But starting slave failed.
192.168.23.13(192.168.23.13:3306): This host has the latest relay log events. Generating relay diff files from the latest slave succeeded. 192.168.23.13(192.168.23.13:3306): WARN: Applying all logs succeeded. But starting slave failed. Master failover to 192.168.23.12(192.168.23.12:3306) done, but recovery on slave partially failed. ^C[1]+ 退出 10 nohup masterha_manager --conf=/etc/masterha/app1.cnf --remove_dead_master_conf --ignore_last_failover < /dev/null > /var/log/masterha/app1/manager.log 2>&1
(2) slave 节点进入数据库,使用 show slave status \G,查看从节点状态,发现如下信息。IO线程失败,并且有
Last_IO_Error: Got fatal error 1236 from master when reading data from binary log: 'Could not open log file'
,表示无法打开binlog日志。原因可能是master上面的binlog日志出现问题
Slave_IO_State: Master_Host: 192.168.23.12 Master_User: myslave Master_Port: 3306 Connect_Retry: 60 Master_Log_File: mysql-bin.000001 Read_Master_Log_Pos: 154 Relay_Log_File: relay-log-bin.000002 Relay_Log_Pos: 4 Relay_Master_Log_File: mysql-bin.000001 Slave_IO_Running: No Slave_SQL_Running: Yes 。。。。。 Master_SSL_Verify_Server_Cert: No Last_IO_Errno: 1236 Last_IO_Error: Got fatal error 1236 from master when reading data from binary log: 'Could not open log file'
(3) 来到MHA启用的 master上,使用show master status ;查看主的状态。发现有fie项和 Postion项都有数据。
mysql> show master status; +------------------+----------+--------------+------------------+-------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set | +------------------+----------+--------------+------------------+-------------------+ | mysql-bin.000001 | 154 | | | | +------------------+----------+--------------+------------------+-------------------+
(4) 退出master的数据库,来到mysql的工作目录的date目录下查看,发现没有相应的binlog日志和index索引文件。所以,从才会报错,打开binlog日志失败。这里,我直接就使用了systemctl restart mysqld ,重启服务,生成binlog日志和index索引文件。
也可以在数据库里使用flush logs; 刷新日志。或者 reset master;清除所有二进制日志(会生成01开始的binlog日志)
(5) 修复MHA故障后,在此模拟故障。MHA切换成功