当设置了resource_limit=true 。通过idle_time限制session idle 时间。session idle超过设置时间,状态为sniped (v$session).,然而OS下的process并不会释放,当session(user process) 再次与server process 通讯,将关闭相应的server process.

sqlnet.expire_time 的原理不一样,Oracle Server 发送包探测dead connection ,如果连接关闭,或者不再用,则关闭相应的server process.

以上两者组合使用,减少server process,防止process超过init$ORACLE_SID极限值。

#查找长时间不用的session.
SELECT s.username,s.status,s.machine,osuser,spid,
'kill -9 '||spid UNIX_level_kill,
'alter system kill session ' ||''''||s.sid||','||s.serial# || ''';' Oracle_level_kill,
TO_CHAR (logon_time, 'dd/mm/yyyy hh24:mi:ss') logon_time,
last_call_et idle_time,
TO_CHAR (TRUNC (last_call_et / 3600, 0))||' '||' HRS '||TO_CHAR (TRUNC ((last_call_et - TRUNC(last_call_et / 3600, 0) * 3600) / 60, 0)) ||' MINS' idle_time_hour_minute,
module 
FROM v$session s, v$process p
WHERE TYPE = 'USER'
AND p.addr = s.paddr
AND status = 'SNIPED' 
-- AND SUBSTR (machine, 1, 19) NOT IN ('machine')
AND last_call_et > 60 * 60 * 2
-- session idle time more than 1 hour
ORDER BY last_call_et desc;

##写了一个脚本,kill sniped session
##kill_sniped_session.sh
#! /bin/bash
ORACLE_SID=xxxxprod
export ORACLE_SID
ORACLE_HOME=`cat /var/opt/oracle/oratab|grep ^$ORACLE_SID:|cut -f2 -d':'`
export ORACLE_HOME
SQLPATH=/apps/oracle/sql
export SQLPATH
#
$ORACLE_HOME/bin/sqlplus -s "/ as sysdba"<<!
@sniped_session.sql 
exit
!
if [ -s /apps/oracle/sql/kill_sniped_session.lst ] 
then
echo "have a list of sniped_session"
grep kill /apps/oracle/sql/kill_sniped_session.lst
grep kill /apps/oracle/sql/kill_sniped_session.lst | awk '{ print $3 }' | xargs kill -9 2>/backup/oracle/kill_sniped_session.log
fi
if [ $? -ne 0 ]
then
cat /backup/oracle/kill_sniped_session.log | mailx -s "xxxxprod kill sniped session failed" xx@@ss.com
else
sessions_count=`grep kill /apps/oracle/sql/kill_sniped_session.lst | wc -l`
echo "sessions:${sessions_count}" | mailx -s "xxxxprod kill sniped session successful" xx@@ss.com
touch /backup/oracle/kill_sniped_session.sh
fi

oracle@xxxxprod$ more sniped_session.sql 
rem sniped_session.sql 
rem DESCRIPTION
rem kill sniped session
rem MODIFIED
set pagesize 1000
set heads off
set verify off
set heading off 
set termout off 
set echo off
set feedback off 
spool on
spool /apps/oracle/sql/kill_sniped_session.lst
select 'kill -9 '||spid UNIX_level_kill
FROM v$session s, v$process p
WHERE TYPE = 'USER'
AND p.addr = s.paddr
AND status = 'SNIPED' 
AND last_call_et > 60 * 60 * 3
ORDER BY last_call_et desc;
spool off

##btw

What does 'SNIPED' status in v$session mean?

When IDLE_TIME is set in the users' profiles or the default profile. This will kill the sessions in the database (status in v$session now becomes SNIPED) and they will eventually disconnect. It does not always clean up the Unix session (LOCAL=NO sessions). At this time all oracle resources are released but the shadow processes remains and OS resources are not released. This shadow process is still counted towards the parameters of init.ora.

This process is killed and entry from v$session is released only when user again tries to do something. Another way of forcing disconnect (if your users come in via SQL*Net) is to put the file sqlnet.ora on every client machine and include the parameter "SQLNET.EXPIRE_TIME" in it to force the close of the SQL*Net session

sqlnet.expire_time

sqlnet.expire_time actually works on a different principle and is used to detect dead connections as opposed to disconnecting(actually 'sniping') a session based on idle_time which the profile accomplishes.

