mysql replication health is not ok_MySQL 有关MHA搭建与切换的几个错误log

1:masterha_check_repl 副本集方面报错  replicates is not defined in the configuration file!

具体信息如下:

# /usr/local/bin/masterha_check_repl --conf=/etc/mha/app1.cnf

Thu Nov21 15:33:15 2018 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.

Thu Nov21 15:33:15 2018 - [info] Reading application default configuration from /etc/mha/app1.cnf..

Thu Nov21 15:33:15 2018 - [info] Reading server configuration from /etc/mha/app1.cnf..

Thu Nov21 15:33:15 2018 - [info] MHA::MasterMonitor version 0.56.

Thu Nov21 15:33:16 2018- [error][/usr/local/share/perl5/MHA/ServerManager.pm, ln671] Master 179.179.19.179:3306 from which slave 179.179.19.180(179.179.19.180:3306) replicates is not defined in the configuration file!Thu Nov21 15:33:16 2018 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln424] Error happened on checking configurations. at /usr/local/share/perl5/MHA/MasterMonitor.pm line 326.

Thu Nov21 15:33:16 2018 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln523] Error happened on monitoring servers.

Thu Nov21 15:33:16 2018 - [info] Got exit code 1(Not master dead).

MySQL Replication Health is NOT OK!

分析:MHA 漂移过后,我们知道配置信息中 主节点的信息就不在了,我们需要及时维护,否则/usr/local/bin/masterha_check_repl --conf=/etc/mha/XXX.cnf 检查副本集状态报错。

2. masterha_master_switch 在线切换方面 报错 We should not start online master switch when one of connections are running long updates on the current master

具体信息如下:

# /usr/local/bin/masterha_master_switch --master_state=alive --conf=/etc/mha/app1.cnf

It is better to execute FLUSH NO_WRITE_TO_BINLOG TABLES on the master before switching. Is it ok to execute on179.179.19.184(179.179.19.184:3306)? (YES/no): y

Tue Nov19 17:19:09 2018 - [info] Executing FLUSH NO_WRITE_TO_BINLOG TABLES. This may take long time..

Tue Nov19 17:19:09 2018 - [info] ok.

Tue Nov19 17:19:09 2018 - [info] Checking MHA is not monitoring or doing failover..

Tue Nov19 17:19:09 2018 - [info] Checking replication health on 179.179.19.185..

Tue Nov19 17:19:09 2018 - [info] ok.

Tue Nov19 17:19:09 2018 - [error][/usr/local/share/perl5/MHA/MasterRotate.pm, ln161] We should not start online master switch when one of connections are running long updates on the current master(179.179.19.184(179.179.19.184:3306)). Currently 1update thread(s) are running.

Details:

{'Time' => '12815','db' => undef,'Id' => '1','User' => 'event_scheduler','State' => 'Waiting on empty queue','Command' => 'Daemon','Info' => undef,'Host' => 'localhost'}

Tue Nov19 17:19:09 2018 - [error][/usr/local/share/perl5/MHA/ManagerUtil.pm, ln177] Got ERROR: at /usr/local/bin/masterha_master_switch line 53.

分析:set global event_scheduler=off; 主从都要关闭

3. masterha_master_switch 在线切换方面 报错 Got Error: DBI .....failed: Access denied for user

# /usr/local/bin/masterha_master_switch --master_state=alive --conf=/etc/mha/app1.cnf

Starting master switch from179.179.19.185(179.179.19:3306) to 179.179.19.184(179.179.19.184:3306)? (yes/NO): yes

Tue Nov19 18:52:04 2018 - [info] Checking whether 179.179.19.184(179.179.19.184:3306) is ok forthe new master..

Tue Nov19 18:52:04 2018 - [info] ok.

Tue Nov19 18:52:04 2018 - [info] ** Phase 1: Configuration Check Phase completed.

Tue Nov19 18:52:04 2018 - [info]

Tue Nov19 18:52:04 2018 - [info] * Phase 2: Rejecting updates Phase..

Tue Nov19 18:52:04 2018 - [info]

Tue Nov19 18:52:04 2018 - [info] Executing master ip online change script to disable writeon the current master:

Tue Nov19 18:52:04 2018 - [info] /usr/local/bin/master_ip_online_change_appuanalysis --command=stop --orig_master_host=179.179.19.185 --orig_master_ip=179.179.19.185 --orig_master_port=3306--orig_master_user='weixinLX391P_xldbmha' --orig_master_password='weixinLX391P_xldbmha\)qlk' --new_master_host=179.179.19.184 --new_master_ip=179.179.19.184 --new_master_port=55988 --new_master_user='us_mha' --new_master_password='weixinLX391P_xldbmha\)qlk' --orig_master_ssh_user=root --new_master_ssh_user=root

Got Error: DBI connect(';host=179.179.19.184;port=3306;mysql_connect_timeout=4','weixinLX391P_xldbmha',...) failed: Access denied for user 'weixinLX391P_xldbmha'@'179.179.19.166' (using password: YES) at /usr/local/share/perl5/MHA/DBHelper.pm line 205.

at/usr/local/bin/master_ip_online_change_app1 line 119.

Tue Nov19 18:52:04 2018 - [error][/usr/local/share/perl5/MHA/ManagerUtil.pm, ln177] Got ERROR: at /usr/local/bin/masterha_master_switch line 53.

分析:账号密码有需要转移字符的。app1.cnf 文件中user账号相应的密码 password 不能有待转移的字符,例如本例中的')',但是 账号 repl_user 相应的密码repl_password 没有此限制。

4.如果使用的是xtrabackup,注意从节点会把event还原上去,可能会造成数据不一致,同步失败的问题。

如果主节点有event,需要手动关闭从节点的event。例如,主节点有归档删除数据的event,从节点需要关闭,否则报错。类似如下错误:

Could not execute Delete_rows event on table ????DB.*****table; Can't find record in'*****', Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the event's master log FIRST, end_log_pos XXXXXXX

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在MySQL搭建MHAMySQL Master High Availability),需要执行以下步骤: 1. 在所有MySQL服务器上创建一个MHA管理账号,并赋予其所有权限。在MySQL命令行中执行以下语句: ``` mysql> grant all privileges on *.* to 'root'@'192.168.1.%' identified by '123456'; mysql> flush privileges; ``` 如果是在slave服务器上安装的manager,则需要创建一个以本机hostname名连接的账号,以确保masterha_check_repl测试通过。在MySQL命令行中执行以下语句: ``` GRANT ALL PRIVILEGES ON *.* TO 'root'@'master(主机名)' IDENTIFIED BY '123456'; ``` 2. 安装MHA软件包。在MHA节点服务器上执行以下命令: ``` cd /opt tar zxvf mha4mysql-manager-0.57.tar.gz cd mha4mysql-manager-0.57 perl Makefile.PL make && make install ``` 3. 在manager节点上测试MySQL主从连接情况。在命令行中执行以下命令: ``` masterha_check_repl -conf=/etc/masterha/app1.cnf ``` 如果最后出现"MySQL Replication Health is OK"字样,说明连接正常。 请注意,以上步骤仅为搭建MHA的基本步骤,具体操作可能会因环境和需求而有所不同。建议参考MHA的官方文档或相关教程进行详细配置和操作。 #### 引用[.reference_title] - *1* [MySQL高可用架构之基于MHA搭建](https://blog.csdn.net/weixin_34137799/article/details/93427145)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* *3* [MySQL——MHA搭建](https://blog.csdn.net/qq_45773660/article/details/118445729)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值