通过 MHA 0.58 搭建一个数据库集群结构

#给治理端安装mha-manager和mha-node包
[root@mha-manager ~]#yum -y install mha4mysql-node-0.58-0.el7.centos.noarch.rpm
[root@mha-manager ~]#yum -y install mha4mysql-manager-0.58-0.el7.centos.noarch.rpm
#给mysql服务器节点安装mha-node包
[root@master ~]#yum -y install mha4mysql-node-0.58-0.el7.centos.noarch.rpm
[root@slave1 ~]#yum -y install mha4mysql-node-0.58-0.el7.centos.noarch.rpm
[root@slave2 ~]#yum -y install mha4mysql-node-0.58-0.el7.centos.noarch.rpm

#在所有节点之间实现基于key验证
[root@mha-manager ~]#ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Created directory '/root/.ssh'.
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:fTNTrKIR3DWJFNW7fUJsCGz/JuKE7QIgfiSjhWrB/Rc root@mha-manager
The key's randomart image is:
+---[RSA 2048]----+
|         oo++o   |
|       . .=..o.  |
|...     o..o oo. |
|.o=.o  E o  oo=  |
|.+.=..  Soo *+ o |
|o.. .....o+o.+= o|
|.  .  ...+ . o ..|
|        . o      |
|         .       |
+----[SHA256]-----+
[root@mha-manager ~]#rsync -av .ssh 10.0.0.8:
root@10.0.0.80's password: 
sending incremental file list
.ssh/
.ssh/authorized_keys
.ssh/id_rsa
.ssh/id_rsa.pub
.ssh/known_hosts

sent 4,007 bytes  received 96 bytes  1,641.20 bytes/sec
total size is 3,670  speedup is 0.89
[root@mha-manager ~]#rsync -av .ssh 10.0.0.18:
root@10.0.0.81's password: 
sending incremental file list
.ssh/
.ssh/authorized_keys
.ssh/id_rsa
.ssh/id_rsa.pub
.ssh/known_hosts

sent 4,007 bytes  received 96 bytes  1,641.20 bytes/sec
total size is 3,670  speedup is 0.89
[root@mha-manager ~]#rsync -av .ssh 10.0.0.28:
root@10.0.0.28's password: 
sending incremental file list
.ssh/
.ssh/authorized_keys
.ssh/id_rsa
.ssh/id_rsa.pub
.ssh/known_hosts

sent 4,007 bytes  received 96 bytes  1,641.20 bytes/sec
total size is 3,670  speedup is 0.89

#在治理节点确立设置文件
[root@mha-manager ~]#mkdir /etc/mastermha/
[root@mha-manager ~]#vim /etc/mastermha/app1.cnf
[server default]
user=mhauser
password=magedu
manager_workdir=/data/mastermha/app1/
manager_log=/data/mastermha/app1/manager.log
remote_workdir=/data/mastermha/app1/
ssh_user=root
repl_user=repluser
repl_password=magedu
ping_interval=1
master_ip_failover_script=/usr/local/bin/master_ip_failover
report_script=/usr/local/bin/sendmail.sh
check_repl_delay=0
master_binlog_dir=/data/mysql/
[server1]
hostname=10.0.0.8
candidate_master=1    
[server2]
hostname=10.0.0.18
master
[server3]
hostname=10.0.0.28
candidate_master=1

#相关剧本
[root@mha-manager ~]#vim /usr/local/bin/sendmail.sh
echo "MySQL is down" | mail -s "MHA Warning" 1098182702@qq.com
[root@mha-manager ~]#chmod +x /usr/local/bin/sendmail.sh
[root@mha-manager ~]#vim /usr/local/bin/master_ip_failover
#!/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 = '10.0.0.100/24';
my $gateway = '10.0.0.2';
my $interface = 'eth0';
my $key = "1";
my $ssh_start_vip = "/ *** in/ifconfig $interface:$key $vip;/ *** in/arping -I 
$interface -c 3 -s $vip $gateway >/dev/null 2>&1";
my $ssh_stop_vip = "/ *** in/ifconfig $interface:$key down";
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" ) {
# $orig_master_host, $orig_master_ip, $orig_master_port are passed.
# If you manage master ip address at global catalog database,
# invalidate orig_master_ip here.
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" ) {
# all arguments are passed.
# If you manage master ip address at global catalog database,
# activate new_master_ip here.
# You can also grant write access (create user, set read_only=0, etc) here.
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";
`ssh $ssh_user\@$orig_master_host \" $ssh_start_vip \"`;
exit 0;
}
else {
&usage();
exit 1;
}
}
# A simple system call that enable the VIP on the new master
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";
}

