出现了一个问题,当想确认是否有人开启了 系统的trace 事件。
可以通过如下方法去确认,我们可以通过如下实验去看:
1. 在没有开任何事件时,做一次oradebug
- SYS@liuzhou> oradebug setmypid
-
Statement processed.
-
SYS@liuzhou>
-
SYS@liuzhou> oradebug dump events 4
-
Statement processed.
2. 查看udump的trace文件
- SYS@liuzhou> oradebug tracefile_name
-
/u01/app/oracle/admin/liuzhou/udump/liuzhou_ora_3232.trc
-
-
[oracle@milo ~]$ tail /u01/app/oracle/admin/liuzhou/udump/liuzhou_ora_3232.trc
-
*** 2011-10-26 06:15:33.543
-
Dump event group for level SYSTEM
-
TC Addr Evt#(b10) Action TR Addr Arm Life
3. 开启 系统 10046 事件
- SYS@liuzhou> alter system set events '10046 trace name context forever, level 4';
-
-
System altered.
4. 再做一次oradebug
- SYS@liuzhou> oradebug setmypid
-
Statement processed.
-
SYS@liuzhou>
-
SYS@liuzhou> oradebug dump events 4
-
Statement processed.
5. 查看生成到的trace文件
- SYS@liuzhou> oradebug tracefile_name
-
/u01/app/oracle/admin/liuzhou/udump/liuzhou_ora_3232.trc
-
SYS@liuzhou>
6. 查看具体生成的trace文件内容
- [oracle@milo ~]$ tail /u01/app/oracle/admin/liuzhou/udump/liuzhou_ora_3232.trc
-
*** 2011-10-26 06:17:01.698
-
Dump event group for level SYSTEM
-
TC Addr Evt#(b10) Action TR Addr Arm Life
-
36042A04 10046 1 36042a70 0 0
-
TR Name TR level TR address TR arm TR life TR type
-
CONTEXT 4 0 -1 2 952320028
需要注意的是:
a. 只有系统事件才会有记录。
b. "immediate trace"这种一次性的trace,也不会被记录。
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dump Session event的过程:
- oradebug setospid 449
-
oradebug dump events 1
-
oradebug tracefile_name
trace文件里有如下信息:
- *** 2011-10-25 12:08:53.131
-
Received ORADEBUG command 'dump events 1' from process Unix process pid: 13235, image:
-
Dump event group for level SESSION
-
TC Addr Evt#(b10) Action TR Addr Arm Life
-
B7F900B0 10046 1 b7f9011c 0 0
-
TR Name TR level TR address TR arm TR life TR type
-
CONTEXT 10 0 -1 2 -1208418192
-
Received ORADEBUG command 'tracefile_name' from process Unix process pid: 13235, image:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
自己写了个脚本,去获取所有session的event状态,但是如果session多的话,可能会涉及到很多trace文件:
1. 获取当前的客户端连接进程,并生成获取每个session的脚本到get_sess_event.sql
- $ ps -ef | grep LOCAL= | grep -v grep | grep -i <instance_name> |awk 'BEGIN{print "spool sess_trc.txt\n" } {print "oradebug setospid " $2 "\n" "oradebug dump events 1 \n" "oradebug tracefile_name\n"}END{print "spool off"}' > get_sess_event.sql
2. 执行脚本,结果输出到sess_trc.txt
- $ sqlplus / as sysdba
-
SQL> @get_sess_event.sql
3. 查看生成出来的trace文件:
- $ grep -E ".trc" sess_trc.txt | sort -u
-
/opt/oracle/admin/myrac/udump/myrac1_ora_449.trc
-
/opt/oracle/admin/myrac/udump/myrac1_ora_679.trc
在自己的环境测试过(RHEL 5.5), 其他平台没有测试。
希望能帮到各位。:)
阅读(1755) | 评论(0) | 转发(0) |