mysql 高可用架构 mha 之七 masterha_check_repl 报错
程序员文章站
2022-03-26 19:03:07
os: ubuntu 16.04db: mysql 5.7.25mha: 0.58mysql master 关闭后,发生 failover 到另外一台机器上,这时再启动 mysql 后,执行 masterha_check_repl 报错如下$ masterha_check_repl --conf=/etc/mha/mysql/app.cnfWed Jul 15 14:43:43 2020 - [warning] Global configuration file /etc/masterha_def...
os: ubuntu 16.04
db: mysql 5.7.25
mha: 0.58
mysql master 关闭后,发生 failover 到另外一台机器上,这时再启动 mysql 后,执行 masterha_check_repl 报错如下
$ masterha_check_repl --conf=/etc/mha/mysql/app.cnf
Wed Jul 15 14:43:43 2020 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
Wed Jul 15 14:43:43 2020 - [info] Reading application default configuration from /etc/mha/mysql/app.cnf..
Wed Jul 15 14:43:43 2020 - [info] Reading server configuration from /etc/mha/mysql/app.cnf..
Wed Jul 15 14:43:43 2020 - [info] MHA::MasterMonitor version 0.58.
Wed Jul 15 14:43:44 2020 - [error][/usr/local/share/perl/5.22.1/MHA/ServerManager.pm, ln653] There are 2 non-slave servers! MHA manages at most one non-slave server. Check configurations.
Wed Jul 15 14:43:44 2020 - [error][/usr/local/share/perl/5.22.1/MHA/MasterMonitor.pm, ln427] Error happened on checking configurations. at /usr/local/share/perl/5.22.1/MHA/MasterMonitor.pm line 329.
Wed Jul 15 14:43:44 2020 - [error][/usr/local/share/perl/5.22.1/MHA/MasterMonitor.pm, ln525] Error happened on monitoring servers.
Wed Jul 15 14:43:44 2020 - [info] Got exit code 1 (Not master dead).
MySQL Replication Health is NOT OK!
手动变为新的slave,并启动同步进程
mysql> reset master;
mysql> change master to
master_host='192.168.56.90',
master_port=3306,
master_user='repl',
master_password='xxoo';
mysql> start slave;
mysql> show slave status\G
再次执行 masterha_check_repl 时依旧报错
$ masterha_check_repl --conf=/etc/mha/mysql/app.cnf
Wed Jul 15 14:56:27 2020 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
Wed Jul 15 14:56:27 2020 - [info] Reading application default configuration from /etc/mha/mysql/app.cnf..
Wed Jul 15 14:56:27 2020 - [info] Reading server configuration from /etc/mha/mysql/app.cnf..
Wed Jul 15 14:56:27 2020 - [info] MHA::MasterMonitor version 0.58.
Wed Jul 15 14:56:27 2020 - [error][/usr/local/share/perl/5.22.1/MHA/Server.pm, ln180] Got MySQL error when connecting 192.168.56.92(192.168.56.92:3306) :1045:Access denied for user 'mha'@'192.168.56.92' (using password: YES), but this is not a MySQL crash. Check MySQL server settings.
Wed Jul 15 14:56:27 2020 - [error][/usr/local/share/perl/5.22.1/MHA/ServerManager.pm, ln301] at /usr/local/share/perl/5.22.1/MHA/ServerManager.pm line 297.
Wed Jul 15 14:56:28 2020 - [error][/usr/local/share/perl/5.22.1/MHA/ServerManager.pm, ln309] Got fatal error, stopping operations
Wed Jul 15 14:56:28 2020 - [error][/usr/local/share/perl/5.22.1/MHA/MasterMonitor.pm, ln427] Error happened on checking configurations. at /usr/local/share/perl/5.22.1/MHA/MasterMonitor.pm line 329.
Wed Jul 15 14:56:28 2020 - [error][/usr/local/share/perl/5.22.1/MHA/MasterMonitor.pm, ln525] Error happened on monitoring servers.
Wed Jul 15 14:56:28 2020 - [info] Got exit code 1 (Not master dead).
MySQL Replication Health is NOT OK!
修改方法:
需要重建 mha 相关用户
set sql_log_bin=0;
create user 'mha'@'192.168.56.%' identified by 'xxoo';
grant all privileges on *.* to 'mha'@'192.168.56.%';
grant select, insert, update, delete, create, drop on `mysql`.`apply_diff_relay_logs_test` to 'mha'@'192.168.56.%';
flush privileges;
create user 'mha_purge'@'localhost' identified by 'xxoo';
grant select, reload, super, replication client on *.* to 'mha_purge'@'localhost';
flush privileges;
set sql_log_bin=1;
本文地址:https://blog.csdn.net/ctypyb2002/article/details/107360464