Oracle连接数满了

简介: 项目逐渐做大,分布式微服务越部署越多,会遇到 数据库连接数不够的情况。image.png采用直连的方式报错如下:00:00:22.670 |Weekday_Thread-220523178|ERROR| c.

项目逐渐做大,分布式微服务越部署越多,会遇到 数据库连接数不够的情况。

img_540e2f26ff6cb26fc9da28dc1c11e290.png
image.png

采用直连的方式报错如下:

00:00:22.670 |Weekday_Thread-220523178|ERROR| c.e.m.b.t.WeekdayManageThread - 线程中断运行:Could not open JDBC Connection for transaction; nested exception is org.apache.commons.dbcp.S
QLNestedException: Cannot get a connection, pool error Timeout waiting for idle object
org.springframework.transaction.CannotCreateTransactionException: Could not open JDBC Connection for transaction; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot 
get a connection, pool error Timeout waiting for idle object
    at org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:238) ~[spring-2.5.6.jar:2.5.6.SEC03]
    at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:374) ~[spring-2.5.6.jar:2.5.6.SEC03]
    at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:263) ~[spring-2.5.6.jar:2.5.6.SEC03]
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:101) ~[spring-2.5.6.jar:2.5.6.SEC03]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) ~[spring-2.5.6.jar:2.5.6.SEC03]
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89) ~[spring-2.5.6.jar:2.5.6.SEC03]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) ~[spring-2.5.6.jar:2.5.6.SEC03]
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) ~[spring-2.5.6.jar:2.5.6.SEC03]
    at com.sun.proxy.$Proxy2417.doWeekdayControl(Unknown Source) ~[na:na]
    at com.xxx.matrix.base.thread.xxxx.run(xxxx.java:43) ~[its.xxx.xxxxx-1.70.jar:1.70]
    at java.lang.Thread.run(Thread.java:784) [na:1.6.0]
Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot get a connection, pool error Timeout waiting for idle object
    at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:104) ~[commons-dbcp-1.2.2.jar:1.2.2]
    at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880) ~[commons-dbcp-1.2.2.jar:1.2.2]
    at org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:200) ~[spring-2.5.6.jar:2.5.6.SEC03]
    ... 10 common frames omitted
Caused by: java.util.NoSuchElementException: Timeout waiting for idle object
    at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:1174) ~[commons-pool-1.6.jar:1.6]
    at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:96) ~[commons-dbcp-1.2.2.jar:1.2.2]
    ... 12 common frames omitted

使用websphereb(was)报错如下:

10:39:51.130 |Weekday_Thread878128082|ERROR| c.e.m.b.t.xx - 线程中断运行:Could not open JDBC Connection for transaction; nested exception is com.ibm.websphere.ce.cm.ConnectionWaitTimeoutException: CWTE_NORMAL_J2CA1009
org.springframework.transaction.CannotCreateTransactionException: Could not open JDBC Connection for transaction; nested exception is com.ibm.websphere.ce.cm.ConnectionWaitTimeoutException: CWTE_NORMAL_J2CA1009
    at org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:238) ~[spring-2.5.6.jar:2.5.6.SEC03]
    at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:374) ~[spring-2.5.6.jar:2.5.6.SEC03]
    at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:263) ~[spring-2.5.6.jar:2.5.6.SEC03]
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:101) ~[spring-2.5.6.jar:2.5.6.SEC03]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) ~[spring-2.5.6.jar:2.5.6.SEC03]
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89) ~[spring-2.5.6.jar:2.5.6.SEC03]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) ~[spring-2.5.6.jar:2.5.6.SEC03]
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) ~[spring-2.5.6.jar:2.5.6.SEC03]
    at com.sun.proxy.$Proxy109.doWeekdayControl(Unknown Source) ~[na:na]
    at com.xxx.matrix.base.thread.xxx.run(WeekdayManageThread.java:43) ~[its.xxx.xxx.xx-1.70.jar:1.70]
    at java.lang.Thread.run(Thread.java:784) [na:1.6.0]
