Mysql  too many connection 問題定位及解決方案

問題描述:

 

             springboot  + mybatis  +mysql

application   中import  dbcp2配置

dao中取得mapper

DymicDatasource中create  datasource

 

解決方案:

       登錄mysql -u root -p 

D:\Program Files (x86)\MySQL\MySQL Server 5.5\bin

 

mysql> show  variables  like '%connection%';
+--------------------------+-----------------+
| Variable_name            | Value           |
+--------------------------+-----------------+
| character_set_connection | utf8            |
| collation_connection     | utf8_general_ci |
| max_connections          | 100             |
| max_user_connections     | 0               |
+--------------------------+-----------------+
4 rows in set

mysql> show  variables  like '%timeout
%';
+----------------------------+----------+
| Variable_name              | Value    |
+----------------------------+----------+
| connect_timeout            | 10       |
| delayed_insert_timeout     | 300      |
| innodb_lock_wait_timeout   | 50       |
| innodb_rollback_on_timeout | OFF      |
| interactive_timeout        | 28800    |
| lock_wait_timeout          | 31536000 |
| net_read_timeout           | 30       |
| net_write_timeout          | 60       |
| slave_net_timeout          | 3600     |
| wait_timeout               | 28800    |
+----------------------------+----------+
10 rows in set

 

判斷當前大型系統timeout   設置非常大,連接sleep後不被mysql回收導致連接超過max_connection

解決方案:

      調整動態創建數據庫連接池:

      修改dbcp2回收時間,連接數

    

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章