Grails 2.4 Mysql验证查询不能用于VPS

时间:2015-11-15 09:05:25

标签: mysql tomcat ubuntu grails timeout

我在tomcat7上部署了grails(2.4)应用程序(操作系统在VPS上 Ubuntu 14.04服务器)。我使用推荐的设置连接到DB(见下文)。我无法在日志中看到验证查询。

注意 我的PC上有一个测试虚拟机--Ubuntu 14.04桌面版。在此环境中,验证查询正在运行,并且我没有丢失连接。我可以看到登录的查询: /var/lib/mysql/test.log

详情

  • 唯一可能导致问题的区别是: mysql_secure_installation

  • 这两个环境几乎相同:一个相同: WAR文件,相同的mysql和tomcat版本;

  • 未启用SElinux ;
  • MYSQL 用户已启用所有权限;

我试图改变:

  • 远程登录;
  • 删除外部配置;

  • log tomcat,mysql和ubuntu日志 - 没有错误和警告;

问题 - 监控/日志连接池和与之相关的错误/事件是否可能?

这是我的外化配置文件(放在grails app的conf文件夹中): 的 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

我跟踪:

跟踪sql连接
sudo mysqladmin -u root -p -i 5 processlist

结果是:

+----+-------+-----------------+------------+---------+------+-------+------------------+
| 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 |
+----+-------+-----------------+------------+---------+------+-------+------------------+

如果达到超时限制:所有连接都结束,tomcat出错:

+----+------+-----------+----+---------+------+-------+------------------+
| Id | User | Host      | db | Command | Time | State | Info             |
+----+------+-----------+----+---------+------+-------+------------------+
| 57 | root | localhost |    | Query   | 0    |       | show processlist |
+----+------+-----------+----+---------+------+-------+------------------+

提前谢谢!

1 个答案:

答案 0 :(得分:0)

您可以添加

        dataSource.logSql = true

检查您的查询,但实际上我更愿意通过以下选项之一检查您的mysql日志:https://dev.mysql.com/doc/refman/5.6/en/server-logs.html

f.e。我仍然使用oldschool tail -f /var/log/mysql/mysql.log