Crawl error log information from the log, as follows:
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
Generate reports more early, so there will be a large amount of database access, the problem is roughly the database connection pool.
Solution:
(1) using the JDBC URL used autoReconnect attributes, url add
&autoReconnect=true&failOverReadOnly=false
例如:
String URL = "jdbc:mysql://localhost:3306/devops&autoReconnect=true&failOverReadOnly=false";
(2) modify the MySQL parameters. /Etc/my.cnf add
[mysqld]
wait_timeout=31536000
interactive_timeout=31536000
(3) restart mysql
service mysql restart
Cause Analysis:
(1) a large amount of data available, mysql connection connector may fail
(2) long might ask, connection will fail
The excerpt below is coming from somewhere else, we can learn from it
It can be configured so that the buffer pool to test whether the connection is recycled, if recovered, not continue to be used to dbcp example:
#SQL query, to verify the connection removed from the connection pool
dbcp.validationQuery=SELECT 1
# Indicates whether the connection is idle collector connection (if any) is tested, if the test fails, the connection is removed from the pool
dbcp.testWhileIdle=true
# Connection time value collector thread to sleep during the idle operation, in milliseconds, typically less than minEvictableIdleTimeMillis
dbcp.timeBetweenEvictionRunsMillis = 300000
# Number of connections connecting each collector thread checks the idle time (if any) runs the best and consistent maxActive
dbcp.numTestsPerEvictionRun=50
# Connection pool, has been idle period, removed from the connection pool time (60 * 1000 * 60), in milliseconds
dbcp.minEvictableIdleTimeMillis = 3600000