博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

MHA 报错:There is no alive slave. We can't do failover

Posted on 2017-11-13 21:50  moss_tan_jun  阅读(4540)  评论(0编辑  收藏  举报

dba http://blog.csdn.net/zengxuewen2045/article/details/51524880

 

关于这个错误:

 

在之前的部署文档里:

 

我说需要把server_id,改成10,可以走过去。
其实这是很片面的。

今天又遇到了这个问题,并解决了。

关于该问题,比较靠谱的解释是:
MHA默认去连接MySQL的端口是:3306

如果你的主机名解析,或者你写的IP都没问题,防火墙也关闭了,那么,剩下的原因是:
你的MySQL,没有运行在默认端口上。

如果不能修改MySQL的端口为:3306。

那么你可以给MHA,添加PORT描述。

以下是添加端口描述的MHA应用配置文件的样例:

 

——————————————

 

=================================================

8.MHA架构中的错误

Tue Apr 28 15:15:36 2015 - [error][/usr/local/share/perl5/MHA/ServerManager.pm, ln193] There is no alive slave. We can't do failover
Tue Apr 28 15:15:36 2015 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln383] Error happend on checking configurations.  at /usr/local/share/perl5/MHA/MasterMonitor.pm line 298
Tue Apr 28 15:15:36 2015 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln478] Error happened on monitoring servers.

 

解决方法:

(1).删除健康检查文件  rm -rf /var/log/masterha/app1/app1.master_status.health 
(2).在宕机的数据库中重新同步到主服务器 change master to master_host...............

(3).检查复制是否出错 masterha_check_repl --conf=/etc/mysqlmha/conf/app1.cnf 

 ========================================

主从同步已经打好的情况下执行
grant all privileges on *.* to 'root'@'server01' identified by '123qwe!@#';
grant all privileges on *.* to 'root'@'server02' identified by '123qwe!@#';
grant all privileges on *.* to 'root'@'server03' identified by '123qwe!@#';
grant all privileges on *.* to 'root'@'server04' identified by '123qwe!@#';
flush privileges;
[root@server01 lib]# masterha_check_repl --conf=/etc/masterha/app1.cnf
Tue Jul 12 16:08:08 2016 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
Tue Jul 12 16:08:08 2016 - [info] Reading application default configurations from /etc/masterha/app1.cnf..
Tue Jul 12 16:08:08 2016 - [info] Reading server configurations from /etc/masterha/app1.cnf..
Tue Jul 12 16:08:08 2016 - [info] MHA::MasterMonitor version 0.53.
Tue Jul 12 16:08:08 2016 - [error][/usr/local/share/perl5/MHA/ServerManager.pm, ln193] There is no alive slave. We can't do failover
Tue Jul 12 16:08:08 2016 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln383] Error happend on checking configurations.  at /usr/local/share/perl5/MHA/MasterMonitor.pm line 298
Tue Jul 12 16:08:08 2016 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln478] Error happened on monitoring servers.
Tue Jul 12 16:08:08 2016 - [info] Got exit code 1 (Not master dead).
配置主主复制架构,并设置其中一台为read_only  (set global read_only=1;)