码迷,mamicode.com
首页 > 数据库 > 详细

Oracle警告、跟踪文件(10046、死锁等跟踪)

时间:2016-01-13 19:18:36      阅读:290      评论:0      收藏:0      [点我收藏+]

标签:

跟踪文件由各个后台进程生成,警报日志中记录关键操作包括:
    ·所有启动和关闭命令,包括中间命令,如alter database mount
    ·实例的所有内部错误(ORA-600错误,只能报告给Oracle Support解决)
    ·任何检测到的数据文件块损坏情况
    ·任何已经发生的死锁
    ·影响数据库物理结构的所有操作,如创建或重命名数据文件和联机重做日志
    ·调整内部参数值的alter system命令
    ·所有日志开关和日志归档文件

 

以Oracle死锁为例:

确定警告日志文件的存放目录

SQL>show parameter dump_dest

 

技术分享

 

详细的trc日志如下:

*** 2015-12-15 08:47:31.756
DEADLOCK DETECTED ( ORA-00060 )
 
[Transaction Deadlock]
 
The following deadlock is not an ORACLE error. It is a
deadlock due to user error in the design of an application
or from issuing incorrect ad-hoc SQL. The following
information may aid in determining the deadlock:
 
Deadlock graph:
                       ---------Blocker(s)--------  ---------Waiter(s)---------
Resource Name          process session holds waits  process session holds waits
TX-000a000d-0009fdf2        31     745     X             34     817           X
TX-000b0012-00064744        34     817     X             31     745           X
 
session 745: DID 0001-001F-001BA3CC    session 817: DID 0001-0022-000E48FD 
session 817: DID 0001-0022-000E48FD    session 745: DID 0001-001F-001BA3CC 
 
Rows waited on:
  Session 745: obj - rowid = 0001B049 - AAAbBJAAHAAEN4SAAF
  (dictionary objn - 110665, file - 7, block - 1105426, slot - 5)
  Session 817: obj - rowid = 0001B049 - AAAbBJAAHAAEN4SAAE
  (dictionary objn - 110665, file - 7, block - 1105426, slot - 4)
 
----- Information for the OTHER waiting sessions -----
Session 817:
  sid: 817 ser: 32301 audsid: 7129480 user: 93/LC019999
    flags: (0x100045) USR/- flags_idl: (0x1) BSY/-/-/-/-/-
    flags2: (0x40009) -/-/INC
  pid: 34 O/S info: user: SYSTEM, term: PERFTESTDB66, ospid: 21068
    image: ORACLE.EXE (SHAD)
  client details:
    O/S info: user: Administrator, term: WANGZG-INSPUR, ospid: 2736:11836
    machine: WORKGROUP\WANGZG-INSPUR program: plsqldev.exe
    application name: PL/SQL Developer, hash value=1190136663
    action name: SQL 窗口 - 新建, hash value=2127054360
  current SQL:
  update tableName
set name = ‘tkk1215‘
where xxxxxxxxxxxxxxx
 
----- End of information for the OTHER waiting sessions -----
 
Information for THIS session:
 
----- Current SQL Statement for this session (sql_id=01yxw4cmbqgg3) -----
update tableName
set name = ‘xyy1215‘
where xxxxxxx
===================================================

 

 

SQL语句跟踪
1.用户级自我跟踪
    alter session set sql_trace=true;
    在同一个session中执行SQL语句,将会产生跟踪文件sid_ora_spid.trc(spid为系统进程id):
    /u01/app/oracle/diag/rdbms/sid/sid/trace/sid_ora_spid.trc
    spid:系统进程id,可以通过语句查看:
    select s.username,s.sid,s.serial#,p.spid,s.program
      from v$session s,v$process p
     where s.paddr = p.addr 
       and s.sid = userenv(‘sid‘);


    alter session set sql_trace=false;

2.系统级跟踪
    alter system set sql_trace=true scope=memory;
    在任何session中执行SQL语句,产生跟踪文件sid_ora_spid.trc(spid为系统进程id):
    /u01/app/oracle/diag/rdbms/sid/sid/trace/sid_ora_spid.trc


    alter system set sql_trace=false scope=memory;


3.用户级的DBA跟踪
    使用Oracle的PL/SQL包DBMS_SYSTEM
    (1)从session性能视图中查出用户的sid和serial#.

    select s.username,s.sid,s.serial#,p.spid,s.program 
      from v$session s,v$process p 
     where s.paddr = p.addr  
       and s.username is not null  
       and p.background is null; 


    USERNAME                              SID    SERIAL# SPID                     PROGRAM
    ------------------------------ ---------- ---------- ------------------------ -----------------------------
    SYSTEM                                 13      35114  9172                     plsqldev.exe
    SYSTEM                                248      32295  9225                     plsqldev.exe
    SYS                                       14      36202  9111                     sqlplus@gymvm (TNS V1-V3)
    (2)跟踪用户会话
    execute sys.dbms_system.set_sql_trace_in_session(248,32295,true);
    在任何id为248的session中执行SQL语句,产生跟踪文件sid_ora_spid.trc(spid为系统进程id):
    /u01/app/oracle/diag/rdbms/sid/sid/trace/sid_ora_9225.trc
    (3)停止跟踪
    execute sys.dbms_system.set_sql_trace_in_session(248,32295,true);

4.SQL_TRACE跟踪SQL语句执行情况的内容
    ·解析、执行、取数据的计数
    ·CPU时间和占用时间
    ·物理读和逻辑读
    ·处理行数目
    ·所解析的用户名
    ·每次提交和回滚的情况.

5.格式化跟踪文件(tkprof)
    使用tkprof程序可以将跟踪文件转化成可以阅读的文本文件,tkprof语法:
    tkprof tracefile outputfile [explain=user/password] [table=schema.tablename] 
                                [print=integer] [insert= ] [sys= ] [sort= ] ...
    $ tkprof tracefile outputfile

Oracle警告、跟踪文件(10046、死锁等跟踪)

标签:

原文地址:http://www.cnblogs.com/zhaoguan_wang/p/5127982.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!