安装环境:CentOS 6.5 MySQL 5.7.22 MHA 0.56
1、找不到mysql 命令
Sat Mar 23 07:17:50 2019 - [info] Connecting to root@192.168.32.181(server2:22)..
Checking slave recovery environment settings..
Opening /data/mysql/relay-log.info ... ok.
Relay log found at /data/mysql, up to server2-relay-bin.000005
Temporary relay log file is /data/mysql/server2-relay-bin.000005
Testing mysql connection and privileges..sh: mysql: command not found
mysql command failed with rc 127:0!
解决办法:找到MySQL 的安装目录,创建适当的软链接
ln -s /usr/local/mysql/bin/mysqlbinlog /usr/local/bin/mysqlbinlog
ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql
2、脚本文件没有执行权限
Sat Mar 23 07:25:46 2019 - [error][/usr/share/perl5/vendor_perl/MHA/MasterMonitor.pm, ln424] Error happened on checking configurations. Can't exec "/usr/local/bin/master_ip_failover": Permission denied at /usr/share/perl5/vendor_perl/MHA/ManagerUtil.pm line 68.
Sat Mar 23 07:25:46 2019 - [error][/usr/share/perl5/vendor_perl/MHA/MasterMonitor.pm, ln523] Error happened on monitoring servers.
Sat Mar 23 07:25:46 2019 - [info] Got exit code 1 (Not master dead).
MySQL Replication Health is NOT OK!
解决办法:赋权
chmod +x /usr/local/bin/master_ip_failover
3、master_ip_failover脚本错误
Sat Mar 23 07:27:44 2019 - [info] Checking master_ip_failover_script status:
Sat Mar 23 07:27:44 2019 - [info] /usr/local/bin/master_ip_failover --command=status --ssh_user=root --orig_master_host=server1 --orig_master_ip=192.168.32.180 --orig_master_port=3306
/usr/local/bin/master_ip_failover: line 4: use: command not found
/usr/local/bin/master_ip_failover: line 6: use: command not found
/usr/local/bin/master_ip_failover: line 10: use: command not found
/usr/local/bin/master_ip_failover: line 14: syntax error near unexpected token `newline'
/usr/local/bin/master_ip_failover: line 14: `my ( '
Sat Mar 23 07:27:44 2019 - [error][/usr/share/perl5/vendor_perl/MHA/MasterMonitor.pm, ln226] Failed to get master_ip_failover_script status with return code 2:0.
Sat Mar 23 07:27:44 2019 - [error][/usr/share/perl5/vendor_perl/MHA/MasterMonitor.pm, ln424] Error happened on checking configurations. at /usr/bin/masterha_check_repl line 48
Sat Mar 23 07:27:44 2019 - [error][/usr/share/perl5/vendor_perl/MHA/MasterMonitor.pm, ln523] Error happened on monitoring servers.
Sat Mar 23 07:27:44 2019 - [info] Got exit code 1 (Not master dead).
解决办法:#!/usr/bin/env perl要最顶行
4、不能切换,出现 No route to host
[root@server3 ~]# masterha_manager --conf=/etc/masterha/app1.cnf
Sun Mar 24 01:49:48 2019 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
Sun Mar 24 01:49:48 2019 - [info] Reading application default configuration from /etc/masterha/app1.cnf..
Sun Mar 24 01:49:48 2019 - [info] Reading server configuration from /etc/masterha/app1.cnf..
ssh: connect to host 192.168.32.180 port 22: No route to host
ssh: connect to host 192.168.32.180 port 22: No route to host
ssh: connect to host 192.168.32.180 port 22: No route to host
ssh: connect to host 192.168.32.180 port 22: No route to host
ssh: connect to host 192.168.32.180 port 22: No route to host
ssh: connect to host 192.168.32.180 port 22: No route to host
解决办法:
找到MHA的log文件,查看原因:
Sun Mar 24 01:51:43 2019 - [info] Executing secondary network check script: /usr/local/bin/masterha_secondary_check -s 192.168.32.181 -s 192.168.32.182 --user=root --master_host=server1 --master_ip=192.168.32.180 --master_port=3306 --user=root --master_host=server1 --master_ip=192.168.32.180 --master_port=3306 --master_user=monitor --master_password=mysql --ping_type=SELECT
sh: /usr/local/bin/masterha_secondary_check: No such file or directory
Sun Mar 24 01:51:43 2019 - [error][/usr/share/perl5/vendor_perl/MHA/HealthCheck.pm, ln412] Got unknown error from /usr/local/bin/masterha_secondary_check -s 192.168.32.181 -s 192.168.32.182 --user=root --master_host=server1 --master_ip=192.168.32.180 --master_port=3306 --user=root --master_host=server1 --master_ip=192.168.32.180 --master_port=3306 --master_user=monitor --master_password=mysql --ping_type=SELECT. exit.
发现是找不到文件路径,经查文件在
/usr/bin/masterha_secondary_check
修改参数文件/etc/mastermha/app.cof 的配置项secondary_check_script= /usr/bin/masterha_secondary_check -s 192.168.32.181 -s 192.168.32.182 --user=root --master_host=server1 --master_ip=192.168.32.180 --master_port=3306
5、Failed to deactivate master IP with return code 1:0
Sun Mar 24 03:55:29 2019 - [info] ** Phase 1: Configuration Check Phase completed.
Sun Mar 24 03:55:29 2019 - [info]
Sun Mar 24 03:55:29 2019 - [info] * Phase 2: Dead Master Shutdown Phase..
Sun Mar 24 03:55:29 2019 - [info]
Sun Mar 24 03:55:29 2019 - [info] Forcing shutdown so that applications never connect to the current master..
Sun Mar 24 03:55:29 2019 - [info] Executing master IP deactivation script:
Sun Mar 24 03:55:29 2019 - [info] /etc/masterha/master_ip_failover --orig_master_host=server1 --orig_master_ip=192.168.32.180 --orig_master_port=3306 --command=stop
Got Error: Use of uninitialized value $ssh_user in concatenation (.) or string at /etc/masterha/master_ip_failover line 79.
IN SCRIPT TEST====/sbin/ifconfig eth0:1 down==/sbin/ifconfig eth0:1 192.168.32.183===
Disabling the VIP on old master: server1
Sun Mar 24 03:55:29 2019 - [error][/usr/share/perl5/vendor_perl/MHA/MasterFailover.pm, ln352] Failed to deactivate master IP with return code 1:0
Sun Mar 24 03:55:29 2019 - [error][/usr/share/perl5/vendor_perl/MHA/ManagerUtil.pm, ln177] Got ERROR: at /usr/bin/masterha_manager line 65
Sun Mar 24 03:55:29 2019 - [info]
----- Failover Report -----
app1: MySQL Master failover server1(192.168.32.180:3306)
Master server1(192.168.32.180:3306) is down!
Check MHA Manager logs at server3:/var/log/masterha/app1-manager.log for details.
Started automated(non-interactive) failover.
Failed to deactivate master IP with return code 1:0
Got Error so couldn't continue failover from here.
Sun Mar 24 03:55:29 2019 - [info] Sending mail..
Unknown option: conf
解决办法:
这个一直说/etc/masterha/master_ip_failover line 79行错误
ssh_user没有初始化