关于v$session

v$session记录的是会话的信息,通常允许最多session=processes*1.1+10
可以通过v$session.paddr=v$process.addr,进而找到v$process.spid

v$session的状态status有几种情况
active:活动,正在执行操作
inactive:不活动
killed:用命令alter system killed session 'sid,serial#'kill后的状态,会保持一段时间,一直到pmon自动清除或者是被kill的session重新尝试连接报错后从v$session中清除。在标记killed状态后,v$session的paddr被修改指向一个虚拟的地址。可以通过查询
select p.addr from v$process p where pid <> 1
minus
select s.paddr from v$session s;
得到addr,再查询v$process获取spid,从系统中彻底kill这个进程.kill -9 spid
至于在系统中kill进程会不会有什么坏的影响,没有研究

SNIPED 在profile中设定idle_time时间,系统会在超时后讲进程标记为sniped状态,同样也是在用户重新尝试连接后报错清除
可以为用户指定独立的profile,控制idle_time,比如ALTER PROFILE DEFAULT LIMIT IDLE_TIME 3;
在session1里
SQL> conn lin/lin@fox
Connected.
在session2里sqlplus "/as sysdba"
SQL> select status,paddr,to_char(logon_time,'yyyymmdd hh24:mi:ss'),to_char(sysda
where username='LIN';

STATUS PADDR TO_CHAR(LOGON_TIM TO_CHAR(SYSDATE,'
-------- -------- ----------------- -----------------
INACTIVE 6921048C 20101025 10:49:53 20101025 10:53:37

SQL> select status,paddr,to_char(logon_time,'yyyymmdd hh24:mi:ss'),to_char(sysda
where username='LIN';

STATUS PADDR TO_CHAR(LOGON_TIM TO_CHAR(SYSDATE,'
-------- -------- ----------------- -----------------
SNIPED 6921048C 20101025 10:49:53 20101025 10:54:02

SQL> select spid from v$process where addr='6921048C';

SPID
------------
5224

在sqlnet.ora里设置sqlnet.expire_time=2理论上应该隔2分钟就会扫描sinped的进程将其清除,但是在标记为sniped之后反复查询始终保持这个状态,并没有被清除,同时
SQL> select status,paddr,to_char(logon_time,'yyyymmdd hh24:mi:ss'),to_char(sysdate,'yyyymmdd hh24:mi:ss') from v$ses
 where username='LIN';

STATUS   PADDR    TO_CHAR(LOGON_TIM TO_CHAR(SYSDATE,'
-------- -------- ----------------- -----------------
SNIPED   6921048C 20101025 10:49:53 20101025 11:06:54

SQL> select spid from v$process where addr='6921048C';

SPID
------------
5224

也能一直查到lin的这个进程。甚是困惑。

9i文档里关于这个参数的说明如下

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.
http://download.oracle.com/docs/cd/B10501_01/network.920/a96581/sqlnet.htm#437583
个人理解beq指的是不通过listener的本地连接,但是我的lin用户连接使用的是conn lin/lin@fox方式,应该走的是tcp协议才对。

在metalink上关于这个参数的使用有一些bug,未深究。

作者: lovegigi1999   发布时间: 2010-10-25