背景
MySQL 5.7.24
CentOS Linux 3.10.0-693.21.1.el7.x86_64
利用网易Cetus开源中间件搭建集群环境,MySQL集群利用Group Replication的Single-Primary Mode,节点角色如下:
node1(primary),IP:192.168.233.74
node2(Secondary),IP:192.168.233.192
node3(Secondary),IP:192.168.233.51
Cetus部署在node1
按照Cetus安装说明操作后,在启动Cetus时,报错如下:
(pid=36145) 2019-01-17 17:13:51: (warning) src/network-mysqld.c:5316: con:0x2555f80 failed for server:0x2570700
(pid=36145) 2019-01-17 17:13:51: (warning) src/network-mysqld.c:5370: ...
(pid=36145) 2019-01-17 17:13:51: (warning) src/network-mysqld.c:5316: con:0x2555030 failed for server:0x25628c0
(pid=36145) 2019-01-17 17:13:51: (warning) src/network-mysqld.c:5370: ...
(pid=36145) 2019-01-17 17:13:51: (warning) src/network-mysqld.c:5316: con:0x2555420 failed for server:0x2563880
(pid=36145) 2019-01-17 17:13:51: (message) monitor thread connected to backend: 192.168.233.74:3306, cached 1 conns
(pid=36145) 2019-01-17 17:13:51: (message) monitor thread connected to backend: 192.168.233.192:3306, cached 2 conns
(pid=36145) 2019-01-17 17:13:51: (critical) monitor thread cannot connect to backend: root@192.168.233.51:3306
(pid=36145) 2019-01-17 17:13:51: (message) get connection failed. error: 0, text: , backend: 192.168.233.51:3306
(pid=36145) 2019-01-17 17:13:51: (message) change backend: 192.168.233.74:3306 from type: read/write, state: online to type: read/write, state: online
(pid=36145) 2019-01-17 17:13:51: (message) Backend 192.168.233.74:3306 is set to UP.
(pid=36145) 2019-01-17 17:13:51: (message) change backend: 192.168.233.192:3306 from type: readonly, state: online to type: readonly, state: online
(pid=36145) 2019-01-17 17:13:51: (message) Slave delay 0.040 seconds. Recovered. Set slave to UP.
(pid=36145) 2019-01-17 17:13:51: (critical) monitor thread cannot connect to backend: root@192.168.233.51:3306
(pid=36145) 2019-01-17 17:13:51: (critical) Connection error when read delay from RO backend: 192.168.233.51:3306
(pid=36145) 2019-01-17 17:13:51: (message) change backend: 192.168.233.51:3306 from type: readonly, state: down to type: readonly, state: down
(pid=36145) 2019-01-17 17:13:51: (critical) Backend 192.168.233.51:3306 is set to DOWN.
(pid=36145) 2019-01-17 17:13:51: (critical) monitor thread cannot connect to backend: root@192.168.233.51:3306
(pid=36145) 2019-01-17 17:13:51: (message) get connection failed. error: 0, text: , backend: 192.168.233.51:3306
(pid=36145) 2019-01-17 17:13:51: (critical) monitor thread cannot connect to backend: root@192.168.233.51:3306
(pid=36145) 2019-01-17 17:13:51: (critical) Connection error when read delay from RO backend: 192.168.233.51:3306
现象
可以发现node1、node2已经连接成功,但是在连接node3的时候失败。
解决方法
首先排除账号密码的问题,然后在node1本机远程访问node3的数据库,结果报错如下:
[root@node1 /usr/local/cetus]#mysql -h 192.168.233.51 -u root -p
Enter password:
ERROR 1129 (HY000): Host '192.168.233.74' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'
很明显,是由于node1连接node3数据库时报错太多,被node3的数据库封杀了。
在node3直接连接数据库执行如下命令即可:
[root@node3 /root]#mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4070
Server version: 5.7.24-log MySQL Community Server (GPL)
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> flush hosts;
Query OK, 0 rows affected (0.02 sec)