查看跟踪文件的内容的不同方法

在oracle 10g中,通过 10046等 event可以很好的对系统进行优化、排错;当启用这些事件时,会在udump下生成相应的 xxx.trc 文件,里边记录了相关内容;每个 trc文件是与oracle当中的 进程对于的,比如:
SQL> select spid from v$process where addr = (
  2   select paddr from v$session where sid =
  3   (select sid from v$mystat where rownum = 1)
  4   );

SPID
------------
18555
那么会生成相应的文件名为:
[oracle@rac1 udump]$ ls
para1_ora_1006.trc   para1_ora_21865.trc  para1_ora_2460.trc
para1_ora_18555.trc  para1_ora_22232.trc  para1_ora_2790.trc
比较麻烦的就是查找与数据库登录用户产生的对应的trc文件;上面的算是一个方法;

我们还可以通过设置相关参数来便于查找trc 文件:

SQL> show parameters trace

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
log_archive_trace                    integer     0
sql_trace                            boolean     FALSE
trace_enabled                        boolean     TRUE
tracefile_identifier                 string
SQL> alter session set tracefile_identifier=parameters ;

Session altered.

SQL> alter system dump datafile 4 block 16;

System altered.
--------------------------------------------
查看:
[oracle@rac2 udump]$ ls
para2_ora_11879.trc  para2_ora_21986.trc             para2_ora_31264.trc
para2_ora_1377.trc   para2_ora_22042.trc             para2_ora_3167.trc
para2_ora_15196.trc  para2_ora_22272.trc             para2_ora_3386.trc
para2_ora_15481.trc  para2_ora_22420_paramters.trc   para2_ora_3400.trc
-----
通过以上两种方法能够查找到相关的trc 文件,然后进行查看;

还有一重方法是可以在sqlplus 中直接显示,trc 文件的内容,这样就更容易快速查看信息了,设置如下:SQL> select spid from v$process where addr = (
  2   select paddr from v$session where sid =
  3   (select sid from v$mystat where rownum = 1)
  4   );

SPID
------------
18555

SQL> host mknod /home/oracle/oracle/product/10.2.0/db_1/admin/para/udump/para1_ora_18555.trc p

SQL> set define off
SQL> host grep "WAIT" /home/oracle/oracle/product/10.2.0/db_1/admin/para/udump/para1_ora_18555.trc &

SQL> set define on
SQL> alter session set events '10046 trace name context forever,level 8';     

Session altered.

现在查看:
SQL> select 8 from scott.emp where rownum<2;
WAIT #0: nam='SQL*Net message from client' ela= 896025799 driver id=1650815232 #bytes=1 p3=0 obj#=51148 tim=1282857987227071
WAIT #0: nam='SQL*Net break/reset to client' ela= 124 driver id=1650815232 break?=0 p3=0 obj#=51148 tim=1282857987227754
WAIT #0: nam='SQL*Net message to client' ela= 7 driver id=1650815232 #bytes=1 p3=0 obj#=51148 tim=1282857987227845
WAIT #0: nam='SQL*Net message from client' ela= 455 driver id=1650815232 #bytes=1 p3=0 obj#=51148 tim=1282857987228668
WAIT #2: nam='row cache lock' ela= 17 cache id=7 mode=0 request=3 obj#=51148 tim=1282857987238403
WAIT #2: nam='row cache lock' ela= 1937 cache id=7 mode=0 request=3 obj#=51148 tim=1282857987240387
WAIT #3: nam='row cache lock' ela= 2955 cache id=16 mode=0 request=3 obj#=51148 tim=1282857987247668
WAIT #3: nam='row cache lock' ela= 1645 cache id=16 mode=0 request=3 obj#=51148 tim=1282857987251458
WAIT #1: nam='gc cr grant 2-way' ela= 1307 p1=1 p2=1934 p3=1 obj#=51148 tim=1282857987254899
WAIT #1: nam='db file sequential read' ela= 10721 file#=1 block#=1934 blocks=1 obj#=51148 tim=1282857987265858
WAIT #1: nam='gc cr grant 2-way' ela= 735 p1=1 p2=1935 p3=1 obj#=51148 tim=1282857987269463
WAIT #1: nam='db file sequential read' ela= 1503 file#=1 block#=1935 blocks=1 obj#=51148 tim=1282857987271021
WAIT #3: nam='row cache lock' ela= 1302 cache id=16 mode=0 request=3 obj#=51148 tim=1282857987273628
WAIT #4: nam='gc cr grant 2-way' ela= 1672 p1=1 p2=60345 p3=1 obj#=51148 tim=1282857987278143
WAIT #4: nam='db file sequential read' ela= 2890 file#=1 block#=60345 blocks=1 obj#=51148 tim=1282857987281104
WAIT #3: nam='row cache lock' ela= 1375 cache id=16 mode=0 request=3 obj#=51148 tim=1282857987283530
WAIT #1: nam='gc cr grant 2-way' ela= 1264 p1=1 p2=60346 p3=1 obj#=51148 tim=1282857987288595
WAIT #1: nam='db file sequential read' ela= 1928 file#=1 block#=60346 blocks=1 obj#=51148 tim=1282857987290628
WAIT #3: nam='row cache lock' ela= 7 cache id=16 mode=0 request=3 obj#=51148 tim=1282857987293900
WAIT #3: nam='row cache lock' ela= 1834 cache id=16 mode=0 request=3 obj#=51148 tim=1282857987295777
WAIT #2: nam='SQL*Net message to client' ela= 4 driver id=1650815232 #bytes=1 p3=0 obj#=51148 tim=1282857987299022

         8
----------
         8

SQL> WAIT #2: nam='db file sequential read' ela= 3105 file#=4 block#=36 blocks=1 obj#=51149 tim=1282857987318651
WAIT #2: nam='SQL*Net message from client' ela= 560 driver id=1650815232 #bytes=1 p3=0 obj#=51149 tim=1282857987320252
WAIT #2: nam='SQL*Net message to client' ela= 4 driver id=1650815232 #bytes=1 p3=0 obj#=51149 tim=1282857987320496
WAIT #2: nam='SQL*Net message from client' ela= 1668 driver id=1650815232 #bytes=1 p3=0 obj#=51149 tim=1282857987322204
WAIT #0: nam='SQL*Net message to client' ela= 4 driver id=1650815232 #bytes=1 p3=0 obj#=51149 tim=1282857987322594

这样做更方便一些吧;

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/25656398/viewspace-705251/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/25656398/viewspace-705251/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值