最近看项目运行日志,报出很多数据库连接异常
- Java code
1,java.sql.SQLException: ORA-04031: unable to allocate 27996 bytes of shared memory ("shared pool","unknown object","sga heap(1,0)","session parame")2,java.sql.SQLException: We are already in the process of making 6 connections and the number of simultaneous builds has been throttled to 53,java.sql.SQLException: Listener refused the connection with the following error:ORA-12519, TNS:no appropriate service handler foundThe Connection descriptor used by the client was:
以上问题不知道是程序的问题,还是Oracle的配置问题,用完的连接又关闭的,有在跑7个项目,用的proxool 连接池,配置
都一样
配置信息如下
- Java code
#Main Database jdbc-0.proxool.alias=DBPool jdbc-0.proxool.driver-url=jdbc:oracle:thin:@XXXX:ORCL jdbc-0.proxool.driver-class=oracle.jdbc.driver.OracleDriver jdbc-0.user=XXX jdbc-0.password=XXX jdbc-0.proxool.house-keeping-sleep-time=40000 jdbc-0.proxool.house-keeping-test-sql=select 1 from dual jdbc-0.proxool.maximum-connection-count=100 jdbc-0.proxool.minimum-connection-count=10 jdbc-0.proxool.maximum-connection-lifetime=900000 jdbc-0.proxool.simultaneous-build-throttle=5 jdbc-0.proxool.recently-started-threshold=40000 jdbc-0.proxool.overload-without-refusal-lifetime=50000 jdbc-0.proxool.maximum-active-time=60000 jdbc-0.proxool.verbose=false jdbc-0.proxool.trace=false jdbc-0.proxool.fatal-sql-exception=Fatal error jdbc-0.proxool.prototype-count=2 jdbc-0.proxool.statistics-log-level=ERROR jdbc-0.proxool.test-before-use=false jdbc-0.proxool.test-after-use=false
公司又没有Oracle能力强的人,更没有专业DBA
还有这种情况下Oracle配置里面最大连接数多少好呢,现在的最大连接数是150,平常情况下,在线连接数有130多的
------解决方案--------------------
2,java.sql.SQLException: We are already in the process of making 6 connections and the number of simultaneous builds has been throttled to 5 (被控制在5)
这里信息表明,有链接数量限制。
但还不清楚是什么地方的限制,也许是连接池,也许是数据库。
3,java.sql.SQLException: Listener refused the connection with the following error:
ORA-12519, TNS:no appropriate service handler found(没有合适的服务处理器)
这里信息表明,数据库当前的连接数已超过了设置的数据库处理的最大上限
select count(*) from v$process --查看当前的连接数
select value from v$parameter where name = 'processes' --查看数据库允许的最大连接数
修改最大连接数:
alter system set processes = 500 scope = spfile;
重启数据库:
shutdown immediate;
startup;
--查看当前有哪些用户正在使用数据
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;