mycat鏈接不上mysql數據庫

1:首先查看schema.xml中數據庫地址和數量是否配置正確mysql

2:查看mycat.log日誌看具體什麼錯誤。我的報錯:sql

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

具體意思是:太多錯誤鏈接致使被堵塞bash

緣由:同一個ip在短期內產生太多(超過mysql數據庫max_connection_errors的最大值)中斷的數據庫鏈接而致使的阻塞;spa

解決辦法:命令行

方法一日誌

使用mysqladmin flush-hosts 命令清理一下hosts文件(不知道mysqladmin在哪一個目錄下能夠使用命令查找:whereis mysqladmin);code

進入命令行 到mysql安裝目錄,bin文件夾下執行server

刷新記錄報錯host的文件      mysqladmin -u root -p  flush-hostsxml

註釋:不過好像方法一不太好使,方法二搞定;

方法二:

進入數據庫將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)
相關文章
相關標籤/搜索