Orbeon MySQL连接不断下降

时间:2013-05-06 14:10:13

标签: orbeon

几分钟后我就不断失去我的MySQL连接。在我尝试连接之前,我在日志中看不到任何错误。

我很高兴发布任何有助于调试的设置,让我知道你需要看到什么。

context.xml中:

<Resource name="jdbc/mysql" auth="Container" type="javax.sql.DataSource"
        initialSize="10" maxActive="50" maxIdle="20" maxWait="60000"
        driverClassName="com.mysql.jdbc.Driver"
        poolPreparedStatements="true"
        username="orbeon"
        password="pw"
        url="jdbc:mysql://localhost:3306/orbeon"/>

的my.cnf:

[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock


[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0

[mysqld]


user = mysql
pid-file  = /var/run/mysqld/mysqld.pid
socket  = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
skip-external-locking
skip-name-resolve

bind-address            = 0.0.0.0


key-buffer            = 256M
thread_stack          = 256K
thread_cache_size     = 8
max_allowed_packet    = 16M
max_connections       = 200
myisam-recover        = BACKUP
wait_timeout          = 180
net_read_timeout      = 30
net_write_timeout     = 30
back_log              = 128
table_cache           = 128
max_heap_table_size   = 32M
lower_case_table_names = 0


query_cache_limit           = 1M
query_cache_size      = 16M



log_error             = /var/log/mysql/error.log

log_slow_queries            = /var/log/mysql/slow.log
long-query-time       = 5
log-queries-not-using-indexes



[mysqldump]
quick
quote-names
max_allowed_packet    = 16M

[mysql]

[isamchk]
key-buffer            = 256M
max_allowed_packet    = 16M

!includedir /etc/mysql/conf.d/

2 个答案:

答案 0 :(得分:1)

尝试将以下两个属性添加到现有的<Resource> for MySQL中。有了这些,Tomcat中的连接池将在从池中获取连接后检查连接是否仍然可用。

validationQuery="select 1 from dual"
testOnBorrow="true"

所以你的<Resource>应该看起来像(当然使用适当的用户名,密码和服务器):

<Resource name="jdbc/mysql" auth="Container" type="javax.sql.DataSource"
    initialSize="3" maxActive="10" maxIdle="20" maxWait="30000"
    driverClassName="com.mysql.jdbc.Driver"
    poolPreparedStatements="true"
    validationQuery="select 1 from dual"
    testOnBorrow="true"
    username="orbeon"
    password="orbeon"
    url="jdbc:mysql://localhost:3306/orbeon?useUnicode=true&amp;characterEncoding=UTF8"/>

答案 1 :(得分:1)