快捷搜索:

从问题入手帮你解决Oracle杀死死锁进程 - 死锁

Oracle杀逝世逝世锁进程

先查看哪些表被锁住了:

select b.owner,b.object_name,a.session_id,a.locked_mode

from v$locked_object a,dba_objects b

where b.object_id = a.object_id;

OWNER OBJECT_NAME SESSION_ID LOCKED_MODE

------------------------------ -----------------

WSSB SBDA_PSHPFTDT  22 3

WSSB_RTREPOS WB_RT_SERVICE_QUEUE_TAB  24 2

WSSB_RTREPOS WB_RT_NOTIFY_QUEUE_TAB  29 2

WSSB_RTREPOS WB_RT_NOTIFY_QUEUE_TAB  39 2

WSSB SBDA_PSDBDT 47 3

WSSB_RTREPOS WB_RT_AUDIT_DETAIL 47 3

select b.username,b.sid,b.serial#,logon_time

from v$locked_object a,v$session b

where a.session_id = b.sid order by b.logon_time;

USERNAME  SID  SERIAL# LOGON_TIME

------------------------------ ---------- -------

WSSB_RTACCESS 39 1178 2006-5-22 1

WSSB_RTACCESS 29 5497 2006-5-22 1

杀进程中的会话:

alter system kill session 'sid,serial#';

e.g

alter system kill session '29,5497';

假如有ora-00031差错,则在后面加immediate;alter system kill session '29,5497' immediate;

若何杀逝世oracle逝世锁进程

1.查哪个历程被锁:

查V$DB_OBJECT_CACHE视图:

SELECT * FROM V$DB_OBJECT_CACHE WHERE OWNER='历程的所属用户' AND CLOCKS!='0';

2. 查是哪一个SID,经由过程SID可知道是哪个SESSION:

查V$ACCESS视图:

SELECT * FROM V$ACCESS WHERE OWNER='历程的所属用户' AND NAME='刚才查到的历程名';

3. 查出SID和SERIAL#:

查V$SESSION视图:

SELECT SID,SERIAL#,PADDR FROM V$SESSION WHERE SID='刚才查到的SID';

查V$PROCESS视图:

SELECT SPID FROM V$PROCESS WHERE ADDR='刚才查到的PADDR';

4. 杀进程:

(1)先杀ORACLE进程:

ALTER SYSTEM KILL SESSION '查出的SID,查出的SERIAL#';

(2)再杀操作系统进程:

KILL -9 刚才查出的SPID或ORAKILL 刚才查出的SID 刚才查出的SPID。

Oracle的逝世锁

查询数据库逝世锁:

select t2.username||'  '||t2.sid||'

'||t2.serial#||'  '||t2.logon_time||'

'||t3.sql_text

from v$locked_object t1,v$session t2,v$sqltext t3

where t1.session_id=t2.sid

and t2.sql_address=t3.address

order by t2.logon_time;

查询出来的结果便是有逝世锁的session了,下面便是杀掉落,拿到上面查询出来的SID和SERIAL#,填入到下面的语句中:

alter system kill session 'sid,serial#';

一样平常环境可以办理数据库存在的逝世锁了,或经由过程session id 查到对应的操作系统进程,在Unix中杀掉落操作系统的进程。

SELECT a.username,c.spid AS os_process_id,c.pid

AS oracle_process_id FROM v$session a,v$process c

WHERE c.addr=a.paddr and a.sid= and a.serial#= ;

然后采纳kill (unix) 或 orakill(windows )。

在Unix中:

ps -ef|grep os_process_id

kill -9 os_process_id

ps -ef|grep os_process_id

常常在Oracle的应用历程中碰着这个问题,以是也总结了一点办理措施。

1)查找逝世锁的进程:

sqlplus "/as sysdba"  (sys/change_on_install)

SELECT s.username,l.OBJECT_ID,l.SESSION_ID,s.SERIAL#,

l.ORACLE_USERNAME,l.OS_USER_NAME,l.PROCESS

FROM V$LOCKED_OBJECT l,V$SESSION S WHERE l.SESSION_ID=S.SID;

2)kill掉落这个逝世锁的进程:

alter system kill session ‘sid,serial#’; (此中sid=l.session_id)

3)假如还不能办理:

select pro.spid from v$session ses,

v$process pro where ses.sid=XX and

ses.paddr=pro.addr;

此中sid用逝世锁的sid调换:

exit

ps -ef|grep spid

此中spid是这个进程的进程号,kill掉落这个Oracle进程。

您可能还会对下面的文章感兴趣: