alter
system set events
格式:
通过:符号,可以连续设置多个事件,也可以通过连续使用alter session set events来设置多个事件。
格式说明:
eventnumber指触发dump的事件号,事件号可以是Oracle错误号(出现相应错误时跟踪指定的事件)或oralce内部事件号,内部事件号在10000到10999之间,不能与immediate关键字同用。
immediate关键字表示命令发出后,立即将指定的结构dump到跟踪文件中,这个关键字只用在alter session语句中,并且不能与eventnumber、forever关键字同用。
trace name是关键字
eventname指事件名称(见后面),即要进行dump的实际结构名。若eventname为context,则指根据内部事件号进行跟踪。
forever关键字表示事件在实例或会话的周期内保持有效状态,不能与immediate同用。
level为事件级别关键字。但在dump错误栈(errorstack)时不存在级别。
levelnumber表示事件级别号,一般从1到10,1表示只dump结构头部信息,10表示dump结构的所有信息。
常用转储命令:
一.Memory Dumps
1).Global Area
Alter SESSION SET EVENTS 'immediate trace name global_area level n';
1 包含PGA
2 包含SGA
4 包含UGA
8 包含indrect memory
2).Library Cache
Alter SESSION SET EVENTS 'immediate trace name library_cache level n';
1 library cache统计信息
2 包含hash table histogram
3 包含object handle
4 包含object结构(Heap 0)
3).Row Cache
Alter SESSION SET EVENTS 'immediate trace name row_cache level n';
1 row cache统计信息
2 包含hash table histogram
8 包含object结构
4).Buffers
Alter SESSION SET EVENTS 'immediate trace name buffers level n';
1 buffer header
2 level 1 + block header
3 level 2 + block contents
4 level 1 + hash chain
5 level 2 + hash chain
6 level 3 + hash chain
8 level 4 + users/waiters
9 level 5 + users/waiters
10 level 6 + users/waiters
5).Buffer
Alter SESSION SET EVENTS 'immediate trace name buffer level n';
n为某个指定block的rdba,该命令可以转储某个block在buffer中的所有版本。
6).Heap
Alter SESSION SET EVENTS 'immediate trace name heapdump level level';
1 PGA摘要
2 SGA摘要
4 UGA摘要
8 Current call(CGA)摘要
16 User call(CGA)摘要
32 Large call(LGA)摘要
1025 PGA内容
2050 SGA内容
4100 UGA内容
8200 Current call内容
16400 User call内容
32800 Large call内容
7).Sub Heap
oracle 9.0.1版本之前
Alter SESSION SET EVENTS 'immediate trace name heapdump_addr level n';
若n为subheap的地址,转储的是subheap的摘要信息
若n为subheap的地址+1,转储的则是subheap的内容
oracle 9.2.0版本之后
Alter SESSION SET EVENTS 'immediate trace name heapdump_addr level n, addr m';
其中m为subheap的地址
n为1转储subheap的摘要,n为2转储subheap的内容
8).Process State
Alter SESSION SET EVENTS 'immediate trace name processstate level n';
9).System State
Alter SESSION SET EVENTS 'immediate trace name systemstate level n';
10).Error State
Alter SESSION SET EVENTS 'immediate trace name errorstack level n';
0 Error stack
1 level 0 + function call stack
2 level 1 + process state
3 level 2 + context area
11).Hang Analysis
Alter SESSION SET EVENTS 'immediate trace name hanganalyze level n';
12).Work Area
Alter SESSION SET EVENTS 'immediate trace name workareatab_dump level n';
1 SGA信息
2 Workarea Table摘要信息
3 Workarea Table详细信息
13).Latches
Alter SESSION SET EVENTS 'immediate trace name latches level n';
1 latch信息
2 统计信息
14).Events
Alter SESSION SET EVENTS 'immediate trace name events level n';
1 session
2 process
3 system
15).Locks
Alter SESSION SET EVENTS 'immediate trace name locks level n';
16).Shared Server Process
Alter SESSION SET EVENTS 'immediate trace name shared_server_state level n';
n取值为1~14
17).Background Messages
Alter SESSION SET EVENTS 'immediate trace name bg_messages level n';
n为pid+1
二.File Dumps
1).Block
oracle 7之前
Alter SESSION SET EVENTS 'immediate trace name blockdump level n';
n为block的rdba
oracle8以后
Alter SYSTEM DUMP DATAFILE file# BLOCK block#;
Alter SYSTEM DUMP DATAFILE file#
BLOCK MIN minimum_block#
BLOCK MAX maximum_block#;
2).Tree Dump
Alter SESSION SET EVENTS 'immediate trace name treedump level n';
n为object_id
3).Undo Segment Header
Alter SYSTEM DUMP UNDO_HEADER 'segment_name';
4).Undo for a Transaction
Alter SYSTEM DUMP UNDO BLOCK 'segment_name' XID xidusn xidslot xidsqn;
5).File Header
Alter SESSION SET EVENTS 'immediate trace name file_hdrs level n';
1 控制文件中的文件头信息
2 level 1 + 文件头信息
3 level 2 + 数据文件头信息
10 level 3
6).Control file
Alter SESSION SET EVENTS 'immediate trace name controlf level n';
1 文件头信息
2 level 1 + 数据库信息 + 检查点信息
3 level 2 + 可重用节信息
10 level 3
7).Redo log Header
Alter SESSION SET EVENTS 'immediate trace name redohdr level n';
1 控制文件中的redo log信息
2 level 1 + 文件头信息
3 level 2 + 日志文件头信息
10 level 3
8).Redo log
Alter SYSTEM DUMP LOGFILE 'FileName';
Alter SYSTEM DUMP LOGFILE 'FileName'
SCN MIN MinimumSCN
SCN MAX MaximumSCN
TIME MIN MinimumTime
TIME MAX MaximumTime
LAYER Layer
OPCODE Opcode
DBA MIN FileNumber . BlockNumber
DBA MAX FileNumber . BlockNumber
RBA MIN LogFileSequenceNumber . BlockNumber
RBA MAX LogFileSequenceNumber . BlockNumber;
其中time = (((((yyyy - 1988)) * 12 + mm - 1) * 31 + dd - 1) * 24 + hh) * 60 + mi) * 60 + ss;
9).Loghist
Alter SESSION SET EVENTS 'immediate trace name loghist level n';
1 dump控制文件中最早和最迟的日志历史项
>1 dump 2^n个日志历史项
eventnumber
1、例举
Code Description
10000 Controlfile debug event, name 'control_file'
10001 Controlfile crash event1
10002 Controlfile crash event2
10003 Controlfile crash event3
10004 Controlfile crash event4
10005 Trace latch operations for debugging
10006 Testing - block recovery forced
10007 Log switch debug crash after new log select, thread %s
10008 Log switch debug crash after new log header write, thread %s
10009 Log switch debug crash after old log header write, thread %s
10010 Begin Transaction
10011 End Transaction
10012 Abort Transaction
10013 Instance Recovery
10014 Roll Back to Save Point
10015 Undo Segment Recovery
10016 Undo Segment extend
10017 Undo Segment Wrap
10018 Data Segment Create
10019 Data Segment Recovery
10020 Partial link restored to linked list (KSG)
10021 Latch cleanup for state objects (KSS)
10022 Trace ktsgsp
10023 Create Save Undo Segment
10024 Write to Save Undo
10025 Extend Save Undo Segment
10026 Apply Save Undo
10027 Latch cleanup for enqueue locks (KSQ)
10028 Latch cleanup for enqueue resources (KSQ)
10029 Session logon (KSU)
10030 Session logoff (KSU)
10031 Sort debug event (S*)
10032 Sort statistics (SOR*)
10033 Sort run information (SRD*/SRS*)
10034 Access path analysis (APA*)
10035 Parse SQL statement (OPIPRS)
10036 Create remote row source (QKANET)
10037 Allocate remote row source (QKARWS)
10038 Dump row source tree (QBADRV)
10039 Type checking (OPITCA)
10040 Dirty cache list
10041 Dump undo records skipped
10042 Trap error during undo application
10043 Check consistency of owner/waiter/converter lists in KSQ
10044 Free list undo operations
10045 Free list update operations - ktsrsp, ktsunl
10046 Enable SQL statement timing
10047 Trace switching of sessions
10048 Undo segment shrink
10049 Protect library cache memory heaps
10050 Sniper trace
10051 Trace OPI calls
10052 Don't clean up obj$
10053 CBO Enable optimizer trace
10054 Trace UNDO handling in MLS
10055 Trace UNDO handing
10056 Dump analyze stats (kdg)
10057 Suppress file names in error messages
10058 Use table scan cost in tab$.spare1
10059 Simulate error in logfile create/clear
10060 CBO Enable predicate dump
10061 Disable SMON from cleaning temp segment
10062 Disable usage of OS Roles in osds
10063 Disable usage of DBA and OPER privileges in osds
10064 Thread enable debug crash level %s, thread %s
10065 Limit library cache dump information for state object dump
10066 Simulate failure to verify file
10067 Force redo log checksum errors - block number
10068 Force redo log checksum errors - file number
10069 Trusted Oracle test event
10070 Force datafile checksum errors - block number
10071 Force datafile checksum errors - file number
10072 Protect latch recovery memory
10073 Have PMON dump info before latch cleanup
10074 Default trace function mask for kst
10075 CBO Disable outer-join to regular join conversion
10076 CBO Enable cartesian product join costing
10077 CBO Disable view-merging optimization for outer-joins
10078 CBO Disable constant predicate elimination optimization
10079 Trace data sent/received via SQL*Net
10080 Dump a block on a segment list which cannot be exchanged
10081 Segment High Water Mark has been advanced
10082 Free list head block is the same as the last block
10083 A brand new block has been requested from space management
10084 Free list becomes empty
10085 Free lists have been merged
10086 CBO Enable error if kko and qka disagree on oby sort
10087 Disable repair of media corrupt data blocks
10088 CBO Disable new NOT IN optimization
10089 CBO Disable index sorting
10090 Invoke other events before crash recovery
10091 CBO Disable constant predicate merging
10092 CBO Disable hash join
10093 CBO Enable force hash joins
10094 Before resizing a data file
10095 Dump debugger commands to trace file
10096 After the cross instance call when resizing a data file
10097 After generating redo when resizing a data file
10098 After the OS has increased the size of a data file
10099 After updating the file header with the new file size
10100 After the OS has decreased the size of a data file
10101 Atomic redo write recovery
10102 Switch off anti-joins
10103 CBO Disable hash join swapping
10104 Dump hash join statistics to trace file
10105 CBO Enable constant pred trans and MPs w WHERE-clause
10106 CBO Disable evaluating correlation pred last for NOT IN
10107 CBO Always use bitmap index
10108 CBO Don't use bitmap index
10109 CBO Disable move of negated predicates
10110 CBO Try index rowid range scans
10111 Bitmap index creation switch