看懂oracle trc文件,oracle 的 debug 工具 和 分析 trc 文件工具 ass.awk

oracle的dump工具和分析trc文件工具ass.awk

之前介绍了oracle的一个hang住时的一个分析工具hanganalyze,这里再引入另外的一个工具,分析系统进程和单个进程的工具

1、在能登录数据库时,可以使用如下语句:

跟踪进程对象的debug的方法:

可以使用下面方法产生系统状态跟踪文件:

process state dumps ==>一个进程的所有对象状态,如果确认哪个进程有问题,就用该方法

process state dumps:

1.ALTER SESSION SET EVENTS 'IMMEDIATE TRACE NAME PROCESSSTATE LEVEL 10'或者event = '604 trace name processstate,level 10'(INIT.ORA entry);

2.oradebug setospid进程ID

3.oradebug dump processstate 10;

实验:

Sid 300:UPDATEtxt_test aSETa.FLOWNO='b'WHEREa.FLOWNO='a';

Sid 244:UPDATEtxt_test aSETa.FLOWNO='b'WHEREa.FLOWNO='a';

这样,sid 300 update后不commit,那么,sid 244就会卡在那边,这时,我去debug sid 244那个进程id 17541

但是,当我使用ass.awk去跟踪文件的时候,却发现,没有内容出来:

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

[oracle@local ass]$ awk -f ass.awk$ORACLE_HOME/zxin/udump/zxin_ora_17541.trc

Ass.Awk Version 1.0.9 - Processing $ORACLE_HOME/zxin/udump/zxin_ora_17541.trc

2451 Lines Processed.

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

system state dumps ==>整个系统的所有进程中的所有对象状态

system state dumps:

1.ALTER SESSION SET EVENTS 'IMMEDIATE TRACE NAME SYSTEMSTATE LEVEL 10'或者event = '604 trace name systemstate,level 10'(INIT.ORA entry)

2、当系统hang住后,如果连sqlplus也不能登录数据库,那么可以使用如下工具

在LINUX下用gdb,在AIX下用dbx,那么在HP-UX下呢,可以用HP的wdb(可以到HP WDB查看HP WDB的详细信息和下载最新的版本。在solaris上,也会有dbx或gdb(各个平台有多种不同的debugger,其他还有adb,mdb等等)。

这里继续上马的例子,当我在linux上使用sid 300的pid的时候,就可以使用ass.awk了

[oracle@localhost ass]$gdb $ORACLE_HOME/bin/oracle

GNU gdb 6.6

Copyright (C) 2006 Free Software Foundation, Inc.

GDB is free software, covered by the GNU General Public License, and you are

welcome to change it and/or distribute copies of it under certain conditions.

Type "show copying" to see the conditions.

There is absolutely no warranty for GDB.Type "show warranty" for details.

This GDB was configured as "--host=i686-pc-linux-gnu --target=i686-pc-linux"...

Using host libthread_db library "/lib/libthread_db.so.1".

Attaching to program: /home/oracle/oracle92/bin/oracle, process 22655

Readingsymbols from /etc/libcwait.so...done.

Loaded symbols for /etc/libcwait.so

Readingsymbols from /home/oracle/oracle92/lib/libodm9.so...done.

Loaded symbols for /home/oracle/oracle92/lib/libodm9.so

Readingsymbols from /home/oracle/oracle92/lib/libskgxp9.so...done.

Loaded symbols for /home/oracle/oracle92/lib/libskgxp9.so

Readingsymbols from /home/oracle/oracle92/lib/libskgxn9.so...done.

Loaded symbols for /home/oracle/oracle92/lib/libskgxn9.so

Readingsymbols from /home/oracle/oracle92/lib/libjox9.so...done.

Loaded symbols for /home/oracle/oracle92/lib/libjox9.so

Readingsymbols from /lib/libdl.so.2...done.

Loaded symbols for /lib/libdl.so.2

Readingsymbols from /lib/libm.so.6...done.

Loaded symbols for /lib/libm.so.6

Readingsymbols from /lib/libpthread.so.0...done.

Loaded symbols for /lib/libpthread.so.0

Readingsymbols from /lib/libnsl.so.1...done.

Loaded symbols for /lib/libnsl.so.1

Readingsymbols from /lib/libc.so.6...done.

Loaded symbols for /lib/libc.so.6

Readingsymbols from /lib/ld-linux.so.2...done.

Loaded symbols for /lib/ld-linux.so.2

Readingsymbols from /lib/libnss_files.so.2...done.

Loaded symbols for /lib/libnss_files.so.2

0xffffe410 in __kernel_vsyscall ()

(gdb)print ksudss(10)

$1 = 181834684

(gdb)detach

Detaching from program: /home/oracle/oracle92/bin/oracle, process 22655

(gdb)quit

这时,使用ass.awk来跟踪这个trc文件

[oracle@localhost ass]$ awk -f ass109.awk/home/oracle/zxindbf/admin/zxin/udump/zxin_ora_22655.trc

Starting Systemstate 1

..............................................................................

...............................................................................

...............................................................................

...........

Ass.Awk Version 1.0.9 - Processing /home/oracle/zxindbf/admin/zxin/udump/zxin_ora_22655.trc

SystemState1

~~~~~~~~~~~~~~~~

1:

2:waiting for 'pmon timer'seq=43334

3:waiting for 'rdbms ipc message'seq=20506

4:waiting for 'rdbms ipc message'seq=56103

5:waiting for 'rdbms ipc message'seq=51900

6:waiting for 'rdbms ipc message'seq=37622

7:waiting for 'rdbms ipc message'seq=37381

8:waiting for 'rdbms ipc message'seq=26290

9:waiting for 'rdbms ipc message'seq=26699

10: waiting for 'rdbms ipc message'seq=6453

11: waiting for 'rdbms ipc message'seq=17840

12: waiting for 'rdbms ipc message'seq=43737

13: waiting for 'smon timer'seq=10561

14: waiting for 'rdbms ipc message'seq=726

15: waiting for 'rdbms ipc message'seq=55882

16: waiting for 'wakeup time manager'seq=15573

17: waiting for 'SQL*Net message from client' seq=272

18: waiting for 'jobq slave wait'seq=2

19: waiting for 'jobq slave wait'seq=2

20: waiting for 'jobq slave wait'seq=2

21: waiting for 'SQL*Net message from client' seq=282

22: waiting for 'SQL*Net message from client' seq=2456

。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。

225:waiting for 'enqueue'[Enqueue TX-00020016-000FA083] seq=49

Cmd: Update

226:waiting for 'SQL*Net message from client' seq=117

Blockers

~~~~~~~~

Above is a list of all the processes. If they are waiting for a resource

then it will be given in square brackets. Below is a summary of the

waited upon resources, together with the holder of that resource.

Notes:

~~~~~

o A process id of '???' implies that the holder was not found in the

systemstate.

Resource Holder State

Enqueue TX-00020016-000FA083224: waiting for 'SQL*Net message from client'

Object Names

~~~~~~~~~~~~

Enqueue TX-00020016-000FA083

137909 Lines Processed.

这里,可以很清楚地看到,这个进程,是由于什么原因卡在那边。

3、ass.awk的用法

先上传下ass.awk的shell脚本

用的时候,在当前目录下生成那个shell脚本(ass.awk),然后,使用如下命令,就会生成了

(n)awk -f ass.awk$ORACLE_BASE/zxin/udump/zxin_ora_22655.trc

参考网址:

你可能感兴趣的:(看懂oracle,trc文件)