mysql mha故障切换_关于MHA故障切换的问题

老师,我根据视频,配置好了 1主2从的 3台mysql服务器,

ip 为 192.168.200.1 ,192.168.200.2 ,192.168.200.3

还有一台单独弄成管理服务 192.168.200.100 ,总共4台虚拟机~

主从配置也配好了, 主为192.168.200.1 从为剩下的两台

MHA也都按照要求所有依赖包都安装了,

ssh 账号我没有使用root ,用的当前账号vagrant

启动后 使用:

[vagrant@manager mha]$ masterha_check_ssh --conf=/etc/mha/mysql-mha.conf

Thu Apr 30 14:50:20 2020 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.

Thu Apr 30 14:50:20 2020 - [info] Reading application default configuration from /etc/mha/mysql-mha.conf..

Thu Apr 30 14:50:20 2020 - [info] Reading server configuration from /etc/mha/mysql-mha.conf..

Thu Apr 30 14:50:20 2020 - [info] Starting SSH connection tests..

Thu Apr 30 14:50:23 2020 - [debug]

Thu Apr 30 14:50:20 2020 - [debug] Connecting via SSH from vagrant@192.168.200.2(192.168.200.2:22) to vagrant@192.168.200.1(192.168.200.1:22)..

Thu Apr 30 14:50:22 2020 - [debug] ok.

Thu Apr 30 14:50:22 2020 - [debug] Connecting via SSH from vagrant@192.168.200.2(192.168.200.2:22) to vagrant@192.168.200.3(192.168.200.3:22)..

Thu Apr 30 14:50:23 2020 - [debug] ok.

Thu Apr 30 14:50:23 2020 - [debug]

Thu Apr 30 14:50:20 2020 - [debug] Connecting via SSH from vagrant@192.168.200.1(192.168.200.1:22) to vagrant@192.168.200.2(192.168.200.2:22)..

Thu Apr 30 14:50:21 2020 - [debug] ok.

Thu Apr 30 14:50:21 2020 - [debug] Connecting via SSH from vagrant@192.168.200.1(192.168.200.1:22) to vagrant@192.168.200.3(192.168.200.3:22)..

Thu Apr 30 14:50:22 2020 - [debug] ok.

Thu Apr 30 14:50:24 2020 - [debug]

Thu Apr 30 14:50:21 2020 - [debug] Connecting via SSH from vagrant@192.168.200.3(192.168.200.3:22) to vagrant@192.168.200.1(192.168.200.1:22)..

Thu Apr 30 14:50:22 2020 - [debug] ok.

Thu Apr 30 14:50:22 2020 - [debug] Connecting via SSH from vagrant@192.168.200.3(192.168.200.3:22) to vagrant@192.168.200.2(192.168.200.2:22)..

Thu Apr 30 14:50:24 2020 - [debug] ok.

Thu Apr 30 14:50:24 2020 - [info] All SSH connection tests passed successfully.

[vagrant@manager mha]$ masterha_check_repl --conf=/etc/mha/mysql-mha.conf

Thu Apr 30 14:52:56 2020 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.

Thu Apr 30 14:52:56 2020 - [info] Reading application default configuration from /etc/mha/mysql-mha.conf..

Thu Apr 30 14:52:56 2020 - [info] Reading server configuration from /etc/mha/mysql-mha.conf..

Thu Apr 30 14:52:56 2020 - [info] MHA::MasterMonitor version 0.58.

Thu Apr 30 14:52:57 2020 - [info] GTID failover mode = 1

Thu Apr 30 14:52:57 2020 - [info] Dead Servers:

Thu Apr 30 14:52:57 2020 - [info] Alive Servers:

Thu Apr 30 14:52:57 2020 - [info] 192.168.200.1(192.168.200.1:3306)

Thu Apr 30 14:52:57 2020 - [info] 192.168.200.2(192.168.200.2:3306)

Thu Apr 30 14:52:57 2020 - [info] 192.168.200.3(192.168.200.3:3306)

Thu Apr 30 14:52:57 2020 - [info] Alive Slaves:

Thu Apr 30 14:52:57 2020 - [info] 192.168.200.2(192.168.200.2:3306) Version=8.0.20 (oldest major version between slaves) log-bin:enabled

Thu Apr 30 14:52:57 2020 - [info] GTID ON

Thu Apr 30 14:52:57 2020 - [info] Replicating from 192.168.200.1(192.168.200.1:3306)

Thu Apr 30 14:52:57 2020 - [info] Primary candidate for the new Master (candidate_master is set)

Thu Apr 30 14:52:57 2020 - [info] 192.168.200.3(192.168.200.3:3306) Version=8.0.20 (oldest major version between slaves) log-bin:enabled

Thu Apr 30 14:52:57 2020 - [info] GTID ON

Thu Apr 30 14:52:57 2020 - [info] Replicating from 192.168.200.1(192.168.200.1:3306)

Thu Apr 30 14:52:57 2020 - [info] Not candidate for the new Master (no_master is set)

Thu Apr 30 14:52:57 2020 - [info] Current Alive Master: 192.168.200.1(192.168.200.1:3306)

Thu Apr 30 14:52:57 2020 - [info] Checking slave configurations..

Thu Apr 30 14:52:57 2020 - [info] read_only=1 is not set on slave 192.168.200.2(192.168.200.2:3306).

Thu Apr 30 14:52:57 2020 - [info] read_only=1 is not set on slave 192.168.200.3(192.168.200.3:3306).

