SQL> select pid,spid,username from v$process; PID是oracle 的pid ,SPID是操作系统的pid
PID SPID USERNAME
---------- ------------------------ ---------------
1
2 2687 oracle
3 2689 oracle
4 2691 oracle
5 2695 oracle
6 2697 oracle
7 2699 oracle
8 2701 oracle
9 2703 oracle
10 2705 oracle
11 2707 oracle
PID SPID USERNAME
---------- ------------------------ ---------------
12 2709 oracle
13 2711 oracle
14 2713 oracle
15 2715 oracle
16 2717 oracle
17 2719 oracle
18 2721 oracle
19 3190 oracle
20 3076 oracle
22 3192 oracle
23 2735 oracle
PID SPID USERNAME
---------- ------------------------ ---------------
24 2737 oracle
25 2739 oracle
26 2741 oracle
27 2744 oracle
28 2798 oracle
29 2777 oracle
30 2800 oracle
31 2873 oracle
40 3153 oracle
31 rows selected.
用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
SQL> oradebug help
HELP [command] Describe one or all commands
SETMYPID Debug current process --跟踪当前会话
SETOSPID <ospid> Set OS pid of process to debug --跟踪系统进程
SETORAPID <orapid> ['force'] Set Oracle pid of process to debug --跟踪ORACLE进程
SETORAPNAME <orapname> Set Oracle process name to debug --查看trace文件名及位置
SHORT_STACK Get abridged OS stack
CURRENT_SQL Get current SQL
DUMP <dump_name> <lvl> [addr] Invoke named dump
PDUMP [interval=<interval>] Invoke named dump periodically
[ndumps=<count>] <dump_name> <lvl> [addr]
DUMPSGA [bytes] Dump fixed SGA
DUMPLIST Print a list of available dumps
EVENT <text> Set trace event in process
SESSION_EVENT <text> Set trace event in session
DUMPVAR <p|s|uga> <name> [level] Print/dump a fixed PGA/SGA/UGA variable
DUMPTYPE <address> <type> <count> Print/dump an address with type info
SETVAR <p|s|uga> <name> <value> Modify a fixed PGA/SGA/UGA variable
PEEK <addr> <len> [level] Print/Dump memory
POKE <addr> <len> <value> Modify memory
WAKEUP <orapid> 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
SETTRACEFILEID <identifier name> Set tracefile identifier
LKDEBUG Invoke global enqueue service debugger
NSDBX Invoke CGS name-service debugger
-G <Inst-List | def | all> Parallel oradebug command prefix
-R <Inst-List | def | all> Parallel oradebug prefix (return output
SETINST <instance# .. | all> Set instance list in double quotes
SGATOFILE <SGA dump dir> Dump SGA to file; dirname in double quotes
DMPCOWSGA <SGA dump dir> Dump & map SGA as COW; dirname in double quotes
MAPCOWSGA <SGA dump dir> 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 <ifname> <ofname> Helps translate PCs to names
WATCH <address> <len> <self|exist|all|target> Watch a region of memory
DELETE <local|global|target> watchpoint <id> Delete a watchpoint
SHOW <local|global|target> watchpoints Show watchpoints
DIRECT_ACCESS <set/enable/disable command | select query> Fixed table access
IPC Dump ipc information
UNLIMIT Unlimit the size of the trace file --取消trace文件大小限制
CALL [-t count] <func> [arg1]...[argn] Invoke function with arguments
CORE Dump core without crashing process
PROCSTAT Dump process statistics