ITPub博客

首页 > Linux操作系统 > Linux操作系统 > ORACLE oradebug

ORACLE oradebug

原创 Linux操作系统 作者:DBA_oracle_java 时间:2013-08-27 13:53:20 0 删除 编辑

ORACLE oradebug使用

参考文献:

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

oradebug这个工具oracle很少有文档来说明该工具的功能。该工具主要的功能是给技术支持人员使用的。

下面主要来看看这个工具的使用和主要功能。

1. HELP command

SQL> conn / as sysdba

SQL> oradebug help

HELP           [command]                 Describe one or all commands

SETMYPID                                 Debug current process

SETOSPID                          Set OS pid of process to debug

SETORAPID      ['force']        Set Oracle pid of process to debug

SETORAPNAME                    Set Oracle process name to debug

SHORT_STACK                              Get abridged OS stack

CURRENT_SQL                              Get current SQL

DUMP           [addr]  Invoke named dump

DUMPSGA        [bytes]                   Dump fixed SGA

DUMPLIST                                 Print a list of available dumps

EVENT                              Set trace event in process

SESSION_EVENT                      Set trace event in session

DUMPVAR        [level]  Print/dump a fixed PGA/SGA/UGA variable

DUMPTYPE      

  Print/dump an address with type info

SETVAR           Modify a fixed PGA/SGA/UGA variable

PEEK           [level]      Print/Dump memory

POKE                 Modify memory

WAKEUP                           Wake up Oracle process

SUSPEND                                  Suspend execution

RESUME                                   Resume execution

FLUSH                                    Flush pending writes to trace file

CLOSE_TRACE                              Close trace file

TRACEFILE_NAME                           Get name of trace file

LKDEBUG                                  Invoke global enqueue service debugger

NSDBX                                    Invoke CGS name-service debugger

-G                Parallel oradebug command prefix

