目錄
- 一、MHA概述
-
- 1.1 什麼是MHA?
- 1.2 MHA的組成
- 1.3 MHA有什麼特點?
- 1.4:MHA形成的原因
- 二、MHA實驗
-
- 2.1 實驗環境
- 實驗拓撲
- 實驗步驟
一、MHA概述
1.1 什麼是MHA?
- 一套優秀的MySQL高可用環境下故障切換和主從複制的軟體
- 支援故障切換
- MySQL故障過程中,MHA能做到0-30秒内自動完成故障切換,并且在進行故障切換的過程中,MHA能在最大程度上保證資料的一緻性,以達到真正意義上的高可用
- MHA還提供線上主庫切換的功能,能夠安全地切換目前運作的主庫到一個新的主庫中(通過将從庫提升為主庫),大概0.5-2秒内即可完成
1.2 MHA的組成
- MHA Manager (管理節點):用來接收外部信号,監控下方資料節點的工作狀态
- MHA Node (資料節點):工作的機關,負責具體的工作
1.3 MHA有什麼特點?
- 自動故障切換過程中,MHA試圖從當機的主伺服器上儲存二進制日志,最大程度的保證資料的不丢失
- 使用半同步複制,可以大大降低資料丢失的風險
- 目前MHA支援一主多從架構,最少三台服務,即一主兩從
1.4:MHA形成的原因
傳統mysql主從架構存在單點故障的問題
單點故障,主伺服器當機,則服務挂掉
二、MHA實驗
2.1 實驗環境
VMware軟體
一台centos7.6作為MHA伺服器
三台centos7.6作為主伺服器主備伺服器從伺服器
manager伺服器192.168.200.40
master主伺服器192.168.200.90
slave/master主備/從伺服器192.168.200.80
slave從192.168.200.110
實驗拓撲
實驗步驟
1、配置主從同步
主伺服器
[[email protected] ~]# iptables -F
[[email protected] ~]# setenforce 0
[[email protected] ~]# hostnamectl set-hostname Mysql1
[[email protected] ~]# su
[[email protected] ~]# vim /etc/my.cnf
[client]
port=3306
default-character-set=utf8
socket=/usr/local/mysql/mysql.sock
[mysqld]
user=mysql
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
port=3306
character_set_server=utf8mb4
pid-file=/usr/local/mysql/mysqld.pid
socket=/usr/local/mysql/mysql.sock
server-id=1
log_bin=master-bin
log-slave-updates=ture
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,PIPES_AS_CONCAT,ANSI_QUOTES
[[email protected] ~]# ln -s /usr/local/mysql/bin/mysql /usr/bin/
[[email protected] ~]# ln -s /usr/local/mysql/bin/mysqlbinlog /usr/bin/
[[email protected] ~]# systemctl restart mysqld
[[email protected] ~]# netstat -antp | grep mysqld
tcp6 0 0 :::3306 :::* LISTEN 94409/mysqld
[[email protected] ~]# mysql -uroot -pabc123
mysql> grant replication slave on *.* to 'myslave'@'192.168.200.%' identified by '123';
mysql> grant all privileges on *.* to 'mha'@'192.168.200.%' identified by 'manager';
mysql> flush privileges;
mysql> grant all privileges on *.* to 'mha'@'Mysql1' identified by 'manager';
mysql> grant all privileges on *.* to 'mha'@'Mysql2' identified by 'manager';
mysql> grant all privileges on *.* to 'mha'@'Mysql3' identified by 'manager';
mysql> flush privileges;
mysql> show master status;
+-------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+-------------------+----------+--------------+------------------+-------------------+
| master-bin.000001 | 1899 | | | |
+-------------------+----------+--------------+------------------+-------------------+
主備伺服器
[[email protected] ~]# iptables -F
[[email protected] ~]# setenforce 0
[[email protected] ~]# hostnamectl set-hostname Mysql2
[[email protected] ~]# su
[[email protected] ~]# vim /etc/my.cnf
[client]
port=3306
socket=/usr/local/mysql/mysql.sock
[mysql]
port=3306
default-character-set=utf8mb4
socket=/usr/local/mysql/mysql.sock
[mysqld]
user=mysql
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
port=3306
character_set_server=utf8mb4
pid-file=/usr/local/mysql/mysqld.pid
socket=/usr/local/mysql/mysql.sock
server-id=2
log_bin=master-bin
relay-log=relay-log-bin
relay-log-index=slave-relay-bin.index
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,PIPES_AS_CONCAT,ANSI_QUOTES
[[email protected] ~]# ln -s /usr/local/mysql/bin/mysql /usr/bin/
[[email protected] ~]# ln -s /usr/local/mysql/bin/mysqlbinlog /usr/bin/
[[email protected] ~]# systemctl restart mysqld
[[email protected] ~]# netstat -antp | grep mysqld
tcp6 0 0 :::3306 :::* LISTEN 88672/mysqld
[[email protected] ~]# mysql -uroot -pabc123
mysql> grant replication slave on *.* to 'myslave'@'192.168.200.%' identified by '123';
mysql> grant all privileges on *.* to 'mha'@'192.168.200.%' identified by 'manager';
mysql> flush privileges;
mysql> grant all privileges on *.* to 'mha'@'Mysql1' identified by 'manager';
mysql> grant all privileges on *.* to 'mha'@'Mysql2' identified by 'manager';
mysql> grant all privileges on *.* to 'mha'@'Mysql3' identified by 'manager';
mysql> flush privileges;
mysql> change master to master_host='192.168.200.90',master_user='myslave',master_password='123',master_log_file='master-bin.000001',master_log_pos=1899;
mysql> flush privileges;
mysql> start slave;
mysql> show slave status\G;
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
mysql> set global read_only=1;
mysql> flush privileges;
從伺服器
[[email protected] ~]# iptables -F
[[email protected] ~]# setenforce 0
[[email protected] ~]# hostnamectl set-hostname Mysql3
[[email protected] ~]# su
[[email protected] ~]# vim /etc/my.cnf
[client]
port=3306
socket=/usr/local/mysql/mysql.sock
[mysql]
port=3306
default-character-set=utf8mb4
socket=/usr/local/mysql/mysql.sock
[mysqld]
user=mysql
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
port=3306
character-set-server = utf8mb4
pid-file=/usr/local/mysql/mysqld.pid
socket=/usr/local/mysql/mysql.sock
server-id=3
log_bin=master-bin
relay-log=relay-log-bin
relay-log-index=slave-relay-bin.index
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,PIPES_AS_CONCAT,ANSI_QUOTES
[[email protected] ~]# ln -s /usr/local/mysql/bin/mysql /usr/bin/
[[email protected] ~]# ln -s /usr/local/mysql/bin/mysqlbinlog /usr/bin/
[[email protected] ~]# systemctl restart mysqld
[[email protected] ~]# netstat -antp | grep mysqld
tcp6 0 0 :::3306 :::* LISTEN 90340/mysqld
[[email protected] ~]# mysql -uroot -pabc123
mysql> grant replication slave on *.* to 'myslave'@'192.168.200.%' identified by '123';
mysql> grant all privileges on *.* to 'mha'@'192.168.200.%' identified by 'manager';
mysql> flush privileges;
mysql> grant all privileges on *.* to 'mha'@'Mysql1' identified by 'manager';
mysql> grant all privileges on *.* to 'mha'@'Mysql2' identified by 'manager';
mysql> grant all privileges on *.* to 'mha'@'Mysql3' identified by 'manager';
mysql> flush privileges;
mysql> change master to master_host='192.168.200.90',master_user='myslave',master_password='123',master_log_file='master-bin.000001',master_log_pos=1899;
mysql> flush privileges;
mysql> start slave;
mysql> show slave status\G;
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
mysql> set global read_only=1;
mysql> flush privileges;
主從同步完成,進行驗證,沒問題
2、主從伺服器安裝mha的node檔案,并進行ssh免密登入授權配置
主伺服器
[[email protected] ~]# yum -y install epel-release --nogpgcheck
[[email protected] ~]# yum -y install perl-DBD-MySQL perl-Config-Tiny perl-Log-Dispatch perl-Parallel-ForkManager perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker perl-CPAN
[[email protected] ~]# ls
anaconda-ks.cfg mha4mysql-node-0.58.tar.gz 模闆 文檔 桌面
initial-setup-ks.cfg mysql-boost-5.7.20.tar.gz 視訊 下載下傳
mha4mysql-manager-0.58.tar.gz 公共 圖檔 音樂
[[email protected] ~]# tar zxvf mha4mysql-node-0.58.tar.gz
[[email protected] ~]# ls
anaconda-ks.cfg mha4mysql-node-0.58 公共 圖檔 音樂
initial-setup-ks.cfg mha4mysql-node-0.58.tar.gz 模闆 文檔 桌面
mha4mysql-manager-0.58.tar.gz mysql-boost-5.7.20.tar.gz 視訊 下載下傳
[[email protected] ~]# cd mha4mysql-node-0.58/
[[email protected] mha4mysql-node-0.58]# ls
AUTHORS COPYING inc Makefile.PL META.yml rpm
bin debian lib MANIFEST README t
[[email protected] mha4mysql-node-0.58]# perl Makefile.PL
[[email protected] mha4mysql-node-0.58]# make
[[email protected] mha4mysql-node-0.58]# make install //安裝完成
[[email protected] mha4mysql-node-0.58]# cd ~ //主伺服器設定兩台從伺服器免密登入
[[email protected] ~]# ssh-keygen -t rsa
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:pq5JMOsg65ZZWe83MpKFMf8EGGr5u4SgMIrVqyC2Hwc [email protected]
The key's randomart image is:
+---[RSA 2048]----+
| |
| . |
| o o |
| = = . |
|o.=E= * S |
|=o.*o+ * . |
|O.=ooo* o |
|+O.o+* + + |
|+o+.oo+ + . |
+----[SHA256]-----+
[[email protected] ~]# ssh-copy-id 192.168.200.80 //授權兩台從伺服器免密登入
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host '192.168.200.80 (192.168.200.80)' can't be established.
ECDSA key fingerprint is SHA256:N5nxR2HffZdSxo0zaKcWTafbevqnrjCj2ULe0dVdPa0.
ECDSA key fingerprint is MD5:78:58:0a:09:66:76:ad:7a:02:28:15:2b:f7:57:2c:ef.
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].168.200.80's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh '192.168.200.80'"
and check to make sure that only the key(s) you wanted were added.
[[email protected] ~]# ssh-copy-id 192.168.200.110 //授權
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host '192.168.200.110 (192.168.200.110)' can't be established.
ECDSA key fingerprint is SHA256:eLdHi9BvCNVro0zGiYPq1F+Psfoo9V+9EDIvdZDR8vM.
ECDSA key fingerprint is MD5:2d:34:ae:97:fd:bc:af:4f:e1:6b:92:22:48:4d:69:b4.
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].168.200.110's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh '192.168.200.110'"
and check to make sure that only the key(s) you wanted were added.
主備伺服器配置主從的免密登入
[[email protected] ~]# yum -y install epel-release --nogpgcheck
[[email protected] ~]# yum -y install perl-DBD-MySQL perl-Config-Tiny perl-Log-Dispatch perl-Parallel-ForkManager perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker perl-CPAN
[[email protected] ~]# ls
anaconda-ks.cfg mha4mysql-node-0.58.tar.gz 模闆 文檔 桌面
initial-setup-ks.cfg mysql-boost-5.7.20.tar.gz 視訊 下載下傳
mha4mysql-manager-0.58.tar.gz 公共 圖檔 音樂
[[email protected] ~]# tar zxvf mha4mysql-node-0.58.tar.gz
[[email protected] ~]# ls
anaconda-ks.cfg mha4mysql-node-0.58 公共 圖檔 音樂
initial-setup-ks.cfg mha4mysql-node-0.58.tar.gz 模闆 文檔 桌面
mha4mysql-manager-0.58.tar.gz mysql-boost-5.7.20.tar.gz 視訊 下載下傳
[[email protected] ~]# cd mha4mysql-node-0.58/
[[email protected] mha4mysql-node-0.58]# ls
AUTHORS COPYING inc Makefile.PL META.yml rpm
bin debian lib MANIFEST README t
[[email protected] mha4mysql-node-0.58]# perl Makefile.PL
[[email protected] mha4mysql-node-0.58]# make
[[email protected] mha4mysql-node-0.58]# make install
[[email protected] mha4mysql-node-0.58]# cd ~
[[email protected] ~]# ssh-keygen -t rsa
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:Lsqb7sgFSaGVOVRmGeg8UW9c8q8AjwkHYLHYfnKnSak [email protected]
The key's randomart image is:
+---[RSA 2048]----+
|.=***o. . |
|o+B=.o + |
|o++oo + . |
| o++ B . |
| =.B + S . |
| B + o . |
| E + . o |
| . + o . |
| ooB. |
+----[SHA256]-----+
[[email protected] ~]# ssh-copy-id 192.168.200.90
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host '192.168.200.90 (192.168.200.90)' can't be established.
ECDSA key fingerprint is SHA256:LGVQSrzmeWOjKsn2nM6C187BdfANy9jsFvmzXotxD7M.
ECDSA key fingerprint is MD5:d2:cd:3a:66:ab:05:b8:16:f8:42:4a:88:4c:60:14:b4.
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 '192.168.200.90'"
and check to make sure that only the key(s) you wanted were added.
[[email protected] ~]# ssh-copy-id 192.168.200.110
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host '192.168.200.110 (192.168.200.110)' can't be established.
ECDSA key fingerprint is SHA256:eLdHi9BvCNVro0zGiYPq1F+Psfoo9V+9EDIvdZDR8vM.
ECDSA key fingerprint is MD5:2d:34:ae:97:fd:bc:af:4f:e1:6b:92:22:48:4d:69:b4.
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 '192.168.200.110'"
and check to make sure that only the key(s) you wanted were added.
從伺服器配置主從的免密登入
[[email protected] ~]# yum -y install epel-release --nogpgcheck
[[email protected] ~]# yum -y install perl-DBD-MySQL perl-Config-Tiny perl-Log-Dispatch perl-Parallel-ForkManager perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker perl-CPAN
[[email protected] ~]# ls
anaconda-ks.cfg mha4mysql-node-0.58.tar.gz 模闆 文檔 桌面
initial-setup-ks.cfg mysql-boost-5.7.20.tar.gz 視訊 下載下傳
mha4mysql-manager-0.58.tar.gz 公共 圖檔 音樂
[[email protected] ~]# tar zxvf mha4mysql-node-0.58.tar.gz
[[email protected] ~]# ls
anaconda-ks.cfg mha4mysql-node-0.58 公共 圖檔 音樂
initial-setup-ks.cfg mha4mysql-node-0.58.tar.gz 模闆 文檔 桌面
mha4mysql-manager-0.58.tar.gz mysql-boost-5.7.20.tar.gz 視訊 下載下傳
[[email protected] ~]# cd mha4mysql-node-0.58/
[[email protected] mha4mysql-node-0.58]# ls
AUTHORS COPYING inc Makefile.PL META.yml rpm
bin debian lib MANIFEST README t
[[email protected] mha4mysql-node-0.58]# perl Makefile.PL
[[email protected] mha4mysql-node-0.58]# make
[[email protected] mha4mysql-node-0.58]# make install
[[email protected] mha4mysql-node-0.58]# cd ~
[[email protected] ~]# ssh-keygen -t rsa
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:q4W5zpTErDyE8QrhMxrXlL/BXGMO3fteP2SMELquimk [email protected]
The key's randomart image is:
+---[RSA 2048]----+
| |
| . . . . |
|. . o . = o . |
|.. * * = o o |
|o+o + O S o . o |
|.+o+ o * o . . + |
|. . + * + . + |
| Eo+ + . . . o |
| .o o*.. . o|
+----[SHA256]-----+
[[email protected] ~]# ssh-copy-id 192.168.200.90
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host '192.168.200.90 (192.168.200.90)' can't be established.
ECDSA key fingerprint is SHA256:LGVQSrzmeWOjKsn2nM6C187BdfANy9jsFvmzXotxD7M.
ECDSA key fingerprint is MD5:d2:cd:3a:66:ab:05:b8:16:f8:42:4a:88:4c:60:14:b4.
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].168.200.90's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh '192.168.200.90'"
and check to make sure that only the key(s) you wanted were added.
[[email protected] ~]# ssh-copy-id 192.168.200.80
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host '192.168.200.80 (192.168.200.80)' can't be established.
ECDSA key fingerprint is SHA256:N5nxR2HffZdSxo0zaKcWTafbevqnrjCj2ULe0dVdPa0.
ECDSA key fingerprint is MD5:78:58:0a:09:66:76:ad:7a:02:28:15:2b:f7:57:2c:ef.
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].168.200.80's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh '192.168.200.80'"
and check to make sure that only the key(s) you wanted were added.
3、配置manager伺服器 安裝mha
[[email protected] ~]# iptables -F
[[email protected] ~]# setenforce 0
[[email protected] ~]# hostnamectl set-hostname mha
[[email protected] ~]# su
[[email protected] ~]# yum -y install epel-release --nogpgcheck
[[email protected] ~]# yum -y install perl-DBD-MySQL perl-Config-Tiny perl-Log-Dispatch perl-Parallel-ForkManager perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker perl-CPAN
[[email protected] ~]# ls
anaconda-ks.cfg mha4mysql-node-0.58.tar.gz 模闆 文檔 桌面
initial-setup-ks.cfg mysql-boost-5.7.20.tar.gz 視訊 下載下傳
mha4mysql-manager-0.58.tar.gz 公共 圖檔 音樂
[[email protected] ~]# tar zxvf mha4mysql-node-0.58.tar.gz
[[email protected] ~]# ls
anaconda-ks.cfg mha4mysql-node-0.58 公共 圖檔 音樂
initial-setup-ks.cfg mha4mysql-node-0.58.tar.gz 模闆 文檔 桌面
mha4mysql-manager-0.58.tar.gz mysql-boost-5.7.20.tar.gz 視訊 下載下傳
[[email protected] ~]# cd mha4mysql-node-0.58/
[[email protected] mha4mysql-node-0.58]# ls
AUTHORS COPYING inc Makefile.PL META.yml rpm
bin debian lib MANIFEST README t
[[email protected] mha4mysql-node-0.58]# perl Makefile.PL
[[email protected] mha4mysql-node-0.58]# make
[[email protected] mha4mysql-node-0.58]# make install
[[email protected] mha4mysql-node-0.58]# cd ~
[[email protected] ~]# tar zxvf mha4mysql-manager-0.58.tar.gz
[[email protected] ~]# cd mha4mysql-manager-0.58/
[[email protected] mha4mysql-manager-0.58]# perl Makefile.PL
[[email protected] mha4mysql-manager-0.58]# make
[[email protected] mha4mysql-manager-0.58]# make install
[[email protected] mha4mysql-manager-0.58]# ls /usr/local/bin/ //檢查生成的工具
apply_diff_relay_logs masterha_conf_host masterha_stop
filter_mysqlbinlog masterha_manager purge_relay_logs
masterha_check_repl masterha_master_monitor save_binary_logs
masterha_check_ssh masterha_master_switch
masterha_check_status masterha_secondary_check
[[email protected] mha4mysql-manager-0.58]# ssh-keygen -t rsa //一路回車
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:5Gqwpw8/N22M1P654zTqxzWfaGq3hnfDgw/ORwvqcXI [email protected]
The key's randomart image is:
+---[RSA 2048]----+
| |
| |
| . |
| o |
| . S. |
| o .. . .o. |
| o +. = +=E*oo|
| *. + =*@X.O.|
| ..oo +=*@*=.o|
+----[SHA256]-----+
[[email protected] mha4mysql-manager-0.58]# cd ~
[[email protected] ~]# ls -a
. .bash_history .bashrc .cshrc .ICEauthority mha4mysql-manager-0.58 mha4mysql-node-0.58.tar.gz .tcshrc 公共 圖檔 音樂
.. .bash_logout .cache .dbus initial-setup-ks.cfg mha4mysql-manager-0.58.tar.gz .pki .viminfo 模闆 文檔 桌面
anaconda-ks.cfg .bash_profile .config .esd_auth .local mha4mysql-node-0.58 .ssh .Xauthority 視訊 下載下傳
[[email protected] ~]# cd .ssh/
[[email protected] .ssh]# ls //檢視密鑰對
id_rsa id_rsa.pub
[[email protected] .ssh]# ssh-copy-id 192.168.200.90
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host '192.168.200.80 (192.168.200.80)' can't be established.
ECDSA key fingerprint is SHA256:N5nxR2HffZdSxo0zaKcWTafbevqnrjCj2ULe0dVdPa0.
ECDSA key fingerprint is MD5:78:58:0a:09:66:76:ad:7a:02:28:15:2b:f7:57:2c:ef.
Are you sure you want to continue connecting (yes/no)? yes //填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].168.200.80's password: //輸入root登入密碼
Number of key(s) added: 1
Now try logging into the machine, with: "ssh '192.168.200.90'"
and check to make sure that only the key(s) you wanted were added.
[[email protected] .ssh]# ssh-copy-id 192.168.200.80
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host '192.168.200.80 (192.168.200.80)' can't be established.
ECDSA key fingerprint is SHA256:N5nxR2HffZdSxo0zaKcWTafbevqnrjCj2ULe0dVdPa0.
ECDSA key fingerprint is MD5:78:58:0a:09:66:76:ad:7a:02:28:15:2b:f7:57:2c:ef.
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].168.200.80's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh '192.168.200.80'"
and check to make sure that only the key(s) you wanted were added.
[[email protected] .ssh]# ssh-copy-id 192.168.200.110
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host '192.168.200.110 (192.168.200.110)' can't be established.
ECDSA key fingerprint is SHA256:eLdHi9BvCNVro0zGiYPq1F+Psfoo9V+9EDIvdZDR8vM.
ECDSA key fingerprint is MD5:2d:34:ae:97:fd:bc:af:4f:e1:6b:92:22:48:4d:69:b4.
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].168.200.110's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh '192.168.200.110'"
and check to make sure that only the key(s) you wanted were added.
[[email protected] .ssh]# cp -ra /root/mha4mysql-manager-0.58/samples/scripts/ /usr/local/bin/
[[email protected] .ssh]# ls /usr/local/bin/
apply_diff_relay_logs masterha_check_status masterha_master_switch save_binary_logs
filter_mysqlbinlog masterha_conf_host masterha_secondary_check scripts
masterha_check_repl masterha_manager masterha_stop
masterha_check_ssh masterha_master_monitor purge_relay_logs
[root@mha .ssh]# cd /usr/local/bin/
[[email protected] bin]# cd scripts/
[[email protected] scripts]# ls
master_ip_failover master_ip_online_change power_manager send_report
[[email protected] scripts]# cp /usr/local/bin/scripts/master_ip_failover /usr/local/bin/
[[email protected] scripts]# vim /usr/local/bin/master_ip_failover
my (
$command, $ssh_user, $orig_master_host,
$orig_master_ip, $orig_master_port, $new_master_host,
$new_master_ip, $new_master_port, $new_master_user,
$new_master_password
);
##########寫入下面的内容#################
my $vip = '192.168.200.200';
my $brdc = '192.168.200.255';
my $ifdev = 'ens33';
my $key = '1';
my $ssh_start_vip = "/sbin/ifconfig ens33:$key $vip";
my $ssh_stop_vip = "/sbin/ifconfig ens33:$key down";
my $exit_code = 0;
#################################
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,
'new_master_user=s' => \$new_master_user,
'new_master_password=s' => \$new_master_password,
);
[[email protected] scripts]# mkdir /etc/masterha //建立檔案夾放配置檔案
[[email protected] scripts]# cp /root/mha4mysql-manager-0.58/samples/conf/app1.cnf /etc/masterha/
[[email protected] scripts]# cd /etc/masterha/
app1.cnf
[[email protected] masterha]# vim app1.cnf
[server default]
manager_workdir=/var/log/masterha/app1
manager_log=/var/log/masterha/app1/manager.log
master_binlog_dir=/usr/local/mysql/data/
master_ip_failover_script=/usr/local/bin/master_ip_failover
master_ip_online_change_script=/usr/local/bin/master_ip_online_change
password=manager
user=mha
ping_interval=1
remote_workdir=/tmp
repl_password=123
repl_user=myslave
report_script=/usr/local/send_report
secondary_check_script=/usr/local/bin/masterha_secondary_check -s 192.168.200.80 -s 192.168.200.110
shutdown_script=""
ssh_user=root
[server1]
hostname=192.168.200.90
port=3306
[server2]
hostname=192.168.200.80
port=3306
candidate_master=1
check_repl_delay=0
[server3]
hostname=192.168.200.110
port=3306
[[email protected] masterha]# cd /usr/local/bin/
[[email protected] bin]# ls
apply_diff_relay_logs masterha_check_status masterha_master_switch purge_relay_logs
filter_mysqlbinlog masterha_conf_host masterha_secondary_check save_binary_logs
masterha_check_repl masterha_manager masterha_stop scripts
masterha_check_ssh masterha_master_monitor master_ip_failover
[[email protected] bin]# cd scripts/
[[email protected] scripts]# cp master_ip_online_change ../
[[email protected] scripts]# cd ..
[[email protected] bin]# pwd
/usr/local/bin
[[email protected] bin]# ls
apply_diff_relay_logs masterha_check_status masterha_master_switch master_ip_online_change
filter_mysqlbinlog masterha_conf_host masterha_secondary_check purge_relay_logs
masterha_check_repl masterha_manager masterha_stop save_binary_logs
masterha_check_ssh masterha_master_monitor master_ip_failover scripts
[[email protected] bin]# cd scripts/
[[email protected] scripts]# cp send_report /usr/local/
[[email protected] scripts]# ls /usr/local/
bin etc games include lib lib64 libexec mysql sbin send_report share src
[[email protected] scripts]# masterha_check_ssh -conf=/etc/masterha/app1.cnf //檢測ssh
Mon Aug 31 03:53:38 2020 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
Mon Aug 31 03:53:38 2020 - [info] Reading application default configuration from /etc/masterha/app1.cnf..
Mon Aug 31 03:53:38 2020 - [info] Reading server configuration from /etc/masterha/app1.cnf..
Mon Aug 31 03:53:38 2020 - [info] Starting SSH connection tests..
Mon Aug 31 03:53:40 2020 - [debug]
Mon Aug 31 03:53:38 2020 - [debug] Connecting via SSH from [email protected](192.168.200.80:22) to [email protected](192.168.200.90:22)..
Mon Aug 31 03:53:39 2020 - [debug] ok.
Mon Aug 31 03:53:39 2020 - [debug] Connecting via SSH from [email protected](192.168.200.80:22) to [email protected](192.168.200.110:22)..
Mon Aug 31 03:53:40 2020 - [debug] ok.
Mon Aug 31 03:53:40 2020 - [debug]
Mon Aug 31 03:53:38 2020 - [debug] Connecting via SSH from [email protected](192.168.200.90:22) to [email protected](192.168.200.80:22)..
Mon Aug 31 03:53:39 2020 - [debug] ok.
Mon Aug 31 03:53:39 2020 - [debug] Connecting via SSH from [email protected](192.168.200.90:22) to [email protected](192.168.200.110:22)..
Mon Aug 31 03:53:40 2020 - [debug] ok.
Mon Aug 31 03:53:41 2020 - [debug]
Mon Aug 31 03:53:39 2020 - [debug] Connecting via SSH from [email protected](192.168.200.110:22) to [email protected](192.168.200.90:22)..
Mon Aug 31 03:53:40 2020 - [debug] ok.
Mon Aug 31 03:53:40 2020 - [debug] Connecting via SSH from [email protected](192.168.200.110:22) to [email protected](192.168.200.80:22)..
Mon Aug 31 03:53:41 2020 - [debug] ok.
Mon Aug 31 03:53:41 2020 - [info] All SSH connection tests passed successfully.
[[email protected] ~]# masterha_check_repl -conf=/etc/masterha/app1.cnf
Mon Aug 31 08:45:33 2020 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
Mon Aug 31 08:45:33 2020 - [info] Reading application default configuration from /etc/masterha/app1.cnf..
Mon Aug 31 08:45:33 2020 - [info] Reading server configuration from /etc/masterha/app1.cnf..
Mon Aug 31 08:45:33 2020 - [info] MHA::MasterMonitor version 0.58.
Mon Aug 31 08:45:34 2020 - [info] GTID failover mode = 0
Mon Aug 31 08:45:34 2020 - [info] Dead Servers:
Mon Aug 31 08:45:34 2020 - [info] Alive Servers:
Mon Aug 31 08:45:34 2020 - [info] 192.168.200.90(192.168.200.90:3306)
Mon Aug 31 08:45:34 2020 - [info] 192.168.200.80(192.168.200.80:3306)
Mon Aug 31 08:45:34 2020 - [info] 192.168.200.110(192.168.200.110:3306)
Mon Aug 31 08:45:34 2020 - [info] Alive Slaves:
Mon Aug 31 08:45:34 2020 - [info] 192.168.200.80(192.168.200.80:3306) Version=5.7.20-log (oldest major version between slaves) log-bin:enabled
Mon Aug 31 08:45:34 2020 - [info] Replicating from 192.168.200.90(192.168.200.90:3306)
Mon Aug 31 08:45:34 2020 - [info] Primary candidate for the new Master (candidate_master is set)
Mon Aug 31 08:45:34 2020 - [info] 192.168.200.110(192.168.200.110:3306) Version=5.7.20-log (oldest major version between slaves) log-bin:enabled
Mon Aug 31 08:45:34 2020 - [info] Replicating from 192.168.200.90(192.168.200.90:3306)
Mon Aug 31 08:45:34 2020 - [info] Current Alive Master: 192.168.200.90(192.168.200.90:3306)
Mon Aug 31 08:45:34 2020 - [info] Checking slave configurations..
Mon Aug 31 08:45:34 2020 - [info] read_only=1 is not set on slave 192.168.200.80(192.168.200.80:3306).
Mon Aug 31 08:45:34 2020 - [warning] relay_log_purge=0 is not set on slave 192.168.200.80(192.168.200.80:3306).
Mon Aug 31 08:45:34 2020 - [info] read_only=1 is not set on slave 192.168.200.110(192.168.200.110:3306).
Mon Aug 31 08:45:34 2020 - [warning] relay_log_purge=0 is not set on slave 192.168.200.110(192.168.200.110:3306).
Mon Aug 31 08:45:34 2020 - [info] Checking replication filtering settings..
Mon Aug 31 08:45:34 2020 - [info] binlog_do_db= , binlog_ignore_db=
Mon Aug 31 08:45:34 2020 - [info] Replication filtering check ok.
Mon Aug 31 08:45:34 2020 - [info] GTID (with auto-pos) is not supported
Mon Aug 31 08:45:34 2020 - [info] Starting SSH connection tests..
Mon Aug 31 08:45:38 2020 - [info] All SSH connection tests passed successfully.
Mon Aug 31 08:45:38 2020 - [info] Checking MHA Node version..
Mon Aug 31 08:45:39 2020 - [info] Version check ok.
Mon Aug 31 08:45:39 2020 - [info] Checking SSH publickey authentication settings on the current master..
Mon Aug 31 08:45:39 2020 - [info] HealthCheck: SSH to 192.168.200.90 is reachable.
Mon Aug 31 08:45:40 2020 - [info] Master MHA Node version is 0.58.
Mon Aug 31 08:45:40 2020 - [info] Checking recovery script configurations on 192.168.200.90(192.168.200.90:3306)..
Mon Aug 31 08:45:40 2020 - [info] Executing command: save_binary_logs --command=test --start_pos=4 --binlog_dir=/usr/local/mysql/data/ --output_file=/tmp/save_binary_logs_test --manager_version=0.58 --start_file=master-bin.000003
Mon Aug 31 08:45:40 2020 - [info] Connecting to [email protected](192.168.200.90:22)..
Creating /tmp if not exists.. ok.
Checking output directory is accessible or not..
ok.
Binlog found at /usr/local/mysql/data/, up to master-bin.000003
Mon Aug 31 08:45:40 2020 - [info] Binlog setting check done.
Mon Aug 31 08:45:40 2020 - [info] Checking SSH publickey authentication and checking recovery script configurations on all alive slave servers..
Mon Aug 31 08:45:40 2020 - [info] Executing command : apply_diff_relay_logs --command=test --slave_user='mha' --slave_host=192.168.200.80 --slave_ip=192.168.200.80 --slave_port=3306 --workdir=/tmp --target_version=5.7.20-log --manager_version=0.58 --relay_log_info=/usr/local/mysql/data/relay-log.info --relay_dir=/usr/local/mysql/data/ --slave_pass=xxx
Mon Aug 31 08:45:40 2020 - [info] Connecting to [email protected](192.168.200.80:22)..
Checking slave recovery environment settings..
Opening /usr/local/mysql/data/relay-log.info ... ok.
Relay log found at /usr/local/mysql/data, up to relay-log-bin.000009
Temporary relay log file is /usr/local/mysql/data/relay-log-bin.000009
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.
Mon Aug 31 08:45:41 2020 - [info] Executing command : apply_diff_relay_logs --command=test --slave_user='mha' --slave_host=192.168.200.110 --slave_ip=192.168.200.110 --slave_port=3306 --workdir=/tmp --target_version=5.7.20-log --manager_version=0.58 --relay_log_info=/usr/local/mysql/data/relay-log.info --relay_dir=/usr/local/mysql/data/ --slave_pass=xxx
Mon Aug 31 08:45:41 2020 - [info] Connecting to [email protected].168.200.110(192.168.200.110:22)..
Checking slave recovery environment settings..
Opening /usr/local/mysql/data/relay-log.info ... ok.
Relay log found at /usr/local/mysql/data, up to relay-log-bin.000011
Temporary relay log file is /usr/local/mysql/data/relay-log-bin.000011
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.
Mon Aug 31 08:45:41 2020 - [info] Slaves settings check done.
Mon Aug 31 08:45:41 2020 - [info]
192.168.200.90(192.168.200.90:3306) (current master)
+--192.168.200.80(192.168.200.80:3306)
+--192.168.200.110(192.168.200.110:3306)
Mon Aug 31 08:45:41 2020 - [info] Checking replication health on 192.168.200.80..
Mon Aug 31 08:45:41 2020 - [info] ok.
Mon Aug 31 08:45:41 2020 - [info] Checking replication health on 192.168.200.110..
Mon Aug 31 08:45:41 2020 - [info] ok.
Mon Aug 31 08:45:41 2020 - [info] Checking master_ip_failover_script status:
Mon Aug 31 08:45:41 2020 - [info] /usr/local/bin/master_ip_failover --command=status --ssh_user=root --orig_master_host=192.168.200.90 --orig_master_ip=192.168.200.90 --orig_master_port=3306
IN SCRIPT TEST====/sbin/ifconfig ens33:1 down==/sbin/ifconfig ens33:1 192.168.195.200===
Checking the Status of the script.. OK
Mon Aug 31 08:45:41 2020 - [info] OK.
Mon Aug 31 08:45:41 2020 - [warning] shutdown_script is not defined.
Mon Aug 31 08:45:41 2020 - [info] Got exit code 0 (Not master dead).
MySQL Replication Health is OK. //出現這話就成功了
驗證明驗
[[email protected] ~]# /sbin/ifconfig ens33:1 192.168.200.200/24
[[email protected] ~]# 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 &
[[email protected] ~]# jobs
[1]+ 運作中 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 &
[[email protected] ~]# masterha_check_status --conf=/etc/masterha/app1.cnf
app1 (pid:103931) is running(0:PING_OK), master:192.168.200.90
檢視日志
[[email protected] ~]# cat /var/log/masterha/app1/manager.log
Mon Aug 31 16:46:31 2020 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
Mon Aug 31 16:46:31 2020 - [info] Reading application default configuration from /etc/masterha/app1.cnf..
Mon Aug 31 16:46:31 2020 - [info] Reading server configuration from /etc/masterha/app1.cnf..
Mon Aug 31 16:46:31 2020 - [info] MHA::MasterMonitor version 0.58.
Mon Aug 31 16:46:32 2020 - [info] GTID failover mode = 0
Mon Aug 31 16:46:32 2020 - [info] Dead Servers:
Mon Aug 31 16:46:32 2020 - [info] Alive Servers:
Mon Aug 31 16:46:32 2020 - [info] 192.168.200.90(192.168.200.90:3306)
Mon Aug 31 16:46:32 2020 - [info] 192.168.200.80(192.168.200.80:3306)
Mon Aug 31 16:46:32 2020 - [info] 192.168.200.110(192.168.200.110:3306)
Mon Aug 31 16:46:32 2020 - [info] Alive Slaves:
Mon Aug 31 16:46:32 2020 - [info] 192.168.200.80(192.168.200.80:3306) Version=5.7.20-log (oldest major version between slaves) log-bin:enabled
Mon Aug 31 16:46:32 2020 - [info] Replicating from 192.168.200.90(192.168.200.90:3306)
Mon Aug 31 16:46:32 2020 - [info] Primary candidate for the new Master (candidate_master is set)
Mon Aug 31 16:46:32 2020 - [info] 192.168.200.110(192.168.200.110:3306) Version=5.7.20-log (oldest major version between slaves) log-bin:enabled
Mon Aug 31 16:46:32 2020 - [info] Replicating from 192.168.200.90(192.168.200.90:3306)
Mon Aug 31 16:46:32 2020 - [info] Current Alive Master: 192.168.200.90(192.168.200.90:3306)
Mon Aug 31 16:46:32 2020 - [info] Checking slave configurations..
Mon Aug 31 16:46:32 2020 - [info] read_only=1 is not set on slave 192.168.200.80(192.168.200.80:3306).
Mon Aug 31 16:46:32 2020 - [warning] relay_log_purge=0 is not set on slave 192.168.200.80(192.168.200.80:3306).
Mon Aug 31 16:46:32 2020 - [info] read_only=1 is not set on slave 192.168.200.110(192.168.200.110:3306).
Mon Aug 31 16:46:32 2020 - [warning] relay_log_purge=0 is not set on slave 192.168.200.110(192.168.200.110:3306).
Mon Aug 31 16:46:32 2020 - [info] Checking replication filtering settings..
Mon Aug 31 16:46:32 2020 - [info] binlog_do_db= , binlog_ignore_db=
Mon Aug 31 16:46:32 2020 - [info] Replication filtering check ok.
Mon Aug 31 16:46:32 2020 - [info] GTID (with auto-pos) is not supported
Mon Aug 31 16:46:32 2020 - [info] Starting SSH connection tests..
Mon Aug 31 16:46:34 2020 - [info] All SSH connection tests passed successfully.
Mon Aug 31 16:46:34 2020 - [info] Checking MHA Node version..
Mon Aug 31 16:46:40 2020 - [info] Version check ok.
Mon Aug 31 16:46:40 2020 - [info] Checking SSH publickey authentication settings on the current master..
Mon Aug 31 16:46:40 2020 - [info] HealthCheck: SSH to 192.168.200.90 is reachable.
Mon Aug 31 16:46:41 2020 - [info] Master MHA Node version is 0.58.
Mon Aug 31 16:46:41 2020 - [info] Checking recovery script configurations on 192.168.200.90(192.168.200.90:3306)..
Mon Aug 31 16:46:41 2020 - [info] Executing command: save_binary_logs --command=test --start_pos=4 --binlog_dir=/usr/local/mysql/data/ --output_file=/tmp/save_binary_logs_test --manager_version=0.58 --start_file=master-bin.000003
Mon Aug 31 16:46:41 2020 - [info] Connecting to [email protected].168.200.90(192.168.200.90:22)..
Creating /tmp if not exists.. ok.
Checking output directory is accessible or not..
ok.
Binlog found at /usr/local/mysql/data/, up to master-bin.000003
Mon Aug 31 16:46:41 2020 - [info] Binlog setting check done.
Mon Aug 31 16:46:41 2020 - [info] Checking SSH publickey authentication and checking recovery script configurations on all alive slave servers..
Mon Aug 31 16:46:41 2020 - [info] Executing command : apply_diff_relay_logs --command=test --slave_user='mha' --slave_host=192.168.200.80 --slave_ip=192.168.200.80 --slave_port=3306 --workdir=/tmp --target_version=5.7.20-log --manager_version=0.58 --relay_log_info=/usr/local/mysql/data/relay-log.info --relay_dir=/usr/local/mysql/data/ --slave_pass=xxx
Mon Aug 31 16:46:41 2020 - [info] Connecting to [email protected].168.200.80(192.168.200.80:22)..
Checking slave recovery environment settings..
Opening /usr/local/mysql/data/relay-log.info ... ok.
Relay log found at /usr/local/mysql/data, up to relay-log-bin.000009
Temporary relay log file is /usr/local/mysql/data/relay-log-bin.000009
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.
Mon Aug 31 16:46:41 2020 - [info] Executing command : apply_diff_relay_logs --command=test --slave_user='mha' --slave_host=192.168.200.110 --slave_ip=192.168.200.110 --slave_port=3306 --workdir=/tmp --target_version=5.7.20-log --manager_version=0.58 --relay_log_info=/usr/local/mysql/data/relay-log.info --relay_dir=/usr/local/mysql/data/ --slave_pass=xxx
Mon Aug 31 16:46:41 2020 - [info] Connecting to [email protected].168.200.110(192.168.200.110:22)..
Checking slave recovery environment settings..
Opening /usr/local/mysql/data/relay-log.info ... ok.
Relay log found at /usr/local/mysql/data, up to relay-log-bin.000011
Temporary relay log file is /usr/local/mysql/data/relay-log-bin.000011
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.
Mon Aug 31 16:46:42 2020 - [info] Slaves settings check done.
Mon Aug 31 16:46:42 2020 - [info]
192.168.200.90(192.168.200.90:3306) (current master)
+--192.168.200.80(192.168.200.80:3306)
+--192.168.200.110(192.168.200.110:3306)
Mon Aug 31 16:46:42 2020 - [info] Checking master_ip_failover_script status:
Mon Aug 31 16:46:42 2020 - [info] /usr/local/bin/master_ip_failover --command=status --ssh_user=root --orig_master_host=192.168.200.90 --orig_master_ip=192.168.200.90 --orig_master_port=3306
IN SCRIPT TEST====/sbin/ifconfig ens33:1 down==/sbin/ifconfig ens33:1 192.168.195.200===
Checking the Status of the script.. OK
Mon Aug 31 16:46:42 2020 - [info] OK.
Mon Aug 31 16:46:42 2020 - [warning] shutdown_script is not defined.
Mon Aug 31 16:46:42 2020 - [info] Set master ping interval 1 seconds.
Mon Aug 31 16:46:42 2020 - [info] Set secondary check script: /usr/local/bin/masterha_secondary_check -s 192.168.200.80 -s 192.168.200.110
Mon Aug 31 16:46:42 2020 - [info] Starting ping health check on 192.168.200.90(192.168.200.90:3306)..
Mon Aug 31 16:46:42 2020 - [info] Ping(SELECT) succeeded, waiting until MySQL doesn't respond..
[[email protected] ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.200.90 netmask 255.255.255.0 broadcast 192.168.200.255
inet6 fe80::1084:e6f4:fe54:f1ba prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:6d:45:fd txqueuelen 1000 (Ethernet)
RX packets 708606 bytes 981615983 (936.1 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 169089 bytes 17498433 (16.6 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ens33:1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.200.200 netmask 255.255.255.0 broadcast 192.168.200.255
ether 00:0c:29:6d:45:fd txqueuelen 1000 (Ethernet)
[[email protected] ~]# netstat -antp | grep 3306
tcp6 0 0 :::3306 :::* LISTEN 99814/mysqld
tcp6 0 0 192.168.200.90:3306 192.168.200.110:45866 ESTABLISHED 99814/mysqld
tcp6 0 0 192.168.200.90:3306 192.168.200.80:45212 ESTABLISHED 99814/mysqld
tcp6 0 0 192.168.200.90:3306 192.168.200.40:41568 ESTABLISHED 99814/mysqld
[[email protected] ~]# killall mysqld 幹掉主伺服器
[[email protected] ~]# netstat -antp | grep 3306
tcp6 0 0 192.168.200.90:3306 192.168.200.40:41574 TIME_WAIT -
tcp6 0 0 192.168.200.90:3306 192.168.200.40:41592 TIME_WAIT -
tcp6 0 0 192.168.200.90:3306 192.168.200.40:41586 TIME_WAIT -
tcp6 0 0 192.168.200.90:3306 192.168.200.110:47320 TIME_WAIT -
tcp6 0 0 192.168.200.90:3306 192.168.200.40:41580 TIME_WAIT -
tcp6 0 0 192.168.200.90:3306 192.168.200.80:46696 TIME_WAIT -
[[email protected] ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.200.90 netmask 255.255.255.0 broadcast 192.168.200.255
inet6 fe80::1084:e6f4:fe54:f1ba prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:6d:45:fd txqueuelen 1000 (Ethernet)
RX packets 709796 bytes 981740488 (936.2 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 169926 bytes 17622394 (16.8 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[[email protected] ~]# ifconfig 檢視主備出現VIP
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.200.80 netmask 255.255.255.0 broadcast 192.168.200.255
inet6 fe80::b948:c5a0:c6f:e7b7 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:cd:9a:36 txqueuelen 1000 (Ethernet)
RX packets 682864 bytes 975227981 (930.0 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 378639 bytes 29835335 (28.4 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ens33:1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.195.200 netmask 255.255.255.0 broadcast 192.168.195.255
ether 00:0c:29:cd:9a:36 txqueuelen 1000 (Ethernet)