Sqlnet.expire_time basically instructs the Server to send a probe packet every set minutes to the client , and if it finds a terminated connection or a connection that is no longer in use, causes the associated server process to terminate on the server. 
A valid database connection that is idle will respond to the probe packet causing no action on the part of the Server , whereas the resource_limit will snipe the session when idle_time is exceeded. The 'sniped' session will get disconnected when the user(or the user process) tries to communicate with the server again.
But again,as you mentioned, expire_time works globally while idle_time profile works for that user. You can use both of them to make sure that the client not only gets sniped but also gets disconnected if the user process abnormally terminates.

sqlnet.expire_time and idle_time相关推荐

  1. [20180123]测试SQLNET.EXPIRE_TIME参数.txt

    [20180123]测试SQLNET.EXPIRE_TIME参数.txt --//曾经写过一篇linux内核网络参数测试tcp_keepalive,链接http://blog.itpub.net/26 ...

  2. [20180124]测试SQLNET.EXPIRE_TIME参数3

    [20180124]测试SQLNET.EXPIRE_TIME参数3.txt --//昨天测试SQLNET.EXPIRE_TIME参数时,链接如下: http://blog.itpub.net/2672 ...

  3. Oracle session active 和 inactive 状态 说明

    一. Session 状态说明 可以通过v$session 视图的status列查看session 的状态.  关于该视图的使用,参考联机文档: V$SESSION http://download.o ...

  4. Oracle报错ora03135,(转)连接到oracle10g,报ORA-03135异常

    问题描述: 开发人员报告,用myeclipse连接oracle后,过一段时间,连接断开,报ORA-03135错误. 问题挖掘: 用pl/sql和sqlplus连接oracle,也存在该问题,确定该问题 ...

  5. 【转载】Oracle 概要文件IDLE_TIME限制用户最大空闲连接时间

    会话的状态:  1.active 处于此状态的会话,表示正在执行,处于活动状态.  2.killed 处于此状态的会话,表示出现了错误,正在回滚,当然,也是占用系统资源的.还有一点就是,killed的 ...

  6. 笔记系列---------sqlnet.ora维护

    一.功能及作用 # NAME # sqlnet.ora # FUNCTION # Oracle Network Client startup parameter file example # NOTE ...

  7. oracle最大空闲时间,使用Oracle PROFILE控制会话空闲时间

    Oracle推荐PROFILE和SQLNET.EXPIRE_TIME一起使用,但由于PL/SQL工具本身的特点,它会在SESSION的状态变成SNIPED(PROFILE IDLE_TI 客户想实现对 ...

  8. oracle长连接超时设置

    方法一.在sqlnet.ora中设置参数 如需要设置客户端空闲10分钟即被中断,则在sqlnet.ora的末尾添加SQLNET.EXPIRE_TIME=10注:sqlnet.ora文件的路径在$ORA ...

  9. Oracle session连接数和inactive的问题记录【转】

    从上周起,服务器Oracle数据库出现问题,用不到半天,就会报maxsession(150)的问题,肯定是数据库的会话超过最大数了.   由于服务器跑的是文件传输应用,占用的请求和会话肯定很大,因此用 ...

最新文章

  1. 数组随机抽取 java_Java利用数组随机抽取幸运观众如何实现
  2. 【深度学习】详解集成学习的投票和Stacking机制
  3. python socketserver实现服务器端执行命令 上传文件 断点续传
  4. Q1手机全球份额反超苹果,美国对华为的“双重恐惧”再度加深
  5. java--Hibernate添加数据save
  6. c语言条件编译的例子,C语言条件编译分析实例
  7. 关于迭代測试的一些思考
  8. memcached应用策略(转)
  9. 那些上海滩的金融传奇,或许都开始于一份PPT
  10. MySQL—delete和truncate的区别
  11. 构建一个自定义CentOS7内核
  12. 每天一道剑指offer-旋转数组的最小数字
  13. 不懂PS怎么修改图片尺寸?
  14. 《金融学》笔记 第一章 货币的本质
  15. arm linux关机命令,嵌入式Linux的关闭命令是什么?
  16. cesium加载谷歌影像底图
  17. 七大原则+23种设计模式
  18. 电脑主要硬件配置信息查询
  19. VO:简单的视觉里程计代码注释(代码可运行)
  20. 如何隐藏一个盘让其他人搜索不到

热门文章

  1. 深度学习笔记之DenseNets
  2. leetcode-21-合并两个有序链表
  3. ansible基础-Jinja2模版 | 过滤器
  4. Kali学习笔记31:目录遍历漏洞、文件包含漏洞
  5. Product Helper
  6. antd design form表单手动处理错误
  7. Filter在Vue,JS,JQ中的使用
  8. C. 防止E-mail注入
  9. python模块-getpass模块
  10. 在IntelliJ IDEA中添加repository模板