基于MySQL 8.0安装部署MHA集群

一、环境介绍

虚拟机:Oracle VM VirtualBox 5.0.24
操作系统:CentOS Linux release 7.7.1908 (Core)
MySQL服务器:8.0.11 MySQL Community Server - GPL
软件下载地址
主从方式:基于GTID的搭建
主从同步方式:半同步复制
master_ip:192.168.56.101
slave1_ip:192.168.56.103
slave2_ip:192.168.56.105
master主机名:mysql-101
slave1主机名:mysql-103
slave2主机名:mysql-105
master配置文件:/etc/my.cnf

[mysqld]
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
basedir=/usr/local/mysql/mysql-8.0.11
datadir=/data/mysql/
port = 3308
socket = /tmp/mysql.sock
character-set-server=utf8
log-error = /data/mysql/mysqld.log
pid-file = /data/mysql/mysqld.pid
#GTID:
server_id=135                #服务器id
gtid_mode=on                 #开启gtid模式
enforce_gtid_consistency=on  #强制gtid一致性,开启后对于特定create table不被支持
#binlog
log_bin=master-binlog
log-slave-updates=1    
binlog_format=row            #强烈建议,其他格式可能造成数据不一致
#relay log
skip_slave_start=1
max_connect_errors=1000
default_authentication_plugin = 'mysql_native_password'

slave1 配置文件:/etc/my.cnf

[mysqld]
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
basedir=/data/mysql/mysql-8.0.11/
datadir=/data/mysql/mysql8.0_data/
port = 3308
socket = /tmp/mysql-8-0-11.sock
character-set-server=utf8
log-error = /data/mysql/mysql8.0_data/mysqld.log
pid-file = /data/mysql/mysql8.0_data/mysqld.pid
max_connect_errors=1000
#GTID:
gtid_mode=on
enforce_gtid_consistency=on
server_id=144
#binlog
log-bin=slave-binlog
log-slave-updates=1
binlog_format=row      #强烈建议,其他格式可能造成数据不一致
#relay log
skip_slave_start=1
default_authentication_plugin = 'mysql_native_password'

slave2 配置文件:/etc/my.cnf

[mysqld]
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
basedir=/data/mysql/mysql-8.0.11/
datadir=/data/mysql/mysql8.0_data/
port = 3308
socket = /tmp/mysql-8-0-11.sock
character-set-server=utf8
log-error = /data/mysql/mysql8.0_data/mysqld.log
pid-file = /data/mysql/mysql8.0_data/mysqld.pid
#GTID:
gtid_mode=on
enforce_gtid_consistency=on
server_id=143
#binlog
log-bin=slave-binlog
log-slave-updates=1
binlog_format=row      #强烈建议,其他格式可能造成数据不一致
#relay log
skip_slave_start=1

二,检查主从状态

1、主库检查从库状态
show slave hosts;

基于MySQL 8.0安装部署MHA集群_第1张图片

2、从库检查状态

slave1_ip:192.168.56.103

mysql> show slave status\G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 192.168.56.101
                  Master_User: repl
                  Master_Port: 3308
                Connect_Retry: 60
              Master_Log_File: master-binlog.000010
          Read_Master_Log_Pos: 195
               Relay_Log_File: wangbin3-relay-bin.000016
                Relay_Log_Pos: 417
        Relay_Master_Log_File: master-binlog.000010
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB: 
          Replicate_Ignore_DB: 
           Replicate_Do_Table: 
       Replicate_Ignore_Table: 
      Replicate_Wild_Do_Table: 
  Replicate_Wild_Ignore_Table: 
                   Last_Errno: 0
                   Last_Error: 
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 195
              Relay_Log_Space: 668
              Until_Condition: None
               Until_Log_File: 
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_SSL_CA_File: 
           Master_SSL_CA_Path: 
              Master_SSL_Cert: 
            Master_SSL_Cipher: 
               Master_SSL_Key: 
        Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error: 
               Last_SQL_Errno: 0
               Last_SQL_Error: 
  Replicate_Ignore_Server_Ids: 
             Master_Server_Id: 135
                  Master_UUID: 791b77ef-4587-11ea-9571-0800278ffd3d
             Master_Info_File: mysql.slave_master_info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
           Master_Retry_Count: 86400
                  Master_Bind: 
      Last_IO_Error_Timestamp: 
     Last_SQL_Error_Timestamp: 
               Master_SSL_Crl: 
           Master_SSL_Crlpath: 
           Retrieved_Gtid_Set: 791b77ef-4587-11ea-9571-0800278ffd3d:1-11
            Executed_Gtid_Set: 791b77ef-4587-11ea-9571-0800278ffd3d:1-11,