Thu Apr 30 14:52:57 2020 - [info] Checking replication filtering settings..

Thu Apr 30 14:52:57 2020 - [info] binlog_do_db= , binlog_ignore_db=

Thu Apr 30 14:52:57 2020 - [info] Replication filtering check ok.

Thu Apr 30 14:52:57 2020 - [info] GTID (with auto-pos) is supported. Skipping all SSH and Node package checking.

Thu Apr 30 14:52:57 2020 - [info] Checking SSH publickey authentication settings on the current master..

Thu Apr 30 14:52:58 2020 - [info] HealthCheck: SSH to 192.168.200.1 is reachable.

Thu Apr 30 14:52:58 2020 - [info]

192.168.200.1(192.168.200.1:3306) (current master)

+--192.168.200.2(192.168.200.2:3306)

+--192.168.200.3(192.168.200.3:3306)

Thu Apr 30 14:52:58 2020 - [info] Checking replication health on 192.168.200.2..

Thu Apr 30 14:52:58 2020 - [info] ok.

Thu Apr 30 14:52:58 2020 - [info] Checking replication health on 192.168.200.3..

Thu Apr 30 14:52:58 2020 - [info] ok.

Thu Apr 30 14:52:58 2020 - [info] Checking master_ip_failover_script status:

Thu Apr 30 14:52:58 2020 - [info] /usr/bin/master_ip_failover --command=status --ssh_user=vagrant --orig_master_host=192.168.200.1 --orig_master_ip=192.168.200.1 --orig_master_port=3306

IN SCRIPT TEST====sudo /sbin/ifconfig eth1:1 down==sudo /sbin/ifconfig eth1:1 192.168.200.10/24===

Checking the Status of the script.. OK

Thu Apr 30 14:52:58 2020 - [info] OK.

Thu Apr 30 14:52:58 2020 - [warning] shutdown_script is not defined.

Thu Apr 30 14:52:58 2020 - [info] Got exit code 0 (Not master dead).

MySQL Replication Health is OK.

我试着把主的mysql停掉, 发现没有切换到 192.168.200.2 ,发现 mysql-mha.master_status.health :

[vagrant@manager mha]$ cat mysql-mha.master_status.health

2697920:PING_FAILINGmaster:192.168.200.1

还有manager.log 一直重复输出这一段:

Thu Apr 30 14:56:05 2020 - [warning] Got error on MySQL connect: 2003 (Can't connect to MySQL server on '192.168.200.1' (111))

Thu Apr 30 14:56:05 2020 - [warning] Connection failed 2 time(s)..

Thu Apr 30 14:56:06 2020 - [warning] Got error on MySQL connect: 2003 (Can't connect to MySQL server on '192.168.200.1' (111))

Thu Apr 30 14:56:06 2020 - [warning] Connection failed 3 time(s)..

Thu Apr 30 14:56:07 2020 - [warning] Got error on MySQL connect: 2003 (Can't connect to MySQL server on '192.168.200.1' (111))

Thu Apr 30 14:56:07 2020 - [warning] Connection failed 4 time(s)..

Thu Apr 30 14:56:07 2020 - [warning] Secondary network check script returned errors. Failover should not start so checking server status again. Check network settings for details.

Thu Apr 30 14:56:08 2020 - [warning] Got error on MySQL connect: 2003 (Can't connect to MySQL server on '192.168.200.1' (111))

Thu Apr 30 14:56:08 2020 - [warning] Connection failed 1 time(s)..

Thu Apr 30 14:56:08 2020 - [info] Executing SSH check script: exit 0

Thu Apr 30 14:56:08 2020 - [info] Executing secondary network check script: /usr/bin/masterha_secondary_check -s 192.168.200.1 -s 192.168.200.2 -s 192.168.200.3 --user=vagrant --master_host=192.168.200.1 --master_ip=192.168.200.1 --master_port=3306 --master_user=dba_mha --master_password=123456 --ping_type=SELECT

Thu Apr 30 14:56:08 2020 - [warning] HealthCheck: SSH to 192.168.200.1 is NOT reachable.

Permission denied (publickey,gssapi-keyex,gssapi-with-mic).^M

Monitoring server 192.168.200.1 is NOT reachable!

Thu Apr 30 14:56:08 2020 - [warning] At least one of monitoring servers is not reachable from this script. This is likely a network problem. Failover should not happen.

看着像是报错我SSH连接问题,但是我4台服务器,我都手动测试了 ssh vagrant@192.168.200.% 这种形式,都能连接成功,前面ssh检查也成功, 谷歌百度也查不到资料~ 不知道哪儿出问题了

/etc/mha/mysq-mha.conf

[server default]

user=dba_mha

password=123456

ssh_user=vagrant

ssh_port=22

repl_user=repl

repl_password=123456

manager_workdir=/home/vagrant/mha

manager_log=/home/vagrant/mha/manager.log

remote_workdir=/home/vagrant/mha

ping_interval=1

master_binlog_dir=/var/log/mysql

master_ip_failover_script=/usr/bin/master_ip_failover

secondary_check_script=/usr/bin/masterha_secondary_check -s 192.168.200.1 -s 192.168.200.2 -s 192.168.200.3

[server1]

hostname=192.168.200.1

[server2]

hostname=192.168.200.2

candidate_master=1

[server3]

hostname=192.168.200.3

no_master=1

其他都跟视频里一样的

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值