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: UPDATE txt_test a SET a.FLOWNO='b' WHERE a.FLOWNO='a';
Sid 244: UPDATE txt_test a SET a.FLOWNO='b' WHERE a.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 上 使用 gdb[番茄花园1] sid 300 的pid 的时候,就可以使用 ass.awk 了
[oracle@localhost ass]$ gdb $ORACLE_HOME/bin/oracle 22655[番茄花园2]
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
Reading symbols from /etc/libcwait.so...done.
Loaded symbols for /etc/libcwait.so
Reading symbols from /home/oracle/oracle92/lib/libodm9.so...done.
Loaded symbols for /home/oracle/oracle92/lib/libodm9.so
Reading symbols from /home/oracle/oracle92/lib/libskgxp9.so...done.
Loaded symbols for /home/oracle/oracle92/lib/libskgxp9.so
Reading symbols from /home/oracle/oracle92/lib/libskgxn9.so...done.
Loaded symbols for /home/oracle/oracle92/lib/libskgxn9.so
Reading symbols from /home/oracle/oracle92/lib/libjox9.so...done.
Loaded symbols for /home/oracle/oracle92/lib/libjox9.so
Reading symbols from /lib/libdl.so.2...done.
Loaded symbols for /lib/libdl.so.2
Reading symbols from /lib/libm.so.6...done.
Loaded symbols for /lib/libm.so.6
Reading symbols from /lib/libpthread.so.0...done.
Loaded symbols for /lib/libpthread.so.0
Reading symbols from /lib/libnsl.so.1...done.
Loaded symbols for /lib/libnsl.so.1
Reading symbols from /lib/libc.so.6...done.
Loaded symbols for /lib/libc.so.6
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
Reading symbols 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
System State 1
~~~~~~~~~~~~~~~~
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-000FA083 224: 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
参考网址:
http://www.laoxiong.net/how_debugger_dump_oracle_state.html
http://hi.baidu.com/edeed/blog/item/2a57b07ebc10273c0cd7dabd.html
http://www.eygle.com/archives/2009/11/awk_ass109.html
[番茄花园1]会在 udump 下 生成 trc 文件,而且,这里很奇怪,当 跟踪 sid 244 的时候,当 print ksudss(10) 的时候,会一直卡在这,不知道是什么原因
[番茄花园2]Os 的pid
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/14730395/viewspace-684602/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/14730395/viewspace-684602/