Oracle oradebug命令使用說明

tianya_2011發表於2015-11-13
一,Oradebug 命令 幫助文件
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

二, 跟蹤當前會話資訊
   oradebug setmypid  --跟蹤當前會話
   oradebug setospid  --跟蹤系統程式
   oradebug setorapid  --跟蹤ORACLE程式
   oradebug unlimit   --取消trace檔案大小限制     
   oradebug tracefile_name  --檢視trace檔名及位置

三,用oradebug做session級10046或10053
   oradebug setmypid
   oradebug unlimit
   oradebug session_event 10046 trace name context forever ,level 4 --啟用會話級10046
   oradebug event 10046 trace name context off   --關閉10046事件
   oradebug tracefile_name  --檢視tracefile檔案位置及檔名

四, 用oradebug做oracle process級10046
   oradebug setorapid
   oradebug unlimit
   oradebug event 10046 trace name context forever ,level 4
   oradebug event 10046 trace name context off 
   oradebug tracefile_name

五,oradebug系統hang住原因分析
   如果系統HANG住,只要sys使用者可以登陸,那麼用oradebug做原因分析是非常有用的
   oradebug setmypid
   oradebug unlimit
   oradebug setinst all   --RAC環境
   oradebug hanganalyze 3  -- 級別一般指定為3足夠了
   oradebug -g def dump systemstate 10  --RAC環境
   oradebug tracefile_name

六,獲取某程式的狀態資訊
   oradebug setospid 22180
   oradebug dump processstate 10
   oradebug tracefile_name

七,獲取程式錯誤資訊狀態
   oradebug setospid 22180
   oradebug dump errorstack 3

八, 追蹤造成錯誤資訊的原因,如ORA-04031
   oradebug event 4031 trace name errorstack level 3

九,例項:
sqlplus  / as sysdba 
SQL> oradebug setmypid
Statement processed.
SQL> oradebug hanganalyze 3
等1-2分鐘
SQL>oradebug hanganalyze 3
等1-2分鐘
SQL> oradebug tracefile_name
Hang Analysis in /usr/app/oracle/admin/ora10g/bdump/ora10g1_diag_7056.trc
SQL> exit

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/25373498/viewspace-1836818/,如需轉載,請註明出處,否則將追究法律責任。

相關文章