[root@mha-manager ~]#chmod +x /usr/local/bin/master_ip_failover

#设置master
[root@master ~]#mkdir /data/mysql
[root@master ~]#chown mysql.mysql /data/mysql/
[root@master ~]#vim /etc/my.cnf.d/mysql-server.cnf
[mysqld]
server-id=8
log-bin=/data/mysql/mysql-bin
skip_name_resolve=1
general_log

[root@master ~]#systemctl start mysqld.service 
[root@master ~]#mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.21 Source distribution

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show master logs;
+------------------+-----------+-----------+
| Log_name         | File_size | Encrypted |
+------------------+-----------+-----------+
| mysql-bin.000001 |       179 | No        |
| mysql-bin.000002 |       156 | No        |
+------------------+-----------+-----------+
2 rows in set (0.00 sec)

mysql> create user repluser@'10.0.0.%' identified by 'magedu';
Query OK, 0 rows affected (0.00 sec)

mysql> grant replication slave on *.* to repluser@'10.0.0.%';
Query OK, 0 rows affected (0.00 sec)

mysql> create user mhauser@'10.0.0.%' identified by 'magedu';
Query OK, 0 rows affected (0.00 sec)

mysql> grant all on *.* to mhauser@'10.0.0.%';
Query OK, 0 rows affected (0.00 sec)

[root@master ~]#ifconfig eth0:1 10.0.0.100/24

#设置slave1
[root@slave1 ~]#mkdir /data/mysql
[root@slave1 ~]#chown mysql.mysql /data/mysql/
[root@slave1 ~]#vim /etc/my.cnf.d/mysql-server.cnf
[mysqld]
server-id=18
log-bin=/data/mysql/mysql-bin
read-only
relay_log_purge=0
skip_name_resolve=1

[root@slave1 ~]#systemctl start mysqld.service 
[root@slave1 ~]#mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.21 Source distribution

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> CHANGE MASTER TO 
    -> MASTER_HOST='10.0.0.8', 
    -> MASTER_USER='repluser', 
    -> MASTER_PASSWORD='magedu', 
    -> MASTER_LOG_FILE='mysql-bin.000002', 
    -> MASTER_LOG_POS=156;
Query OK, 0 rows affected, 2 warnings (0.01 sec)

mysql> start slave;
Query OK, 0 rows affected (0.00 sec)

mysql> show slave status\G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 10.0.0.8
                  Master_User: repluser
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000002
          Read_Master_Log_Pos: 1201
               Relay_Log_File: slave1-relay-bin.000002
                Relay_Log_Pos: 1369
        Relay_Master_Log_File: mysql-bin.000002
             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: 1201
              Relay_Log_Space: 1579
              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: 8
                  Master_UUID: 00db05a9-1074-11eb-abdd-000c2980df3c
             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: 
            Executed_Gtid_Set: 
                Auto_Position: 0
         Replicate_Rewrite_DB: 
                 Channel_Name: 
           Master_TLS_Version: 
       Master_public_key_path: 
        Get_master_public_key: 0
            Network_Namespace: 
1 row in set (0.00 sec)

#设置slave2
[root@slave2 ~]#mkdir /data/mysql
[root@slave2 ~]#chown mysql.mysql /data/mysql
[root@slave2 ~]#vim /etc/my.cnf.d/mysql-server.cnf
[mysqld]
server-id=28
log-bin=/data/mysql/mysql-bin
read-only
relay_log_purge=0
skip_name_resolve=1

[root@slave2 ~]#systemctl start mysqld.service 
[root@slave2 ~]#mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.21 Source distribution

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 
mysql> CHANGE MASTER TO 
    -> MASTER_HOST='10.0.0.8', 
    -> MASTER_USER='repluser', 
    -> MASTER_PASSWORD='magedu', 
    -> MASTER_LOG_FILE='mysql-bin.000002', 
    -> MASTER_LOG_POS=156;
Query OK, 0 rows affected, 2 warnings (0.01 sec)

mysql> start slave;
Query OK, 0 rows affected (0.00 sec)

mysql> show slave status\G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 10.0.0.8
                  Master_User: repluser
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000002
          Read_Master_Log_Pos: 1201
               Relay_Log_File: slave2-relay-bin.000002
                Relay_Log_Pos: 1369
        Relay_Master_Log_File: mysql-bin.000002
             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: 1201
              Relay_Log_Space: 1579
              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: 8
                  Master_UUID: 00db05a9-1074-11eb-abdd-000c2980df3c
             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: 
            Executed_Gtid_Set: 
                Auto_Position: 0
         Replicate_Rewrite_DB: 
                 Channel_Name: 
           Master_TLS_Version: 
       Master_public_key_path: 
        Get_master_public_key: 0
            Network_Namespace: 
