我的应用使用ibatis,连接池用了apache的dbcp,应用的访问量比较大,基本每秒都会有写数据库的操作,我用show processlist查看当前进程,processlist的数量怎么也不会超过30条,就算processlist全部都用光了,resin的连接数由于等待数据库而不断升高直至抛异常的时候,show processlist还是不会超过30,请问这个是正常的吗?还是我的配置有错,请指教!
我的ibatis的配置如下
<sqlMapConfig>
   <settings
  cacheModelsEnabled="true"
  lazyLoadingEnabled="true"
  enhancementEnabled = "true"
  maxRequests="512"
  maxSessions="128"
  maxTransactions="32"
  useStatementNamespaces="true"
  />
  
  <transactionManager type="JDBC" commitRequired="false">
    <dataSource type="DBCP">
      <property name="JDBC.Driver" value="org.gjt.mm.mysql.Driver"/>
      <property name="JDBC.ConnectionURL" value="ConnectionURL"/>
      <property name="JDBC.Username" value="username"/>
      <property name="JDBC.Password" value="password"/>
           <property name="JDBC.DefaultAutoCommit" value="true"/>
           <property name="Pool.ValidationQuery" value="select 1"/>
           <property name="Pool.testOnBorrow" value="true"/>
           <property name="Pool.initialSize" value="40"/>
           <property name="Pool.maxActive" value="300"/>
           <property name="Pool.MaximumCheckoutTime" value="14400"/>
           <property name="Pool.maxIdle" value="150"/>
           <property name="Pool.minIdle" value="40"/>
           <property name="Pool.maxWait" value="60000"/>
           <property name="Pool.numTestsPerEvictionRun" value="3"/>
           <property name="Pool.timeBetweenEvictionRunsMillis" value="1000"/>
           <property name="Pool.minEvictableIdleTimeMillis" value="1800000"/>
           <property name="Pool.RemoveAbandoned" value="false"/>
           <property name="Pool.RemoveAbandonedTimeout" value="300"/>
           <property name="Pool.LogAbandoned" value="false"/>
</dataSource>  </transactionManager>
</sqlMapConfig>

解决方案 »

  1.   

    你是不是 mysql 的 max_connection 设为30了???
      

  2.   

    mysql> show global variables like '%max_connect%';
    +--------------------+-------+
    | Variable_name      | Value |
    +--------------------+-------+
    | max_connect_errors | 10    | 
    | max_connections    | 400   | 
    +--------------------+-------+
    2 rows in set (0.00 sec)max_connections是400的哦my.cnf
    [mysqld]
    port            = 3306
    socket          = /tmp/mysql.sock
    skip-locking
    key_buffer = 384M
    max_allowed_packet = 1M
    table_cache = 512
    sort_buffer_size = 2M
    read_buffer_size = 2M
    read_rnd_buffer_size = 8M
    myisam_sort_buffer_size = 64M
    thread_cache_size = 8
    #query_cache_size = 32M
    # Try number of CPU's*2 for thread_concurrency
    thread_concurrency = 8
    default-character-set=gbk
    tmp_table_size = 64M#log
    log-slow-queries
    log-long-format
    log_queries_not_using_indexes
    log-warnings
    skip-name-resolv
    max_connections=400
      

  3.   

    另外请教一下  我的my.cnf 里面的一些设置如query_cache_size 、tmp_table_size是我在mysql启动后再用set global 来设置的,那是不是当数据库重启后,这些配置就又跟着my.cnf里面的配置一样的了?
      

  4.   

    另外请教一下  我的my.cnf 里面的一些设置如query_cache_size 、tmp_table_size是我在mysql启动后再用set global 来设置的,那是不是当数据库重启后,这些配置就又跟着my.cnf里面的配置一样的了?>>: 不会一样的。既然set global,会在系统表里有一份配置,它会覆盖my.cnf中的配置值。