-R                Parallel oradebug prefix (return output

SETINST              Set instance list in double quotes

SGATOFILE               Dump SGA to file; dirname in double quotes

DMPCOWSGA      Dump & map SGA as COW; dirname in double quotes

MAPCOWSGA               Map SGA as COW; dirname in double quotes

HANGANALYZE    [level] [syslevel]        Analyze system hang

FFBEGIN                                  Flash Freeze the Instance

FFDEREGISTER                             FF deregister instance from cluster

FFTERMINST                               Call exit and terminate instance

FFRESUMEINST                             Resume the flash frozen instance

FFSTATUS                                 Flash freeze status of instance

SKDSTTPCS                Helps translate PCs to names

WATCH         

  Watch a region of memory

DELETE         watchpoint     Delete a watchpoint

SHOW           watchpoints        Show  watchpoints

DIRECT_ACCESS  Fixed table access

CORE                                     Dump core without crashing process

IPC                                      Dump ipc information

UNLIMIT                                  Unlimit the size of the trace file

PROCSTAT                                 Dump process statistics

CALL           [-t count] [arg1]...[argn]  Invoke function with arguments

1.1 SETMYPID command

在使用oradebug之前,必须指定一个process。使用该语法可以选择自己的process或者也可以指定其他的process.当使用setmypid之后,你可以使用所有的command,比如dumps

 

下面的语句就是选择自己的process

For example

  ORADEBUG SETMYPID

当你准备使用oradebug suspend的时候,请不要使用oradebug setmypid

1.2 SETORAPID or SETOSPID command

1.1里面的东西对应,这两个都是进程追踪指令,setorapid是追踪oracle的进程,setospid追踪的是操作系统的进程。他们分别对应v$process视图中的pidspid

SQL> select pid,spid,username from v$process;

 

       PID SPID                     USERNAME

---------- ------------------------ ---------------

         1

         2 2771                     oracle

         3 2773                     oracle

         4 2775                     oracle

         5 2779                     oracle

 

 

 

 

如下的查询定位SMON进程的pid,spid

  SELECT pid,spid FROM v$process

  WHERE addr =

  (

    SELECT paddr FROM v$bgprocess

    WHERE name = 'SMON'

  );

 

如下查询定位JOB ID21号进程的pid,spid

  SELECT pid,spid FROM v$process

  WHERE addr =

  (

    SELECT paddr FROM v$session

    WHERE sid =

    (

      SELECT sid FROM dba_jobs_running WHERE job = 21

    )

  );

1.3 TRACEFILE_NAME

显示出当前trace文件的位置

SQL> oradebug tracefile_name

/u02/app/oracle/diag/rdbms/szscpdb/szscdb/trace/szscdb_ora_3860.trc

1.4 UNLIMIT

In Oracle 8.1.5 and below the maximum size of the trace file is restricted by default. This means that large dumps (LIBRARY_CACHE, BUFFERS) may fail.

To remove the limitation on the size of the trace file use

    ORADEBUG UNLIMIT

In Oracle 8.1.6 and above the maximum size of the trace file defaults to UNLIMITED

1.5 FULSH

把当前的trace buffer中的数据刷新到trace file

1.6 CLOSE_TRACE

关闭使用当前的trace file

SQL> oradebug close_trace

Statement processed.

 

1.7 SUSPEND

该语句将当前的process挂起。

SQL> SELECT s.USERNAME,p.pid,p.SPID

  2  FROM V$SESSION s,V$PROCESS p

  3  WHERE s.PADDR=p.ADDR AND s.USERNAME='HR';

 

USERNAME                              PID SPID

------------------------------ ---------- ------------------------

HR                                     31 3956

 

SQL> oradebug setospid 3956

Oracle pid: 31, Unix process pid: 3956, image: oracle@szsckj

SQL> oradebug suspend    -----spid2956的会话挂起

Statement processed.

SQL> oradebug resume

Statement processed.  -----取消挂起

 

1.8 DUMPLIST

To list the dumps available in ORADEBUG use

TRACE_BUFFER_ON

TRACE_BUFFER_OFF

LATCHES

PROCESSSTATE

SYSTEMSTATE

INSTANTIATIONSTATE

REFRESH_OS_STATS

CROSSIC

CONTEXTAREA

HANGDIAG_HEADER

HEAPDUMP

HEAPDUMP_ADDR

POKE_ADDRESS

POKE_LENGTH

POKE_VALUE

POKE_VALUE0

GLOBAL_AREA

REALFREEDUMP

FLUSH_JAVA_POOL

POOL_SIMULATOR

PGA_DETAIL_GET

PGA_DETAIL_DUMP

PGA_DETAIL_CANCEL

PGA_SUMMARY

MODIFIED_PARAMETERS

EVENT_TSM_TEST

ERRORSTACK

CALLSTACK

TEST_STACK_DUMP

TEST_GET_CALLER

RECORD_CALLSTACK

EXCEPTION_DUMP

BG_MESSAGES

ENQUEUES

KSTDUMPCURPROC

KSTDUMPALLPROCS

KSTDUMPALLPROCS_CLUSTER

SIMULATE_EOV

KSFQP_LIMIT

KSKDUMPTRACE

DBSCHEDULER

LDAP_USER_DUMP

LDAP_KERNEL_DUMP

DUMP_ALL_OBJSTATS

DUMPGLOBALDATA

HANGANALYZE

HANGANALYZE_PROC

HNGDET_MEM_USAGE_DUMP

HANGANALYZE_GLOBAL

GES_STATE

CGS

OCR

CSS

CRS

SYSTEMSTATE_GLOBAL

GIPC

MMAN_ALLOC_MEMORY

MMAN_CREATE_DEF_REQUEST

MMAN_CREATE_IMM_REQUEST

MMAN_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

GLOBAL_BUFFER_DUMP

BUFFER

PIN_BLOCKS

BC_SANITY_CHECK

PIN_RANDOM_BLOCKS

SET_NBLOCKS

CHECK_ROREUSE_SANITY

DUMP_PINNED_BUFFER_HISTORY

KCBO_OBJ_CHECK_DUMP

KCB_WORKING_SET_DUMP

KCBS_ADV_INT_DUMP

KCBI_DUMP_FREELIST

REDOLOGS

ARCHIVE_ERROR

LOGHIST

REDOHDR

LOGERROR

OPEN_FILES

DATA_ERR_ON

DATA_READ_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_CORRUPT_OFFSET

KRB_PIECE_FAIL

KRB_OPTIONS

KRB_FAIL_INPUT_FILENO

KRB_SIMULATE_NODE_AFFINITY

KRB_TRACE

KRB_BSET_DAYS

KRB_SET_TIME_SWITCH

KRB_OVERWRITE_ACTION

KRB_CORRUPT_SPHEADER_INTERVAL

KRB_CORRUPT_SPHEADER_REPEAT

KRB_CORRUPT_SPBITMAP_INTERVAL

KRB_CORRUPT_SPBITMAP_REPEAT

KRB_CORRUPT_SPBAD_INTERVAL

KRB_CORRUPT_SPBAD_REPEAT

KRB_UNUSED_OPTION

KRBMRSR_LIMIT

KRBMROR_LIMIT

KRBABR_TRACE

KRDRSBF

KRC_TRACE

KRA_OPTIONS

KRA_TRACE

FBTAIL

FBINC

FBHDR

FLASHBACK_GEN

KTPR_DEBUG

DUMP_TEMP

DROP_SEGMENTS

TEST_SPACEBG

TREEDUMP

LONGF_CREATE

KDLIDMP

ROW_CACHE

LIBRARY_CACHE

LIBRARY_CACHE_OBJECT

CURSORDUMP

CURSORTRACE

CURSOR_STATS

XS_SESSION_STATE

SHARED_SERVER_STATE

LISTENER_REGISTRATION

JAVAINFO

KXFPCLEARSTATS

KXFPDUMPTRACE

KXFPBLATCHTEST

KXFXSLAVESTATE

KXFXCURSORSTATE

KXFRHASHMAP

WORKAREATAB_DUMP

KUPPLATCHTEST

OBJECT_CACHE

SAVEPOINTS

RULESETDUMP

RULESETDUMP_ADDR

FAILOVER

OLAP_DUMP

SELFTESTASM

ASMDISK_ERR_ON

ASMDISK_READ_ERR_ON

ASMDISK_ERR_OFF

ASM_EVENREAD

IOERREMUL

IOERREMULRNG

ALRT_TEST

AWR_TEST

AWR_FLUSH_TABLE_ON

AWR_FLUSH_TABLE_OFF

ASHDUMP

ASHDUMPSECONDS

MMON_TEST

ATSK_TEST

HM_FW_TRACE

HM_FDG_VERS

IR_FW_TRACE

KSDTRADV_TEST

 

 

2.oradebug的使用示例

2.1使用oradebug产生10046事件

SQL> SELECT s.USERNAME,p.pid,p.SPID

  2  FROM V$SESSION s,V$PROCESS p

  3  WHERE s.PADDR=p.ADDR AND s.USERNAME='HR';

 

USERNAME                              PID SPID

------------------------------ ---------- ------------------------

HR                                     31 3956

 

SQL> oradebug setospid 3956

Oracle pid: 31, Unix process pid: 3956, image: oracle@szsckj

SQL> oradebug event 10046 trace name context forever, level 12;

SQL>  oradebug tracefile_name

/u02/app/oracle/diag/rdbms/szscpdb/szscdb/trace/szscdb_ora_3956.trc

SQL> oradebug event 10046 trace name context off;

Statement processed.

##显然有一种高端大气上档次的样子

2.2使用oradebug DUMP SGA

SQL> oradebug setmypid

Statement processed.

SQL> oradebug dumpsga

Statement processed.

SQL> oradebug tracefile_name

/u02/app/oracle/diag/rdbms/szscpdb/szscdb/trace/szscdb_ora_5035.trc

 

QQ交流群:300392987

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

请登录后发表评论 登录
全部评论

注册时间:2013-07-02

  • 博文量
    31
  • 访问量
    116900