1 row in set (0.00 sec)

#检查治理端环境
[root@mha-manager ~]#masterha_check_ssh --conf=/etc/mastermha/app1.cnf
Sat Oct 17 12:37:11 2020 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
Sat Oct 17 12:37:11 2020 - [info] Reading application default configuration from /etc/mastermha/app1.cnf..
Sat Oct 17 12:37:11 2020 - [info] Reading server configuration from /etc/mastermha/app1.cnf..
Sat Oct 17 12:37:11 2020 - [info] Starting SSH connection tests..
Sat Oct 17 12:37:12 2020 - [debug] 
Sat Oct 17 12:37:11 2020 - [debug]  Connecting via SSH from root@10.0.0.8(10.0.0.8:22) to root@10.0.0.18(10.0.0.18:22)..
Sat Oct 17 12:37:11 2020 - [debug]   ok.
Sat Oct 17 12:37:11 2020 - [debug]  Connecting via SSH from root@10.0.0.8(10.0.0.8:22) to root@10.0.0.28(10.0.0.28:22)..
Sat Oct 17 12:37:11 2020 - [debug]   ok.
Sat Oct 17 12:37:12 2020 - [debug] 
Sat Oct 17 12:37:11 2020 - [debug]  Connecting via SSH from root@10.0.0.18(10.0.0.18:22) to root@10.0.0.8(10.0.0.8:22)..
Sat Oct 17 12:37:11 2020 - [debug]   ok.
Sat Oct 17 12:37:11 2020 - [debug]  Connecting via SSH from root@10.0.0.18(10.0.0.18:22) to root@10.0.0.28(10.0.0.28:22)..
Sat Oct 17 12:37:12 2020 - [debug]   ok.
Sat Oct 17 12:37:13 2020 - [debug] 
Sat Oct 17 12:37:12 2020 - [debug]  Connecting via SSH from root@10.0.0.28(10.0.0.28:22) to root@10.0.0.8(10.0.0.8:22)..
Sat Oct 17 12:37:12 2020 - [debug]   ok.
Sat Oct 17 12:37:12 2020 - [debug]  Connecting via SSH from root@10.0.0.28(10.0.0.28:22) to root@10.0.0.18(10.0.0.18:22)..
Sat Oct 17 12:37:12 2020 - [debug]   ok.
Sat Oct 17 12:37:13 2020 - [info] All SSH connection tests passed successfully.

[root@mha-manager ~]#masterha_check_repl --conf=/etc/mastermha/app1.cnf
Sat Oct 17 12:37:43 2020 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
Sat Oct 17 12:37:43 2020 - [info] Reading application default configuration from /etc/mastermha/app1.cnf..
Sat Oct 17 12:37:43 2020 - [info] Reading server configuration from /etc/mastermha/app1.cnf..
Sat Oct 17 12:37:43 2020 - [info] MHA::MasterMonitor version 0.58.
Sat Oct 17 12:37:44 2020 - [info] GTID failover mode = 0
Sat Oct 17 12:37:44 2020 - [info] Dead Servers:
Sat Oct 17 12:37:44 2020 - [info] Alive Servers:
Sat Oct 17 12:37:44 2020 - [info]   10.0.0.8(10.0.0.8:3306)
Sat Oct 17 12:37:44 2020 - [info]   10.0.0.18(10.0.0.18:3306)
Sat Oct 17 12:37:44 2020 - [info]   10.0.0.28(10.0.0.28:3306)
Sat Oct 17 12:37:44 2020 - [info] Alive Slaves:
Sat Oct 17 12:37:44 2020 - [info]   10.0.0.18(10.0.0.18:3306)  Version=8.0.21 (oldest major version between slaves) log-bin:enabled
Sat Oct 17 12:37:44 2020 - [info]     Replicating from 10.0.0.8(10.0.0.8:3306)
Sat Oct 17 12:37:44 2020 - [info]   10.0.0.28(10.0.0.28:3306)  Version=8.0.21 (oldest major version between slaves) log-bin:enabled
Sat Oct 17 12:37:44 2020 - [info]     Replicating from 10.0.0.8(10.0.0.8:3306)
Sat Oct 17 12:37:44 2020 - [info]     Primary candidate for the new Master (candidate_master is set)
Sat Oct 17 12:37:44 2020 - [info] Current Alive Master: 10.0.0.8(10.0.0.8:3306)
Sat Oct 17 12:37:44 2020 - [info] Checking slave configurations..
Sat Oct 17 12:37:44 2020 - [info] Checking replication filtering settings..
Sat Oct 17 12:37:44 2020 - [info]  binlog_do_db= , binlog_ignore_db= 
Sat Oct 17 12:37:44 2020 - [info]  Replication filtering check ok.
Sat Oct 17 12:37:44 2020 - [info] GTID (with auto-pos) is not supported
Sat Oct 17 12:37:44 2020 - [info] Starting SSH connection tests..
Sat Oct 17 12:37:47 2020 - [info] All SSH connection tests passed successfully.
Sat Oct 17 12:37:47 2020 - [info] Checking MHA Node version..
Sat Oct 17 12:37:47 2020 - [info]  Version check ok.
Sat Oct 17 12:37:47 2020 - [info] Checking SSH publickey authentication settings on the current master..
Sat Oct 17 12:37:47 2020 - [info] HealthCheck: SSH to 10.0.0.8 is reachable.
Sat Oct 17 12:37:47 2020 - [info] Master MHA Node version is 0.58.
Sat Oct 17 12:37:47 2020 - [info] Checking recovery script configurations on 10.0.0.8(10.0.0.8:3306)..
Sat Oct 17 12:37:47 2020 - [info]   Executing command: save_binary_logs --command=test --start_pos=4 --binlog_dir=/data/mysql/ --output_file=/data/mastermha/app1//save_binary_logs_test --manager_version=0.58 --start_file=mysql-bin.000002 
Sat Oct 17 12:37:47 2020 - [info]   Connecting to root@10.0.0.8(10.0.0.8:22).. 
  Creating /data/mastermha/app1 if not exists.. Creating directory /data/mastermha/app1.. done.
   ok.
  Checking output directory is accessible or not..
   ok.
  Binlog found at /data/mysql/, up to mysql-bin.000002