ac073db4-45c7-11ea-b18a-080027e75c4d:1
                Auto_Position: 1
         Replicate_Rewrite_DB: 
                 Channel_Name: 
           Master_TLS_Version: 
       Master_public_key_path: 
        Get_master_public_key: 0
1 row in set (0.00 sec)

slave2_ip:192.168.56.105

mysql> show slave status\G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 192.168.56.101
                  Master_User: repl
                  Master_Port: 3308
                Connect_Retry: 60
              Master_Log_File: master-binlog.000010
          Read_Master_Log_Pos: 195
               Relay_Log_File: wangbin-relay-bin.000013
                Relay_Log_Pos: 417
        Relay_Master_Log_File: master-binlog.000010
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB: 
          Replicate_Ignore_DB: 
           Replicate_Do_Table: 
       Replicate_Ignore_Table: 
      Replicate_Wild_Do_Table: 
  Replicate_Wild_Ignore_Table: 
                   Last_Errno: 0
                   Last_Error: 
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 195
              Relay_Log_Space: 889
              Until_Condition: None
               Until_Log_File: 
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_SSL_CA_File: 
           Master_SSL_CA_Path: 
              Master_SSL_Cert: 
            Master_SSL_Cipher: 
               Master_SSL_Key: 
        Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error: 
               Last_SQL_Errno: 0
               Last_SQL_Error: 
  Replicate_Ignore_Server_Ids: 
             Master_Server_Id: 135
                  Master_UUID: 791b77ef-4587-11ea-9571-0800278ffd3d
             Master_Info_File: mysql.slave_master_info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
           Master_Retry_Count: 86400
                  Master_Bind: 
      Last_IO_Error_Timestamp: 
     Last_SQL_Error_Timestamp: 
               Master_SSL_Crl: 
           Master_SSL_Crlpath: 
           Retrieved_Gtid_Set: 791b77ef-4587-11ea-9571-0800278ffd3d:1-11
            Executed_Gtid_Set: 0b1232b5-4658-11ea-9c94-080027e12091:1-2,
791b77ef-4587-11ea-9571-0800278ffd3d:1-11
                Auto_Position: 1
         Replicate_Rewrite_DB: 
                 Channel_Name: 
           Master_TLS_Version: 
       Master_public_key_path: 
        Get_master_public_key: 0
1 row in set (0.00 sec)

三、关闭防火墙

执行服务器:所有Linux服务器

1、关闭防火墙服务

① 查看防火墙状态命令

systemctl status firewalld.service

注:如下面绿色字体 active (running) 表示防火墙是开启状态
基于MySQL 8.0安装部署MHA集群_第2张图片

② 关闭防火墙并查看防火墙状态

systemctl stop firewalld.service 
systemctl status firewalld.service

可以看到,inactive (dead) 的字样,说明防火墙已经关闭
基于MySQL 8.0安装部署MHA集群_第3张图片
注:前面的方法,一旦重启操作系统,防火墙就自动开启。

③ 禁止防火墙服务重启(永久关闭)

systemctl disable firewalld.service

执行成功,返回结果
在这里插入图片描述

2、关闭防火墙SELinux

① 修改selinux配置文件

使用vim /etc/sysconfig/selinux,将SELINUX=enforcing改为SELINUX=disabled。

② 修改完成后生效

重启计算机 reboot 或 init 6

③ 查看修改后状态

[root@wangbin ~]# sestatus
SELinux status:                 disabled

注:SELinux status 的值为 disabled 时表示 selinux 防火墙关闭。

四、Linux环境准备

三台Linux服务器都必须进行下面的环境准备

1、配置IP与主机名映射

编辑三台Linux服务器 /etc/hosts 文件,添加内容如下:

192.168.56.101 mysql-101
192.168.56.103 mysql-103
192.168.56.105 mysql-105

2、配置Linux服务之间免认证登录

  • 生成免认证密码文件
[root@mysql-101 .ssh]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:t+l7E6FCsoK+IXHbFWDBm9BGW87s72dqUMLWREd7LYQ root@mysql-101
The key's randomart image is:
+---[RSA 2048]----+
|   +=.....o..    |
|  ..+B  ..Eo .   |
|   o.+=o  . o .  |
|    o.=.+  ...   |
|. .. .o*S .. .   |
| o.o..o....o.    |
|..o .. ...o  .   |
| ...   ...o o    |
|  ..   .o+oo .   |
+----[SHA256]-----+
  • 拷贝免登录文件到当前Linux服务器和另外两台Linux服务器