Caused by: com.ibm.websphere.ce.cm.ConnectionWaitTimeoutException: CWTE_NORMAL_J2CA1009
    at com.ibm.ws.rsadapter.AdapterUtil.toSQLException(AdapterUtil.java:1680) ~[com.ibm.ws.runtime.jar:na]
    at com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource.getConnection(WSJdbcDataSource.java:661) ~[com.ibm.ws.runtime.jar:na]
    at com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource.getConnection(WSJdbcDataSource.java:611) ~[com.ibm.ws.runtime.jar:na]
    at org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:200) ~[spring-2.5.6.jar:2.5.6.SEC03]
    ... 10 common frames omitted
Caused by: com.ibm.websphere.ce.j2c.ConnectionWaitTimeoutException: CWTE_NORMAL_J2CA1009
    at com.ibm.ejs.j2c.FreePool.createOrWaitForConnection(FreePool.java:1782) ~[com.ibm.ws.runtime.jar:na]
    at com.ibm.ejs.j2c.PoolManager.reserve(PoolManager.java:3871) ~[com.ibm.ws.runtime.jar:na]
    at com.ibm.ejs.j2c.PoolManager.reserve(PoolManager.java:3091) ~[com.ibm.ws.runtime.jar:na]
    at com.ibm.ejs.j2c.ConnectionManager.allocateMCWrapper(ConnectionManager.java:1548) ~[com.ibm.ws.runtime.jar:na]
    at com.ibm.ejs.j2c.ConnectionManager.allocateConnection(ConnectionManager.java:1031) ~[com.ibm.ws.runtime.jar:na]
    at com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource.getConnection(WSJdbcDataSource.java:644) ~[com.ibm.ws.runtime.jar:na]
    ... 12 common frames omitted

通常遇到这样的问题,排查方向:

  • 1、检查应用的连接数,是不是配置的小了。
  • 2、如果使用数据源,检查数据源的连接数是不是配置小了。
  • 3、检查数据库的最大连接数和当前连接数,是否是公用的数据库,被别人占用了
  • 4、如果上面均正常,那么查询时间最长的sql,是否是有锁死等待的sql,一直在创建,但是一直锁等待。
---- 当前连接数
select count(*) from v$process ;
--- 最大连接数
select value from v$parameter where name ='processes';  
--- 当前所有用户,按照连接数排序
 select username,count(username) as con from v$session where username is not null group by username  order by con desc;
 
---- 按执行时间排序
 SELECT osuser, a.username,cpu_time/executions/1000000||'s', sql_fulltext,machine
from v$session a, v$sqlarea b
where a.sql_address =b.address order by cpu_time/executions desc;

目录
相关文章
|
6月前
|
资源调度 Oracle 关系型数据库
实时计算 Flink版产品使用合集之同步Oracle数据时,一张表产生了大量的连接数,如何处理
实时计算Flink版作为一种强大的流处理和批处理统一的计算框架,广泛应用于各种需要实时数据处理和分析的场景。实时计算Flink版通常结合SQL接口、DataStream API、以及与上下游数据源和存储系统的丰富连接器,提供了一套全面的解决方案,以应对各种实时计算需求。其低延迟、高吞吐、容错性强的特点,使其成为众多企业和组织实时数据处理首选的技术平台。以下是实时计算Flink版的一些典型使用合集。
|
Oracle 关系型数据库 Linux
Oracle设置连接数进程数会话数
Oracle设置连接数进程数会话数
252 0
|
Oracle 关系型数据库 数据库
|
Oracle 关系型数据库 数据库
oracle查看/修改最大连接数和当前连接数/用户等信息
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/inforstack/article/details/53994958 ...
1709 0
|
Oracle 关系型数据库 数据库
查看oracle数据库的连接数以及用户 (转:http://blog.itpub.net/24558279/viewspace-752293/)
11、查询oracle的连接数2select count(*) from v$session;32、查询oracle的并发连接数4select count(*) from v$session where status='ACTIVE';53、查看不同用户的连接数6select username,count(username) from v$session where username is n
1166 0
|
SQL Oracle 关系型数据库
修改Oracle数据库的连接数
测试了这个,不错。   摘(一)   1. 查看processes和sessions参数   SQL> show parameter processes   NAME TYPE VALUE   db_writer_processes integer 1   gcs_server_processes integer 0   job_queue_processes inte
1193 0
|
Oracle 关系型数据库 数据库
查看Oracle当前连接数
1.查看Oracle最大连接数 SQL>show parameter processes    #最大连接数 2.修改最大连接数 SQL>alter system set processes=value scope=spfile 重启数据库 SQL>shutdown force SQL>start force 3.
732 0