Sat Oct 17 12:37:48 2020 - [info] Binlog setting check done.
Sat Oct 17 12:37:48 2020 - [info] Checking SSH publickey authentication and checking recovery script configurations on all alive slave servers..
Sat Oct 17 12:37:48 2020 - [info]   Executing command : apply_diff_relay_logs --command=test --slave_user='mhauser' --slave_host=10.0.0.18 --slave_ip=10.0.0.18 --slave_port=3306 --workdir=/data/mastermha/app1/ --target_version=8.0.21 --manager_version=0.58 --relay_dir=/var/lib/mysql --current_relay_log=slave1-relay-bin.000002  --slave_pass=xxx
Sat Oct 17 12:37:48 2020 - [info]   Connecting to root@10.0.0.18(10.0.0.18:22).. 
Creating directory /data/mastermha/app1/.. done.
  Checking slave recovery environment settings..
    Relay log found at /var/lib/mysql, up to slave1-relay-bin.000002
    Temporary relay log file is /var/lib/mysql/slave1-relay-bin.000002
    Checking if super_read_only is defined and turned on.. not present or turned off, ignoring.
    Testing mysql connection and privileges..
mysql: [Warning] Using a password on the command line interface can be insecure.
 done.
    Testing mysqlbinlog output.. done.
    Cleaning up test file(s).. done.
Sat Oct 17 12:37:48 2020 - [info]   Executing command : apply_diff_relay_logs --command=test --slave_user='mhauser' --slave_host=10.0.0.28 --slave_ip=10.0.0.28 --slave_port=3306 --workdir=/data/mastermha/app1/ --target_version=8.0.21 --manager_version=0.58 --relay_dir=/var/lib/mysql --current_relay_log=slave2-relay-bin.000002  --slave_pass=xxx
Sat Oct 17 12:37:48 2020 - [info]   Connecting to root@10.0.0.28(10.0.0.28:22).. 
Creating directory /data/mastermha/app1/.. done.
  Checking slave recovery environment settings..
    Relay log found at /var/lib/mysql, up to slave2-relay-bin.000002
    Temporary relay log file is /var/lib/mysql/slave2-relay-bin.000002
    Checking if super_read_only is defined and turned on.. not present or turned off, ignoring.
    Testing mysql connection and privileges..
mysql: [Warning] Using a password on the command line interface can be insecure.
 done.
    Testing mysqlbinlog output.. done.
    Cleaning up test file(s).. done.
Sat Oct 17 12:37:48 2020 - [info] Slaves settings check done.
Sat Oct 17 12:37:48 2020 - [info] 
10.0.0.8(10.0.0.8:3306) (current master)
 +--10.0.0.18(10.0.0.18:3306)
 +--10.0.0.28(10.0.0.28:3306)