[root@mysql-101 .ssh]# ssh-copy-id -i /root/.ssh/id_rsa [email protected]
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host '192.168.56.101 (192.168.56.101)' can't be established.
ECDSA key fingerprint is SHA256:i/7Zu1z5Rfdw0n44IIBtNfH1UDBiZXk/YxfbaNqGgAM.
ECDSA key fingerprint is MD5:ac:7e:6e:81:6d:e0:45:7e:21:7a:e5:f0:4e:f5:29:c5.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
[email protected]'s password: 

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh '[email protected]'"
and check to make sure that only the key(s) you wanted were added.

[root@mysql-101 .ssh]# ssh-copy-id -i /root/.ssh/id_rsa [email protected]
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host '192.168.56.103 (192.168.56.103)' can't be established.
ECDSA key fingerprint is SHA256:i/7Zu1z5Rfdw0n44IIBtNfH1UDBiZXk/YxfbaNqGgAM.
ECDSA key fingerprint is MD5:ac:7e:6e:81:6d:e0:45:7e:21:7a:e5:f0:4e:f5:29:c5.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
[email protected]'s password: 

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh '[email protected]'"
and check to make sure that only the key(s) you wanted were added.

[root@mysql-101 .ssh]# ssh-copy-id -i /root/.ssh/id_rsa [email protected]
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host '192.168.56.105 (192.168.56.105)' can't be established.
ECDSA key fingerprint is SHA256:VqbHYBYA3aBetOKngcPuoaHOShoFUx+80adb2SqpZ24.
ECDSA key fingerprint is MD5:16:aa:25:6c:1d:31:c2:e5:99:00:43:b5:83:21:ea:94.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
[email protected]'s password: 

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh '[email protected]'"
and check to make sure that only the key(s) you wanted were added.
  • 验证免认证登录是否配置成功
ssh root@192.168.56.101
ssh root@192.168.56.103 
ssh root@192.168.56.105

基于MySQL 8.0安装部署MHA集群_第4张图片
注:上面的三步操作另外两台Linux服务器也必须得执行

3、安装yum扩展包

操作服务器:所有Linux服务器

wget http://mirrors.sohu.com/fedora-epel/epel-release-latest-7.noarch.rpm
yum install -y epel-release-latest-7.noarch.rpm

4、修改 /etc/yum.repos.d/epel.repo 文件参数

操作服务器:所有Linux服务器
把 /etc/yum.repos.d/epel.repo 文件中的 gpgcheck 参数值设置成 0 。

5、安装所需要的依赖包

操作服务器:所有Linux服务器

yum list perl-DBD-MySQL ncftp perl-DBI
yum install -y perl-DBD-MySQL ncftp perl-DBI

6、安装监控服务器依赖包

Linux服务器:slave2

yum install -y perl-Config-Tiny.noarch perl-Time-HiRes.x86_64 perl-Parallel-ForkManager perl-Log-Dispatch.noarch

7、安装MHA软件包

软件包下载地址

  • 安装节点软件包,所有Linux服务器都必须安装
rpm -ivh mha4mysql-node-0.57-0.el7.noarch.rpm
  • 安装监控软件包,只在从库 slave 2上面安装即可

生产环境中监控服务要尽量安装在单独的Linux服务器上面

rpm -ivh mha4mysql-manager-0.57-0.el7.noarch.rpm

五、配置MHA

1、主库创建用户

create user dba_mha@'192.168.56.%' identified by '123456';
grant all privileges on *.* to dba_mha@'192.168.56.%';

2、创建目录

  • masterLinux服务器和 slave1 Linux服务器创建目录
mkdir -p /etc/mha
  • 管理节点(slave2)创建目录
mkdir -p /etc/mha
mkdir -p /home/mha

3、配置管理节点(slave2)的配置文件

vim /etc/mha/mysql-mha.conf
[server default]
user=dba_mha
password=123456
manager_workdir=/home/mha
manager_log=/home/mha/manager.log
remote_workdir=/home/mha
ssh_user=root
repl_user=repl
repl_password=repl
ping_interval=1
master_binlog_dir=/data/mysql
ssh_port=22
master_ip_failover_script = /usr/bin/master_ip_failover
secondary_check_script = /usr/bin/masterha_secondary_check -s 192.168.56.101 -s 192.168.56.103 -s 192.168.56.101
[server1]
hostname=192.168.56.101
candidate_master=1
[server2]
hostname=192.168.56.103
candidate_master=1
[server3]
hostname=192.168.56.105
no_master=1

4、配置管理节点(slave2)的vip漂移配置文件

