MHA报错记录整理
masterha_check_repl--conf=/etc/masterha/default.cnf
[warning] Global configuration file/etc/masterha_default.cnf not found. Skipping.
[info] Reading application default configuration from/etc/masterha/app1.cnf..
[info] Reading server configuration from/etc/masterha/default.cnf..
[info] MHA::MasterMonitor version 0.56.
[error][/usr/local/share/perl5/MHA/Server.pm,ln303] Getting relay log directory orcurrent relay logfile from replication table failed on192.168.121.1630(192.168.121.163:3306)!
[error][/usr/local/share/perl5/MHA/MasterMonitor.pm,ln424] Error happened on checking configurations. at /usr/local/share/perl5/MHA/ServerManager.pmline 315
[error][/usr/local/share/perl5/MHA/MasterMonitor.pm,ln523] Error happened on monitoring servers.
[info] Got exit code 1 (Not master dead).
MySQL Replication Health is NOT OK!
检查每台机器的my.cnf,是否有以下三项:
relay-log=/data/mysql/binlog/mysql-relay-bin
master_info_repository = file
relay_log_info_repository = file
如果master_info_repository 和 relay_log_info_repository的值是Table需要修改为file,
my.cnf里面不要设置read_only = 1,否则MHA切换的时候会出问题,直接在线设置即可;
Can't exec "mysqlbinlog": No suchfile or directory at /usr/local/share/perl5/MHA/BinlogManager.pm line 106.
解决方法:
[root@data02 ~]# type mysqlbinlog
mysqlbinlog is/usr/local/mysql/bin/mysqlbinlog
[root@data02 ~]# ln -s /usr/local/mysql/bin/mysqlbinlog /usr/bin/mysqlbinlog
Testing mysql connection and privileges..sh: mysql: command not found
mysql command failed with rc 127:0!
解决方法:
ln -s /usr/local/mysql/bin/mysql/usr/bin/mysql
各机器都需加下软连接。
MHA管理节点目录权限问题
如果在管理节点使用了非root用户进行mha管理,则需要相关权限,否则报错
如下我们使用mysql用户管理mha,则在root账户先创建相关目录,在赋权给mysql
# mkdir -p /var/log/masterha/app1
# chown -R mysql:mysql /var/log/masterha
# su - mysql
$ masterha_check_repl --conf=/etc/app1.cnf 使用mysql用户校验复制关系
需要添加用于登陆到mysql服务器账户
需要STOP SLAVE, CHANGE MASTER, RESET SLAVE等相关权限,该账户要添加到mha配置文件中,主从切换时用到
在mysql数据库各节点执行,如下由于跨网段,所以分配了跨网段账户,否则,单条赋权即可
mysql> grant all privileges on *.* to 'mha'@'172.16.16.%' identified by '***';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on *.* to 'mha'@'192.168.1.%' identified by '***';
Query OK, 0 rows affected (0.00 sec)
Mon Jan 22 21:40:41 2018 - error Multi-master configuration is detected, but all of them are read-only! Check configurations for details. Master configurations are as below:
解决方法:
Master设置
mysql> set global read_only=0;
Query OK, 0 rows affected (0.00 sec)
mysql> show variables like 'read_only';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| read_only | OFF |
+---------------+-------+
1 row in set (0.01 sec)
Slave设置
mysql> set global read_only=1;
Query OK, 0 rows affected (0.00 sec)
mysql> show variables like 'read_only';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| read_only | ON |
+---------------+-------+
1 row in set (0.00 sec)
需要添加用于建立复制关系的账户
在mysql数据库各节点执行,如下由于跨网段,所以分配了跨网段账户,否则,单条赋权即可
mysql> grant replication slave on *.* to 'repl'@'172.16.16.%' identified by '***';
Query OK, 0 rows affected (0.00 sec)
mysql> grant replication slave on *.* to 'repl'@'192.168.1.%' identified by '***';
Query OK, 0 rows affected (0.00 sec)
从库的各客户端应开启binlog,即log_bin=on
未开启则收到如下提示:
Mon Apr 13 20:02:15 2017 - [warning] log-bin is not set on slave SZ-DB-SLAVE01(192.168.81.3:3306).
This host cannot be a master.
各主从库应该使用相同的复制过滤规则
否则收到如下的错误提示:
Mon Apr 13 20:02:15 2017 - [error][/usr/lib/perl5/site_perl/5.8.8/MHA/ServerManager.pm, ln546] Replication
filtering check failed on dbsrv3(192.168.1.3:3306)! All slaves must have same replication filtering rules.
Check SHOW SLAVE STATUS output and set my.cnf correctly.
Mon Apr 13 20:02:15 2017 - [warning] Bad Binlog/Replication filtering rules:
各从库应设置relay_log_purge=0
否则收到以下告警信息 ##mysql -e 'set global relay_log_purge=0' 动态修改该参数,因为随时slave会提升为master。补充@150420
Mon Apr 13 20:02:15 2017 - [warning] relay_log_purge=0 is not set on slave vdbsrv2(172.16.16.12:3306).
各从库设置read_only=1
否则收到以下告警信息 ## mysql -e 'set global read_only=1' 动态修改该参数,因为随时slave会提升为master。补充@150420
Mon Apr 13 20:19:54 2017 - [info] read_only=1 is not set on slave vdbsrv3(172.16.16.13:3306).
Tag标签:「mysql error mha」更新时间:「2021-11-03 10:56:39」阅读次数:「678」