0 概览
hanganaylze主要步骤:
oradebugsetmypid
oradebugunlimit
--RAC环境
oradebugsetinstall
--级别一般指定为3足够了
oradebughanganalyze3
--RAC环境
oradebug-g defdump systemstate10
oradebugtracefile_name
解读 hanganalyze 报告
State of ALL nodes
([nodenum]/cnode/sid/sess_srno/session/ospid/state/[adjlist]):
[124]/1/125/7/0xcb8b7c30/2985/LEAF/
[137]/1/138/85/0xcb8900d0/3456/NLEAF/[124]
这里主要是:
nodenum,将相关信息关联起来
cnode,数据库节点编号,rac中有用
sid,会话的 sid
sess_srno,serial#
ospid,pid
state,表示session状态重点关注LEAF状态的节点,它们通常就是造成阻塞的关键会话
adjlist,关联会话的nodenum,通常就是blocker的nodenum
1 制造阻塞
session 1
SQL> update scott.emp_t set comm = 1000 where empno=7788;
1 row updated.
session 2
SQL> update scott.emp_t set comm = 1500 where empno = 7788;
2 hanganalyze
[[email protected] ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Wed Jun 21 21:40:52 2017
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> oradebug setmypid
Statement processed.
SQL> oradebug unlimit
Statement processed.
SQL> oradebug hanganalyze 3
Hang Analysis in /u01/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_ora_3642.trc
SQL> oradebug tracefile_name
/u01/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_ora_3642.trc
SQL> exit
文件比较长,主要是下面这段
[[email protected] ~]$ vim /u01/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_ora_3642.trc
State of ALL nodes
([nodenum]/cnode/sid/sess_srno/session/ospid/state/[adjlist]):
[124]/1/125/7/0xcb8b7c30/2985/LEAF/
[137]/1/138/85/0xcb8900d0/3456/NLEAF/[124]
sid = 125 serial = 7 pid = 2985 阻塞了 138,85,3456
3 kill 阻塞会话
kill会话有两种方式,oracle内kill相关sid,以及系统中kill相关pid
oracle内kill相关sid
alter system kill session 'sid, s.serial#‘;
linux中就是 kill -9
SQL> alter system kill session '125,7';
System altered.
4 查看结果
session 1
SQL> select * from scott.emp_t;
select * from scott.emp_t
*
ERROR at line 1:
ORA-00028: your session has been killed
session 2
1 row updated.
SQL> set lines 200
SQL> select * from scott.emp_t;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- ---------- --------- ---------- ------------ ---------- ---------- ----------
7369 SMITH CLERK 7902 17-DEC-80 800 20
....
14 rows selected.
5 其他资料
如果感兴趣可以查看下面的资料,虽然有些有出入,可以作为参考
Oracle Hanganalyze 分析
查询Oracle正在执行和执行过的SQL语句
https://www.cndba.cn/xkan/article/2000
https://www.cndba.cn/xkan/article/2000
https://www.cndba.cn/xkan/article/2000
https://www.cndba.cn/xkan/article/2000
https://www.cndba.cn/xkan/article/2000
https://www.cndba.cn/xkan/article/2000
https://www.cndba.cn/xkan/article/2000
https://www.cndba.cn/xkan/article/2000
https://www.cndba.cn/xkan/article/2000
https://www.cndba.cn/xkan/article/2000
版权声明:本文为博主原创文章,未经博主允许不得转载。