vim /usr/bin/master_ip_failover
#!/usr/bin/env perl

use strict;
use warnings FATAL => 'all';

use Getopt::Long;

my (
    $command, $orig_master_host, $orig_master_ip,$ssh_user,
    $orig_master_port, $new_master_host, $new_master_ip,$new_master_port,
    $orig_master_ssh_port,$new_master_ssh_port,$new_master_user,$new_master_password
);

my $vip = '192.168.56.110/24';
my $key = '1';
my $ssh_start_vip = "/sbin/ifconfig enp0s3:$key $vip";
my $ssh_stop_vip = "/sbin/ifconfig enp0s3:$key down";
my $ssh_Bcast_arp= "/sbin/arping -I enp0s3 -c 3 -A 192.168.56.110";

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,
    'orig_master_ssh_port=i' => \$orig_master_ssh_port,
    'new_master_host=s'  => \$new_master_host,
    'new_master_ip=s'    => \$new_master_ip,
    'new_master_port=i'  => \$new_master_port,
    'new_master_ssh_port' => \$new_master_ssh_port,
    'new_master_user' => \$new_master_user,
    'new_master_password' => \$new_master_password

);

exit &main();

sub main {
    $ssh_user = defined $ssh_user ? $ssh_user : 'root';
    print "\n\nIN SCRIPT TEST====$ssh_user|$ssh_stop_vip==$ssh_user|$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();
	    &start_arp();
            $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 \"`;
}
sub stop_vip() {
    `ssh $ssh_user\@$orig_master_host \" $ssh_stop_vip \"`;
}

