数据库MHA高可用排错集!!!

一把心酸一把泪

常见错误

#【1 】:Centos7你的manager与node版本一定要是0.57的,不然不兼容,如果你是Centos6,就要用到0.56版本

#【2】 :当你做主从复制时改完 /etc/my.cnf后,restart数据库卡在那边不动时
解决方法:
pkill -9 mysql
pkill -9 mysqld
systemctl restart mysqld

#【3】 :所有的mysql的server-id不能相同,同时client下的字符集要注释掉,不然健康检查过不去


#【4 】 :当你检查你的IO 和 SQL 线程不是两个yes的时候,回头检查你的授权账户和密码,再检查你的主master的二进制文件与位置是否正确
mysql> show slave status\G;
Slave_IO_Running: Yes
Slave_SQL_Running: Yes

#【5】:你将本地源搭建成线网源之后,一定一定要做的是先清空所有源,再加载所有源

#【6】:密钥传输正确后,会输出一个1,不要无脑回车,看清楚

健康检查问题集合

##########从IO线程没有运行###########
Wed Oct 21 05:57:48 2020 - [error][/usr/local/share/perl5/MHA/Server.pm, ln490] Slave IO thread is not running on 20.0.0.24(20.0.0.24:3306)

#解决方法:去看一下你的主从配置是否有问题,如果配置文件等没有问题,restart mysqld 再来测试
#####未能获得master_ip_failover_script状态,返回代码为2:0############
Wed Oct 21 05:59:10 2020 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln229]  Failed to get master_ip_failover_script status with return code 2:0.
Wed Oct 21 05:59:10 2020 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln427] Error happened on checking configurations.  at /usr/local/bin/masterha_check_repl line 48.
Wed Oct 21 05:59:10 2020 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln525] Error happened on monitoring servers.
Wed Oct 21 05:59:10 2020 - [info] Got exit code 1 (Not master dead).

#解决方法:这里你的脚本环境不对,去首行看一下你的环境是不是#开头,还有配置文件一定要顶头写
Thu Aug 23 04:39:01 2018 - [warning]  log-bin is not set on slave 192.168.0.189(192.168.0.189:3306). This host cannot be a master.

Thu Aug 23 04:39:01 2018 - [warning]  log-bin is not set on slave 192.168.0.190(192.168.0.190:3306). This host cannot be a master.

解决办法:

从库的各客户端应开启binlog,即log_bin=on,两个从上都开启

[root@centos7-02 ~]# vi /etc/my.cnf
basedir = /usr/local/mysql
datadir = /data/mysql
socket = /tmp/mysql.sock
server-id=189
log_bin=on
Can't exec "mysqlbinlog": 没有那个文件或目录 at /usr/local/share/perl5/MHA/BinlogManager.pm line 106.
mysqlbinlog version command failed with rc 1:0, please verify PATH, LD_LIBRARY_PATH, and client options
at /usr/local/bin/apply_diff_relay_logs line 493.

解决办法:
#在所有节点上执行如下命令,也就是建立软连接
[root@centos7-01 ~]# ln -s /usr/local/mysql/bin/mysqlbinlog /usr/local/bin/mysqlbinlog
[root@centos7-01 ~]# ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql
[root@centos7-02 ~]# ln -s /usr/local/mysql/bin/mysqlbinlog /usr/local/bin/mysqlbinlog
[root@centos7-02 ~]# ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql
[root@centos7-03 ~]# ln -s /usr/local/mysql/bin/mysqlbinlog /usr/local/bin/mysqlbinlog
[root@centos7-03 ~]# ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql
Thu Aug 23 05:41:59 2018 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln226]  Failed to get master_ip_failover_script status with return code 1:0.
Thu Aug 23 05:41:59 2018 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln424] Error happened on checking configurations.  at /usr/local/bin/masterha_check_repl line 48
Thu Aug 23 05:41:59 2018 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln523] Error happened on monitoring servers.

解决办法:
[root@centos7-04 ~]# vi /etc/masterha/app1.cnf
#master_ip_failover_script= /usr/local/bin/master_ip_failover            //先暂时注释这条选项,后面引入keepalived后和修改该脚本以后再开启该选项
注释:Failover有两种方式:一种是虚拟IP地址,一种是全局配置文件。MHA并没有限定使用哪一种方式,而是让用户自己选择,虚拟IP地址的方式会牵扯到其它的软件,比如keepalive软件,而且还要修改脚本master_ip_failover。
Thu Aug 23 18:17:14 2018 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln424] Error happened on checking configurations. Can't exec "/usr/local/bin/master_ip_failover": 权限不够 at /usr/local/share/perl5/MHA/ManagerUtil.pm line 68.
Thu Aug 23 18:17:14 2018 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln523] Error happened on monitoring servers.

解决办法:
chmod +x /usr/local/bin/master_ip_failover
[error][/usr/local/share/perl5/MHA/ServerManager.pm, ln492]  Server 192.168.0.190(192.168.0.190:3306) is dead, but must be alive! Check server settings.

解决办法:
[root@centos7-04 ~]# rm -rf /var/log/masterha/app1.log/app1.failover.complete        #删除MHA管理机上的这个文件
[error][/usr/local/share/perl5/MHA/ServerManager.pm, ln492]  Server 192.168.0.190(192.168.0.190:3306) is dead, but must be alive! Check server settings.

解决办法:
清除防火墙规则
[error][/usr/local/share/perl5/MHA/ServerManager.pm, ln492]  Server 192.168.0.188(192.168.0.188:3306) is dead, but must be alive! Check server settings.
Fri Aug 24 23:50:37 2018 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln424] Error happened on checking configurations.  at /usr/local/share/perl5/MHA/MasterMonitor.pm line 399

解决办法:
重启主库的mysql服务
[error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln205] Slaves settings check failed!
解决办法:

登陆从数据库,查看主数据库是不是自己设定的
mysql> show slave status\G
Master_Server_Id: 189
[error][/usr/local/share/perl5/MHA/ServerManager.pm, ln781] Multi-master configuration is detected, but two or more masters are either writable (read-only is not set) or dead! Check configurations for details. Master configurations are as below: 
Master 192.168.0.189(192.168.0.189:3306), dead
Master 192.168.0.188(192.168.0.188:3306), replicating from 192.168.0.189(192.168.0.189:3306)

解决办法:
所有从库上执行,只读模式
mysql -uroot -p -e "set global read_only=1"
mysqlbinlog: unknown variable 'default-character-set=utf8'
mysqlbinlog version command failed with rc 7:0, please verify PATH, LD_LIBRARY_PATH, and client options

解决办法:

在所有从服务器上注释掉clinet段default-character-set=utf8mb4
更改默认字符集UTF8到utf8mb4
[client]
#default-character-set = utf8mb4 

猜你喜欢

转载自blog.csdn.net/weixin_48190891/article/details/109221046