MHA 0.58 报错:There is no alive server. We can‘t do failover

MHA 0.58 报错:There is no alive server. We can’t do failover


基于 Centos 7.3 操作系统进行 MySQL 8.0 MHA 高可用搭建,在执行 masterha_check_repl 时遇到报错 There is no alive server. We can't do failover,详细错误信息如下:

[root@mysql8 mha]# masterha_check_repl --conf=/opt/mha/conf/mha.cnf
Thu May  9 10:57:54 2024 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
Thu May  9 10:57:54 2024 - [info] Reading application default configuration from /opt/mha/conf/mha.cnf..
Thu May  9 10:57:54 2024 - [info] Reading server configuration from /opt/mha/conf/mha.cnf..
Thu May  9 10:57:54 2024 - [info] MHA::MasterMonitor version 0.58.
Thu May  9 10:57:55 2024 - [error][/usr/share/perl5/vendor_perl/MHA/ServerManager.pm, ln188] There is no alive server. We can't do failover
Thu May  9 10:57:55 2024 - [error][/usr/share/perl5/vendor_perl/MHA/MasterMonitor.pm, ln427] Error happened on checking configurations.  at /usr/share/perl5/vendor_perl/MHA/MasterMonitor.pm line 329.
Thu May  9 10:57:55 2024 - [error][/usr/share/perl5/vendor_perl/MHA/MasterMonitor.pm, ln525] Error happened on monitoring servers.
Thu May  9 10:57:55 2024 - [info] Got exit code 1 (Not master dead).

本次该问题实际与 mha 用户身份认证插件 caching_sha2_password 有关系。

MySQL 8.0.4 版本中将默认身份认证插件从 mysql_native_password(8.0.34 中废除) 更改为 caching_sha2_password ,并将其作为默认的身份认证机制,同时客户端对应的 libmysqlclient 也默认使用新的认证插件。

临时修改 mha 用户身份认证插件:

mysql> alter user 'admin'@'%' IDENTIFIED WITH 'mysql_native_password' BY 'admin@123';flush privileges;

修改后,再次检查,结果返回正常,如下所示:

[root@mysql8 mha]# masterha_check_repl --conf=/opt/mha/conf/mha.cnf
Thu May  9 16:57:13 2024 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
Thu May  9 16:57:13 2024 - [info] Reading application default configuration from /opt/mha/conf/mha.cnf..
Thu May  9 16:57:13 2024 - [info] Reading server configuration from /opt/mha/conf/mha.cnf..
Thu May  9 16:57:13 2024 - [info] MHA::MasterMonitor version 0.58.
Thu May  9 16:57:14 2024 - [info] GTID failover mode = 1
Thu May  9 16:57:14 2024 - [info] Dead Servers:
Thu May  9 16:57:14 2024 - [info] Alive Servers:
Thu May  9 16:57:14 2024 - [info]   10.101.100.1(10.101.100.1:3306)
Thu May  9 16:57:14 2024 - [info]   10.101.100.12(10.101.100.12:3306)
Thu May  9 16:57:14 2024 - [info] Alive Slaves:
Thu May  9 16:57:14 2024 - [info]   10.101.100.12(10.101.100.12:3306)  Version=8.0.34-26 (oldest major version between slaves) log-bin:enabled
Thu May  9 16:57:14 2024 - [info]     GTID ON
Thu May  9 16:57:14 2024 - [info]     Replicating from 10.10.101.100.1(10.101.100.1:3306)
Thu May  9 16:57:14 2024 - [info]     Primary candidate for the new Master (candidate_master is set)
Thu May  9 16:57:14 2024 - [info] Current Alive Master: 10.101.100.1(10.101.100.1:3306)
Thu May  9 16:57:14 2024 - [info] Checking slave configurations..
Thu May  9 16:57:14 2024 - [info] Checking replication filtering settings..
Thu May  9 16:57:14 2024 - [info]  binlog_do_db= , binlog_ignore_db= 
Thu May  9 16:57:14 2024 - [info]  Replication filtering check ok.
Thu May  9 16:57:14 2024 - [info] GTID (with auto-pos) is supported. Skipping all SSH and Node package checking.
Thu May  9 16:57:14 2024 - [info] Checking SSH publickey authentication settings on the current master..
Thu May  9 16:57:14 2024 - [info] HealthCheck: SSH to 10.101.100.1 is reachable.
Thu May  9 16:57:14 2024 - [info] 
10.101.100.1(10.101.100.1:3306) (current master)
 +--10.101.100.12(10.101.100.12:3306)

Thu May  9 16:57:14 2024 - [info] Checking replication health on 10.101.100.12..
Thu May  9 16:57:14 2024 - [info]  ok.
Thu May  9 16:57:14 2024 - [info] Checking master_ip_failover_script status:
Thu May  9 16:57:14 2024 - [info]   /opt/mha/scripts/master_ip_failover --command=status --ssh_user=root --orig_master_host=10.101.100.1 --orig_master_ip=10.101.100.1 --orig_master_port=3306 

IN SCRIPT TEST====ip addr del /32 dev eth0==ip addr add /32 dev eth0===
status the VIP -  on the master - 10.101.100.1
Thu May  9 16:57:14 2024 - [info]  OK.
Thu May  9 16:57:14 2024 - [warning] shutdown_script is not defined.
Thu May  9 16:57:14 2024 - [info] Got exit code 0 (Not master dead).
MySQL Replication Health is OK.

注:其他原因也包括 mha 用户密码、端口设置等,看问题具体分析。

另外,同样需要注意主从复制用户,在进行 MHA 切换时,也有可能会遇到相同的问题。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值