关于ORACLE的v$process 和v$session 到达最大连接限制的问题
ORA-12520:TNS:监听程序无法为请求的服务器类型找到可用的处理程序
oracle这个错误的意思是 数据库的连接数达到最大值限制。
一、关于v$process 和v$session的基本知识
Oracle数据库中Session和Connection的区别。
在Oracle的官方文档上,对Session和Connection是这样解释的:
Connection: Communicate pathway between a client process and an Oracle database instance.
连接:一个客户端进程和Oracle数据库实例之间的通信链路。
Session: A logical entity in the database instance memory that represnts the state of a current user login to a database. A single connection can have 0, 1 or more sessions established on it.
会话:用于展示当前登录到数据库用户的状态的数据库实例内存中的一个逻辑实体。一个单独的连接可以有0,1,或者更多的会话。
Connection并不是直接建立在用户进程和数据库实例之间的。而是在用户进程和Server Process(服务器进程)之间的,因此有一个Connection就一定会有一个用户进程和一个服务器进程。但不一定会存在Session。比如,如果需要将东西从A运到B,Connection可以看成是一座“桥”,而卡车把东西从A运到B后并返回A,这就是Session。所以,只要不断开连接,随时都可以在这个连接上创建出会话。
二、查看v$process 和v$session的基本信息
查询资源限制的视图的语法:
select * from v$resource_limit;
select * from v$process;
select * from v$session;
select * from v$session t where t.STATUS=’ACTIVE”;
process和session参数最大值估算方法
select round(sum(pga_used_mem)/1024/1024,0) total_used_M, round(sum(pga_used_mem)/count(1)/1024/1024,0) avg_used_M,
round(sum(pga_alloc_mem)/1024/1024,0) total_alloc_M, round(sum(pga_alloc_mem)/count(1)/1024/1024,0) avg_alloc_M from v$process;
三、释放资源
在sqlnet.ora文件中设置expire_time 参数。
可以使用EXPIRE_TIME参数间歇检查异常session并释放process。
官方说明:SQLNET.EXPIRE_TIME
Purpose
Use parameter SQLNET.EXPIRE_TIME to specify a the time interval, in minutes, to send a probe to verify that client/server connections are active. Setting a value greater than 0 ensures that connections are not left open indefinitely, due to an abnormal client termination. If the probe finds a terminated connection, or a connection that is no longer in use, it returns an error, causing the server process to exit. This parameter is primarily intended for the database server, which typically handles multiple connections at any one time.
Limitations on using this terminated connection detection feature are:
It is not allowed on bequeathed connections.
Though very small, a probe packet generates additional traffic that may downgrade network performance.
Depending on which operating system is in use, the server may need to perform additional processing to distinguish the connection probing event from other events that occur. This can also result in degraded network performance.
Recommended Value
10
Example
SQLNET.EXPIRE_TIME=10
这里设置是10分钟,每10分钟Oracle会确认所有session客户端连接是否正常,对于不正常的session,oracle会清理process。
同时,扩大最大连接数,同时Session自动跟着扩大。
–修改最大连接数:
alter system set processes = 500 scope = spfile;
重启数据库:
cmd :sqlplus sys/passw@databasename as sysdba
然后输入以下命令
shutdown immediate;——关闭数据库,大概需要一个小时
startup;–重启数据库,大概几分钟。
重启之后:
select count(*) from v$process ——从298变成132
select count(*) from v$session ——从104变成38
但是,在ArcGIS Portal 里面打开一个页面,调用了SDE图层,
上面的连接数字都增加,那么就算设置为最大500,也支撑不来多少用户使用的!!!!????
–查看当前有哪些用户正在使用数据
SELECT osuser, a.username,cpu_time/executions/1000000||’s’,b.sql_text,machine
from v$session a, v$sqlarea b
where a.sql_address =b.address order by cpu_time;
——在ArcGIS Portal 里面打开一个页面,调用了SDE图层,通过以上语句,可以看到SDE用户的连接信息。
就算关闭了浏览器,一段时间依然可以看到这些信息,半个小时后,SDE的连接才消失。
——查询数据库有没有死锁,no row selected 说明没有死锁。
select * from v$locked_object
Oracle R12.2补丁步骤
–应用层应用补丁
–1、补丁准备阶段(需run模式下),合适之前补丁是否正常并将文件清理干净,同时同步FS1和FS2
$ adop phase=prepare
–2、补丁应用阶段
$ adop phase=apply patches=xxxxxx
–3、确定阶段(编译无效对象,在此前阶段可通过abort回退)
$ adop phase=finalize
–4、切换阶段(关闭并发管理器和应用,置EBS系统不可用,并完成转化)
$ adop phase=cutover
–5、清理阶段(run模式下,删除代码和数据,如未运行或者下次prepare阶段自动运行)
$ adop phase=cleanup
参考文件:
How To Run Adop Like – Adpatch – With Option Apply=No? (文档 ID 2067371.1)
ADOP phase=prepare Errors With patch does not exists (文档 ID 1941327.1)
Oracle EBS标准form界面导出格式由TSV默认为Excel
路径:系统管理员-安装-浏览器选项
(1)excel->application/vnd.ms-excel->Microsoft Excel
(1)配置文件“导出 MIME 类型”设置成‘application/vnd.ms-excel’
(2)首选项设置为与数据库对应的字符集,如UTF8
Oracle DB scn情况查询
–1、查询当前scn情况
select version,
date_time,
dbms_flashback.get_system_change_number current_scn,
indicator
from (select version,
to_char(SYSDATE, 'YYYY/MM/DD HH24:MI:SS') DATE_TIME,
((((((to_number(to_char(sysdate, 'YYYY')) – 1988) * 12 * 31 * 24 * 60 * 60) +
((to_number(to_char(sysdate, 'MM')) – 1) * 31 * 24 * 60 * 60) +
(((to_number(to_char(sysdate, 'DD')) – 1)) * 24 * 60 * 60) +
(to_number(to_char(sysdate, 'HH24')) * 60 * 60) +
(to_number(to_char(sysdate, 'MI')) * 60) +
(to_number(to_char(sysdate, 'SS')))) * (16 * 1024)) –
SYS.dbms_flashback.get_system_change_number) /
(16 * 1024 * 60 * 60 * 24)) indicator
from v$instance);
–2、查询距离上限天数的历史变化情况
SELECT tim,
gscn,
round(rate),
round((chk16kscn – gscn) / 24 / 3600 / 16 / 1024, 1) "HEADROOM"
FROM (SELECT tim,
gscn,
rate,
((((to_number(to_char(tim, 'YYYY')) – 1988) * 12 * 31 * 24 * 60 * 60) +
((to_number(to_char(tim, 'MM')) – 1) * 31 * 24 * 60 * 60) +
(((to_number(to_char(tim, 'DD')) – 1)) * 24 * 60 * 60) +
(to_number(to_char(tim, 'HH24')) * 60 * 60) +
(to_number(to_char(tim, 'MI')) * 60) +
(to_number(to_char(tim, 'SS')))) * (16 * 1024)) chk16kscn
FROM (SELECT first_time tim,
first_change# gscn,
((next_change# – first_change#) /
((next_time – first_time) * 24 * 60 * 60)) rate
FROM v$archived_log
WHERE (next_time > first_time)))
ORDER BY 1, 2;
可参考以下链接:
https://www.cnblogs.com/likingzi/p/6420927.html
其他:此脚本来做patch 13498243