• oradebug神器


    oradebug是SQL*PLUS工具,只要有SYSDBA权限就可以使用,不用做特别设置,但其功能很强大,是每个从事oracle工作人员必不可少的利器。

    下面就介绍一些常用功能:

    1:获得trace文件的名字和位置

    SQL> select * from v$version;
    
    BANNER
    ----------------------------------------------------------------
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod
    PL/SQL Release 10.2.0.4.0 - Production
    CORE    10.2.0.4.0      Production
    TNS for Linux: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    
    SQL> alter session set events 'immediate trace name controlf level 12';
    
    Session altered.
    
    SQL> oradebug setmypid
    Statement processed.
    SQL> oradebug tracefile_name
    /u01/oracle/admin/gdf/udump/gdf_ora_1961.trc
    SQL> 

    2:诊断转储

    可以转储的类型:

    SQL> oradebug dumplist
    EVENTS
    TRACE_BUFFER_ON
    TRACE_BUFFER_OFF
    HANGANALYZE
    LATCHES
    PROCESSSTATE
    SYSTEMSTATE
    INSTANTIATIONSTATE
    REFRESH_OS_STATS
    CROSSIC
    CONTEXTAREA
    HEAPDUMP
    HEAPDUMP_ADDR
    POKE_ADDRESS
    POKE_LENGTH
    POKE_VALUE
    POKE_VALUE0
    GLOBAL_AREA
    MEMORY_LOG
    REALFREEDUMP
    FLUSH_JAVA_POOL
    POOL_SIMULATOR
    PGA_DETAIL_GET
    PGA_DETAIL_DUMP
    PGA_DETAIL_CANCEL
    MODIFIED_PARAMETERS
    EVENT_TSM_TEST
    ERRORSTACK
    CALLSTACK
    HANGANALYZE_PROC
    TEST_STACK_DUMP
    TEST_GET_CALLER
    RECORD_CALLSTACK
    EXCEPTION_DUMP
    BG_MESSAGES
    ENQUEUES
    KSTDUMPCURPROC
    KSTDUMPALLPROCS
    SIMULATE_EOV
    KSFQP_LIMIT
    KSKDUMPTRACE
    DBSCHEDULER
    LDAP_USER_DUMP
    LDAP_KERNEL_DUMP
    DUMP_ALL_OBJSTATS
    DUMPGLOBALDATA
    HANGANALYZE_GLOBAL
    GES_STATE
    OCR
    CSS
    CRS
    SYSTEMSTATE_GLOBAL
    CREATE_DUMMY_REQUEST
    MMAN_ALLOC_MEMORY
    MMAN_CREATE_REQUEST
    MMAN_CREATE_IMM_REQUEST
    DUMP_ALL_COMP_GRANULE_ADDRS
    DUMP_ALL_COMP_GRANULES
    DUMP_ALL_REQS
    DUMP_TRANSFER_OPS
    DUMP_ADV_SNAPSHOTS
    ADJUST_SCN
    NEXT_SCN_WRAP
    CONTROLF
    FLUSH_CACHE
    FULL_DUMPS
    BUFFERS
    RECOVERY
    SET_TSN_P1
    BUFFER
    PIN_BLOCKS
    BC_SANITY_CHECK
    PIN_RANDOM_BLOCKS
    SET_NBLOCKS
    CHECK_ROREUSE_SANITY
    DUMP_PINNED_BUFFER_HISTORY
    REDOLOGS
    LOGHIST
    ARCHIVE_ERROR
    REDOHDR
    LOGERROR
    OPEN_FILES
    DATA_ERR_ON
    DATA_ERR_OFF
    BLK0_FMTCHG
    UPDATE_BLOCK0_FORMAT
    TR_SET_BLOCK
    TR_SET_ALL_BLOCKS
    TR_SET_SIDE
    TR_CRASH_AFTER_WRITE
    TR_READ_ONE_SIDE
    TR_CORRUPT_ONE_SIDE
    TR_RESET_NORMAL
    TEST_DB_ROBUSTNESS
    LOCKS
    GC_ELEMENTS
    FILE_HDRS
    KRB_CORRUPT_INTERVAL
    KRB_CORRUPT_SIZE
    KRB_CORRUPT_REPEAT
    KRB_PIECE_FAIL
    KRB_OPTIONS
    KRB_FAIL_INPUT_FILENO
    KRB_SIMULATE_NODE_AFFINITY
    KRB_TRACE
    KRB_BSET_DAYS
    KRB_SET_TIME_SWITCH
    KRBMRSR_LIMIT
    KRBMROR_LIMIT
    KRC_TRACE
    KRA_OPTIONS
    KRA_TRACE
    FBTAIL
    FBINC
    FBHDR
    FLASHBACK_GEN
    DROP_SEGMENTS
    KTPR_DEBUG
    TREEDUMP
    LONGF_CREATE
    ROW_CACHE
    LIBRARY_CACHE
    CURSORDUMP
    CURSORTRACE
    CURSOR_STATS
    SHARED_SERVER_STATE
    JAVAINFO
    KXFPCLEARSTATS
    KXFPDUMPTRACE
    KXFPBLATCHTEST
    KXFXSLAVESTATE
    KXFXCURSORSTATE
    WORKAREATAB_DUMP
    KUPPLATCHTEST
    OBJECT_CACHE
    SAVEPOINTS
    RULESETDUMP
    RULESETDUMP_ADDR
    OLAP_DUMP
    SELFTESTASM
    IOERREMUL
    ALRT_TEST
    AWR_TEST
    AWR_FLUSH_TABLE_ON
    AWR_FLUSH_TABLE_OFF
    ASHDUMP
    MMON_TEST
    SQL> 


    由于可转储类型太多,鉴于篇幅,现举例常用的几个,其他类似。

    a:controlf

    SQL> oradebug setmypid
    Statement processed.
    SQL> oradebug dump controlf 12
    Statement processed.
    SQL> oradebug tracefile_name
    /u01/oracle/admin/gdf/udump/gdf_ora_1961.trc

    效果与以下语句一样

    alter session set events 'immediate trace name controlf level 12';


    b:redo log header

    SQL> oradebug setmypid
    Statement processed.
    SQL> oradebug dump redohdr 10
    Statement processed.
    SQL> oradebug tracefile_name
    /u01/oracle/admin/gdf/udump/gdf_ora_2198.trc
    SQL> !

    效果同以下语句一样:

    alter session set events 'immediate trace name redohdr level 10'

    其他类似。

    下面举一个具体的案例来说明oradebug的功能:

    追踪SMON:

    [oracle@edhatGRA ~]$ ps -ef | grep smon
    oracle    1947     1  0 17:31 ?        00:00:01 ora_smon_gdf
    oracle    2300  2222  0 19:01 pts/0    00:00:00 grep smon
    [oracle@edhatGRA ~]$ sqlplus /nolog
    
    SQL*Plus: Release 10.2.0.4.0 - Production on Sun May 5 19:01:23 2013
    
    Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.
    
    SQL> conn / as sysdba
    Connected.
    SQL> oradebug setospid 1947
    Oracle pid: 8, Unix process pid: 1947, image: oracle@edhatGRA (SMON)
    SQL> oradebug event 10500 trace name context forever,level 10
    Statement processed.
    SQL> oradebug tracefile_name
    /u01/oracle/admin/gdf/bdump/gdf_smon_1947.trc
    SQL> 

    打开该文件

    [oracle@edhatGRA ~]$ vi /u01/oracle/admin/gdf/bdump/gdf_smon_1947.trc
    /u01/oracle/admin/gdf/bdump/gdf_smon_1947.trc
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    ORACLE_HOME = /u01/oracle/10g
    System name:    Linux
    Node name:      edhatGRA
    Release:        2.6.32-71.el6.i686
    Version:        #1 SMP Wed Sep 1 01:26:34 EDT 2010
    Machine:        i686
    Instance name: gdf
    Redo thread mounted by this instance: 1
    Oracle process number: 8
    Unix process pid: 1947, image: oracle@edhatGRA (SMON)
    
    *** 2013-05-05 19:02:19.833
    *** SERVICE NAME:(SYS$BACKGROUND) 2013-05-05 19:02:19.832
    *** SESSION ID:(164.1) 2013-05-05 19:02:19.832
    Received ORADEBUG command 'event 10500 trace name context forever,level 10' from process Unix process pid: 2304, image:
    *** 2013-05-05 19:02:19.833
    SMON: system monitor process posted
    *** 2013-05-05 19:02:19.833
    SMON: Posted too frequently, trans recovery disabled.
    Received ORADEBUG command 'tracefile_name' from process Unix process pid: 2304, image:
    *** 2013-05-05 19:02:29.420
    SMON: system monitor process posted
    *** 2013-05-05 19:02:29.420
    SMON: Posted too frequently, trans recovery disabled.

    结合oracle的事件,oradebug可发挥强大功能,为你解决问题,深入理解oracle内部原理,提供有益的帮助。

    3:总结

    oradebug对于学习oracle,解决问题,诊断问题是必不可少的工具,本文只是oradebug的入门,更多功能请参阅相关文档。本人提供一些链接:

    a:http://www.dba-oracle.com/t_oradebug_tips.htm

    b:   http://www.juliandyke.com/Diagnostics/Tools/ORADEBUG/ORADEBUG.html

    c:http://www.orafaq.com/wiki/Oradebug








     

  • 相关阅读:
    银行存款利息
    oracle sql 为表创建序列和触发器
    Python socker/subprocess模块练习(ssh案例)
    Python socker模块练习(聊天案例)
    Python 文件上传案例
    文献管理软件Zotero配置及常用插件安装使用(转载)
    记一次jvm闲置,但是应用进程占用高内存
    maven versionsmavenplugin插件
    记录一次spring cglib代理导致空指针异常
    树莓派SD卡容量扩展的方法
  • 原文地址:https://www.cnblogs.com/javawebsoa/p/3061662.html
Copyright © 2020-2023  润新知