I'm deploying a grails (2.4) application on tomcat7 (the OS is Ubuntu 14.04 server on VPS ). I use recommended settings to connect to DB (see below). I cannot see the validation query in the logs.
Note I have a test virtual machine on my PC - Ubuntu 14.04 desktop edition. In this environment the validation query is working and I'm not losing the connections. I can see the query logged into: /var/lib/mysql/test.log
Details
the only difference which could cause the problem is: mysql_secure_installation
these two environments are almost identical: one and the same: WAR file, same mysql and tomcat version ;
I tried to change:
remove external configuration;
log tomcat, mysql and ubuntu logs - no errors and warnings;
Question - Is it possible monitor/log connection pool and errors/events related to it?
This is my externalized configuration file(placed in conf folder of grails app): config.properties :
dataSource.pooled = true
dataSource.dbCreate=update
dataSource.driverClassName=com.mysql.jdbc.Driver
dataSource.url=jdbc:mysql://localhost:3306/db
dataSource.username=user
dataSource.password=pass
dataSource.jmxEnabled = true
dataSource.initialSize = 5
dataSource.maxActive = 50
dataSource.minIdle = 5
dataSource.maxIdle = 25
dataSource.maxWait = 1000
dataSource.maxAge = 1000
dataSource.timeBetweenEvictionRunsMillis = 1000
dataSource.minEvictableIdleTimeMillis = 1000
dataSource.validationQuery = "SELECT 1"
dataSource.validationQueryTimeout = 30
dataSource.validationInterval = 1500
dataSource.testOnBorrow = true
dataSource.testWhileIdle = true
dataSource.testOnReturn = true
dataSource.jdbcInterceptors = "ConnectionState"
dataSource.defaultTransactionIsolation = java.sql.Connection.TRANSACTION_READ_COMMITTED
I'm tracing sql connections with:
sudo mysqladmin -u root -p -i 5 processlist
and the result is:
+----+-------+-----------------+------------+---------+------+-------+------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+-------+-----------------+------------+---------+------+-------+------------------+
| 47 | test | localhost:38977 | test | Sleep | 143 | | |
| 48 | test | localhost:38978 | test | Sleep | 143 | | |
| 49 | test | localhost:38979 | test | Sleep | 143 | | |
| 50 | test | localhost:38980 | test | Sleep | 143 | | |
| 51 | test | localhost:38981 | test | Sleep | 143 | | |
| 52 | test | localhost:38982 | test | Sleep | 143 | | |
| 53 | test | localhost:38983 | test | Sleep | 143 | | |
| 54 | test | localhost:38984 | test | Sleep | 143 | | |
| 55 | test | localhost:38985 | test | Sleep | 143 | | |
| 56 | test | localhost:38986 | test | Sleep | 138 | | |
| 57 | root | localhost | | Query | 0 | | show processlist |
+----+-------+-----------------+------------+---------+------+-------+------------------+
If the time out limit is reached: all connections are ended and tomcat gives an error:
+----+------+-----------+----+---------+------+-------+------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+------+-----------+----+---------+------+-------+------------------+
| 57 | root | localhost | | Query | 0 | | show processlist |
+----+------+-----------+----+---------+------+-------+------------------+
Thank you in advance!
You can add
dataSource.logSql = true
to check your queries but in fact I'd rather check your mysql logs by one of these options: https://dev.mysql.com/doc/refman/5.6/en/server-logs.html
fe I still use oldschool tail -f /var/log/mysql/mysql.log
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.