sub start_arp() {
    `ssh $ssh_user\@$new_master_host \" $ssh_Bcast_arp \"`;
}
sub usage {
    print
    "Usage: master_ip_failover --command=start|stop|stopssh|status --ssh_user=user --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";

执行权限设置:chmod +x /usr/bin/master_ip_failover

5、检查ssh配置

[root@mysql-105 mha]# masterha_check_ssh --conf=/etc/mha/mysql-mha.conf
Tue Feb  4 22:10:02 2020 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
Tue Feb  4 22:10:02 2020 - [info] Reading application default configuration from /etc/mha/mysql-mha.conf..
Tue Feb  4 22:10:02 2020 - [info] Reading server configuration from /etc/mha/mysql-mha.conf..
Tue Feb  4 22:10:02 2020 - [info] Starting SSH connection tests..
Tue Feb  4 22:10:04 2020 - [debug] 
Tue Feb  4 22:10:03 2020 - [debug]  Connecting via SSH from root@192.168.56.105(192.168.56.105:22) to root@192.168.56.101(192.168.56.101:22)..
Tue Feb  4 22:10:03 2020 - [debug]   ok.
Tue Feb  4 22:10:03 2020 - [debug]  Connecting via SSH from root@192.168.56.105(192.168.56.105:22) to root@192.168.56.103(192.168.56.103:22)..
Tue Feb  4 22:10:04 2020 - [debug]   ok.
Tue Feb  4 22:10:04 2020 - [debug] 
Tue Feb  4 22:10:02 2020 - [debug]  Connecting via SSH from root@192.168.56.101(192.168.56.101:22) to root@192.168.56.103(192.168.56.103:22)..
Tue Feb  4 22:10:04 2020 - [debug]   ok.
Tue Feb  4 22:10:04 2020 - [debug]  Connecting via SSH from root@192.168.56.101(192.168.56.101:22) to root@192.168.56.105(192.168.56.105:22)..
Tue Feb  4 22:10:04 2020 - [debug]   ok.
Tue Feb  4 22:10:05 2020 - [debug] 
Tue Feb  4 22:10:02 2020 - [debug]  Connecting via SSH from root@192.168.56.103(192.168.56.103:22) to root@192.168.56.101(192.168.56.101:22)..
Tue Feb  4 22:10:04 2020 - [debug]   ok.
Tue Feb  4 22:10:04 2020 - [debug]  Connecting via SSH from root@192.168.56.103(192.168.56.103:22) to root@192.168.56.105(192.168.56.105:22)..
Tue Feb  4 22:10:05 2020 - [debug]   ok.
Tue Feb  4 22:10:05 2020 - [info] All SSH connection tests passed successfully.

出现 All SSH connection tests passed successfully 表示配置成功

6、检查主从复制配置

[root@mysql-105 mha]# masterha_check_repl --conf=/etc/mha/mysql-mha.conf
Tue Feb  4 22:42:22 2020 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
Tue Feb  4 22:42:22 2020 - [info] Reading application default configuration from /etc/mha/mysql-mha.conf..
Tue Feb  4 22:42:22 2020 - [info] Reading server configuration from /etc/mha/mysql-mha.conf..
Tue Feb  4 22:42:22 2020 - [info] MHA::MasterMonitor version 0.57.
Tue Feb  4 22:42:24 2020 - [info] GTID failover mode = 1
Tue Feb  4 22:42:24 2020 - [info] Dead Servers:
Tue Feb  4 22:42:24 2020 - [info] Alive Servers:
Tue Feb  4 22:42:24 2020 - [info]   192.168.56.101(192.168.56.101:3308)
Tue Feb  4 22:42:24 2020 - [info]   192.168.56.103(192.168.56.103:3308)
Tue Feb  4 22:42:24 2020 - [info]   192.168.56.105(192.168.56.105:3308)
Tue Feb  4 22:42:24 2020 - [info] Alive Slaves:
Tue Feb  4 22:42:24 2020 - [info]   192.168.56.103(192.168.56.103:3308)  Version=8.0.11 (oldest major version between slaves) log-bin:enabled
Tue Feb  4 22:42:24 2020 - [info]     GTID ON
Tue Feb  4 22:42:24 2020 - [info]     Replicating from 192.168.56.101(192.168.56.101:3308)
Tue Feb  4 22:42:24 2020 - [info]     Primary candidate for the new Master (candidate_master is set)
Tue Feb  4 22:42:24 2020 - [info]   192.168.56.105(192.168.56.105:3308)  Version=8.0.11 (oldest major version between slaves) log-bin:enabled
Tue Feb  4 22:42:24 2020 - [info]     GTID ON
Tue Feb  4 22:42:24 2020 - [info]     Replicating from 192.168.56.101(192.168.56.101:3308)
Tue Feb  4 22:42:24 2020 - [info]     Not candidate for the new Master (no_master is set)
Tue Feb  4 22:42:24 2020 - [info] Current Alive Master: 192.168.56.101(192.168.56.101:3308)
Tue Feb  4 22:42:24 2020 - [info] Checking slave configurations..
Tue Feb  4 22:42:24 2020 - [info]  read_only=1 is not set on slave 192.168.56.103(192.168.56.103:3308).
Tue Feb  4 22:42:24 2020 - [info]  read_only=1 is not set on slave 192.168.56.105(192.168.56.105:3308).
Tue Feb  4 22:42:24 2020 - [info] Checking replication filtering settings..
Tue Feb  4 22:42:24 2020 - [info]  binlog_do_db= , binlog_ignore_db= 
Tue Feb  4 22:42:24 2020 - [info]  Replication filtering check ok.
Tue Feb  4 22:42:24 2020 - [info] GTID (with auto-pos) is supported. Skipping all SSH and Node package checking.
Tue Feb  4 22:42:24 2020 - [info] Checking SSH publickey authentication settings on the current master..
Tue Feb  4 22:42:25 2020 - [info] HealthCheck: SSH to 192.168.56.101 is reachable.
Tue Feb  4 22:42:25 2020 - [info] 
192.168.56.101(192.168.56.101:3308) (current master)
 +--192.168.56.103(192.168.56.103:3308)
 +--192.168.56.105(192.168.56.105:3308)

Tue Feb  4 22:42:25 2020 - [info] Checking replication health on 192.168.56.103..
Tue Feb  4 22:42:25 2020 - [info]  ok.
Tue Feb  4 22:42:25 2020 - [info] Checking replication health on 192.168.56.105..
Tue Feb  4 22:42:25 2020 - [info]  ok.
Tue Feb  4 22:42:25 2020 - [info] Checking master_ip_failover_script status:
Tue Feb  4 22:42:25 2020 - [info]   /usr/bin/master_ip_failover --command=status --ssh_user=root --orig_master_host=192.168.56.101 --orig_master_ip=192.168.56.101 --orig_master_port=3308 


IN SCRIPT TEST====root|/sbin/ifconfig enp0s3:1 down==root|/sbin/ifconfig enp0s3:1 192.168.56.110/24===

Checking the Status of the script.. OK 
Tue Feb  4 22:42:25 2020 - [info]  OK.
Tue Feb  4 22:42:25 2020 - [warning] shutdown_script is not defined.
Tue Feb  4 22:42:25 2020 - [info] Got exit code 0 (Not master dead).

MySQL Replication Health is OK.

7、master手动执行vip命令

/sbin/ifconfig enp0s3:1 192.168.56.110/24

8、管理节点(slave2) 启动MHA

masterha_manager --conf=/etc/mha/mysql-mha.conf &

你可能感兴趣的:(MySQL)