Sat Oct 17 12:37:48 2020 - [info] Checking replication health on 10.0.0.18..
Sat Oct 17 12:37:48 2020 - [info]  ok.
Sat Oct 17 12:37:48 2020 - [info] Checking replication health on 10.0.0.28..
Sat Oct 17 12:37:48 2020 - [info]  ok.
Sat Oct 17 12:37:48 2020 - [info] Checking master_ip_failover_script status:
Sat Oct 17 12:37:48 2020 - [info]   /usr/local/bin/master_ip_failover --command=status --ssh_user=root --orig_master_host=10.0.0.8 --orig_master_ip=10.0.0.8 --orig_master_port=3306 

IN SCRIPT TEST====/ *** in/ifconfig eth0:1 down==/ *** in/ifconfig eth0:1 10.0.0.100/24;/ *** in/arping -I
eth0 -c 3 -s 10.0.0.100/24 10.0.0.2 >/dev/null 2>&1===

Checking the Status of the script.. OK 
/ *** in/arping: option requires an argument -- 'I'
Usage: arping [-fqbDUAV] [-c count] [-w timeout] [-I device] [-s source] destination
  -f : quit on first reply
  -q : be quiet
  -b : keep broadcasting, don't go unicast
  -D : duplicate address detection mode
  -U : Unsolicited ARP mode, update your neighbours
  -A : ARP answer mode, update your neighbours
  -V : print version and exit
  -c count : how many packets to send
  -w timeout : how long to wait for a reply
  -I device : which ethernet device to use
  -s source : source ip address
  destination : ask for what ip address
Sat Oct 17 12:37:48 2020 - [info]  OK.
Sat Oct 17 12:37:48 2020 - [warning] shutdown_script is not defined.
Sat Oct 17 12:37:48 2020 - [info] Got exit code 0 (Not master dead).

MySQL Replication Health is OK.

[root@mha-manager ~]#masterha_check_status --conf=/etc/mastermha/app1.cnf
app1 is stopped(2:NOT_RUNNING).

#启动mha
[root@mha-manager ~]#masterha_manager --conf=/etc/mastermha/app1.cnf
Sat Oct 17 12:39:09 2020 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
Sat Oct 17 12:39:09 2020 - [info] Reading application default configuration from /etc/mastermha/app1.cnf..
Sat Oct 17 12:39:09 2020 - [info] Reading server configuration from /etc/mastermha/app1.cnf..

[root@master ~]#tail -f /var/lib/mysql/master.log 
2020-10-17T12:41:33.799439Z    15 Query SELECT 1 As Value
2020-10-17T12:41:34.800094Z    15 Query SELECT 1 As Value
2020-10-17T12:41:35.800754Z    15 Query SELECT 1 As Value
2020-10-17T12:41:36.802357Z    15 Query SELECT 1 As Value
2020-10-17T12:41:37.802221Z    15 Query SELECT 1 As Value
2020-10-17T12:41:38.802487Z    15 Query SELECT 1 As Value
2020-10-17T12:41:39.803444Z    15 Query SELECT 1 As Value
2020-10-17T12:41:40.804324Z    15 Query SELECT 1 As Value

[root@mha-manager ~]#masterha_check_status --conf=/etc/mastermha/app1.cnf
app1 (pid:12292) is running(0:PING_OK), master:10.0.0.8

#模拟故障
[root@mha-manager ~]#masterha_manager --conf=/etc/mastermha/app1.cnf
Sat Oct 17 12:39:09 2020 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
Sat Oct 17 12:39:09 2020 - [info] Reading application default configuration from /etc/mastermha/app1.cnf..
Sat Oct 17 12:39:09 2020 - [info] Reading server configuration from /etc/mastermha/app1.cnf..
Sat Oct 17 12:44:19 2020 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
Sat Oct 17 12:44:19 2020 - [info] Reading application default configuration from /etc/mastermha/app1.cnf..
Sat Oct 17 12:44:19 2020 - [info] Reading server configuration from /etc/mastermha/app1.cnf..
[root@mha-manager ~]#

[root@mha-manager ~]#masterha_check_status --conf=/etc/mastermha/app1.cnf
app1 is stopped(2:NOT_RUNNING).

[root@slave2 ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 00:0c:29:5c:a0:c5 brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.28/24 brd 10.0.0.255 scope global noprefixroute eth0
       valid_lft forever preferred_lft forever
    inet 10.0.0.100/24 brd 10.0.0.255 scope global secondary eth0:1
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fe5c:a0c5/64 scope link 
       valid_lft forever preferred_lft forever