Grails 2.4 Mysql验证查询在VPS上不起作用



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

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

详细信息

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

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

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

我试图更改:

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

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

问题-是否可能监视/记录连接池及其相关的错误/事件?

这是我的外部化配置文件(位于grails应用程序的conf文件夹中):配置属性

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

提前谢谢!

您可以添加

        dataSource.logSql = true

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

f.e.我仍然使用旧的tail-f/var/log/mysql/mysql.log

相关内容

  • 没有找到相关文章

最新更新