mycat连接不上mysql数据库

耗尽温柔 提交于 2019-12-06 07:03:17

1:首先查看schema.xml中数据库地址和数量是否配置正确

2:查看mycat.log日志看具体什么错误。个人报错:

can't connect to mysql server ,errmsg:Host '192.168.100.196' is blocked because of many connection errors

具体意思是:太多错误连接导致被堵塞

原因:同一个ip在短时间内产生太多(超过mysql数据库max_connection_errors的最大值)中断的数据库连接而导致的阻塞;

解决办法:

方法一

使用mysqladmin flush-hosts 命令清理一下hosts文件(不知道mysqladmin在哪个目录下可以使用命令查找:whereis mysqladmin);

进入命令行 到mysql安装目录,bin文件夹下执行

刷新记录报错host的文件      mysqladmin -u root -p  flush-hosts

注释:不过好像方法一不太好使,方法二搞定;

方法二:

进入数据库将max_connection_errors参数调高,也可以在my.cnf文件中修改不过需要重启MySQL。

mysql>show variables like '%max_connection_errors%';
mysql>set global max_connect_errors = 1000;
mysql>show variables like '%max_connection_errors%';


mysql> show variables like 'max_connect%';
+--------------------+-------+
| Variable_name      | Value |
+--------------------+-------+
| max_connect_errors | 1000  |
| max_connections    | 151   |
+--------------------+-------+
2 rows in set (0.00 sec)

mysql> show @@datasource;
+----------+--------+-------+-----------------+------+------+--------+------+------+---------+-----------+------------+
| DATANODE | NAME   | TYPE  | HOST            | PORT | W/R  | ACTIVE | IDLE | SIZE | EXECUTE | READ_LOAD | WRITE_LOAD |
+----------+--------+-------+-----------------+------+------+--------+------+------+---------+-----------+------------+
| dn1      | hostM1 | mysql | 192.168.118.157 | 3306 | W    |      0 |    1 | 2000 |     321 |     14296 |         35 |
| dn1      | hostS1 | mysql | 192.168.118.158 | 3306 | R    |      0 |    3 | 2000 |    2262 |      2113 |          0 |
| dn1      | hostS2 | mysql | 192.168.118.159 | 3306 | R    |      0 |    3 | 2000 |    2283 |      2134 |          0 |
| dn3      | hostM1 | mysql | 192.168.118.157 | 3306 | W    |      0 |    1 | 2000 |     321 |     14296 |         35 |
| dn3      | hostS1 | mysql | 192.168.118.158 | 3306 | R    |      0 |    3 | 2000 |    2262 |      2113 |          0 |
| dn3      | hostS2 | mysql | 192.168.118.159 | 3306 | R    |      0 |    3 | 2000 |    2283 |      2134 |          0 |
| dn2      | hostM1 | mysql | 192.168.118.157 | 3306 | W    |      0 |    1 | 2000 |     321 |     14296 |         35 |
| dn2      | hostS1 | mysql | 192.168.118.158 | 3306 | R    |      0 |    3 | 2000 |    2262 |      2113 |          0 |
| dn2      | hostS2 | mysql | 192.168.118.159 | 3306 | R    |      0 |    3 | 2000 |    2283 |      2134 |          0 |
+----------+--------+-------+-----------------+------+------+--------+------+------+---------+-----------+------------+
9 rows in set (0.00 sec)

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!