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)
来源:oschina
链接:https://my.oschina.net/u/3711371/blog/2872489