Dumps
Immediate Dumps
Conditional Dumps
Memory Dumps
File Dumps
Immediate Dumps
There are three ways of specifying an immediate dump
Immediate dumps can be specified using the ALTER SESSION command
ALTER SESSION SET EVENTS
'immediate trace name dump level level';
Immediate dumps can be specified in ORADEBUG
ORADEBUG DUMP dump level
Immediate dumps can also be specified using the DBMS_SYSTEM.SET_EV procedure
EXECUTE dbms_system.set_ev (sid,serial#,65535,level,'dump');
Immediate dumps cannot be invoked from init.ora
Conditional Dumps
Conditional dumps are invoked when an error occurs
Conditional dump can be specified in the init.ora file e.g
event="error trace name dump level level"
Conditional dumps can be specified in the current session
ALTER SESSION SET EVENTS
'error trace name dump level level';
Conditional dumps can be specified in ORADEBUG
ORADEBUG EVENT error trace name dump level level
ORADEBUG SESSION_EVENT error trace name dump level level
Memory Dumps
Dumping the Global Area
The following command can be used to dump the global area
ALTER SESSION SET EVENTS 'immediate trace name global_area level level';
Levels are (bitmask)
Level
Description
1
Include PGA
2
Include SGA
4
Include UGA
8
Include indirect memory dumps
The following ORADEBUG command has the same effect
ORADEBUG DUMP GLOBAL_AREA level
The structure of the fixed SGA is externalised in X$KSMFSV
Name
Type
Description
ADDR
RAW(4)
INDX
NUMBER
INST_ID
NUMBER
KSMFSNAM
VARCHAR2(64)
Name
KSMFSTYP
VARCHAR2(64)
Type
KSMFSADR
RAW(4)
Address
KSMFSSIZ
NUMBER
Size in Bytes
This can be queried using
SELECT
SUBSTR (ksmfsnam,1,20) AS "Name",
SUBSTR (ksmfstyp,1,20) AS "Type",
ksmfsadr AS "Address",
ksmfssiz AS "Size"
FROM x$ksmfsv;
Dumping the Library Cache
The following command can be used to dump the library cache
ALTER SESSION SET EVENTS 'immediate trace name library_cache level level';
where level is one of the following
Level
Description
1
Dump library cache statistics
2
Include hash table histogram
3
Include dump of object handles
4
Include dump of object structures (heap 0)
For example
ALTER SESSION SET EVENTS 'immediate trace name library_cache level 1';
The following ORADEBUG command has the same effect
ORADEBUG DUMP LIBRARY_CACHE level
Dumping the Row (Dictionary) Cache
ROW_CACHE
The row cache is also known as the dictionary cache
The following command can be used to dump the row cache
ALTER SESSION SET EVENTS 'immediate trace name row_cache level level';where level is one of the following
Level
Description
1
Dump row cache statistics
2
Include hash table histogram
8
Include dump of object structures
For example
ALTER SESSION SET EVENTS 'immediate trace name row_cache level 1';The following ORADEBUG command has the same effect
ORADEBUG DUMP ROW_CACHE level
Dumping Multiple Buffers
Multiple Buffers
To dump buffer headers and buffer contents for buffers currently in the cache
ALTER SESSION SET EVENTS 'immediate trace name buffers level level';where level is one of the following
Level
Description
1
Buffer headers only
2
Level 1 + block headers
3
Level 2 + block contents
4
Buffer headers only + hash chain
5
Level 1 + block headers + hash chain
6
Level 2 + block contents + hash chain
8
Buffer headers only + hash chain + users/waiters
9
Level 1 + block headers + hash chain + users/waiters
10
Level 2 + block contents + hash chain + users/waiters
Dumping Individual Buffers
Individual Buffers
In Oracle 8.0 and above is is possible to dump buffer all buffers currently in the cache for a specific block
For example where a block has been modified and is subject to consistent read from a number of transactions, there may be more than one copy of the block in the buffer cache
First identify the tablespace number for the block e.g for tablespace TS01
SELECT ts# FROM sys.ts$ WHERE name = 'TS01';Set the tablespace number using
ALTER SESSION SET EVENTS 'immediate trace name set_tsn_p1 level level';where level is the tablespace number + 1
Identify the relative DBA for the block
This is equal to
RelativeFileNumber * 4194304 + BlockNumbere.g. for a block with relative file number of 5 and a block number of 127874
5 * 4194304 + 127874 = 21099394Dump the buffer using
ALTER SESSION SET EVENTS 'immediate trace name buffer level level';where level is the relative DBA e.g.
ALTER SESSION SET EVENTS 'immediate trace name buffer level 21099394';
Dumping Memory Heaps
Memory Heaps
To dump the top-level heap in a memory area
ALTER SESSION SET EVENTS 'immediate trace name heapdump level level';Levels are
Level
Description
1
PGA summary
2
SGA summary
4
UGA summary
8
Callheap (Current)
16
Callheap (User)
32
Large pool
64
Streams pool
128
Java pool
1025
PGA with contents
2050
SGA with contents
4100
UGA with contents
8200
Callheap with contents (Current)
16400
Callheap with contents (User)
32800
Large pool with contents
65600
Streams pool with contents
131200
Java pool with contents
Levels are correct to Oracle 10.2.0.1
The levels can be combined. For example a level 3 dump will contain both the PGA and SGA
Dumping Memory Subheaps
Memory Subheaps
Each heap may have one or more subheaps. These can be dumped using the command
ALTER SESSION SET EVENTS 'immediate trace name heapdump_addr level level';where the level is the address of the subheap.
The syntax for this command changed in Oracle 9.2
Oracle 9.0.1 and below
Oracle 9.2.0 and above
Oracle 9.0.1 and below
For Oracle 9.0.1 and below a summary dump is obtained by setting the level to the decimal value of the address. A detailed dump is obtained by adding 1 to the decimal value of the address.
For example to dump the subheap at address 0x8057eb78, first convert the address to decimal (2153245560)
The subheap address can be found in the heapdump, for example
ds=0x8057eb78For a summary dump use
ALTER SESSION SET EVENTS 'immediate trace name heapdump_addr level 2153245560';For a detailed dump, add 1 to the address e.g.
ALTER SESSION SET EVENTS 'immediate trace name heapdump_addr level 2153245561';Oracle 9.2.0 and above
In Oracle 9.2 and above, for a summary dump
ALTER SESSION SET EVENTS 'immediate trace name heapdump_addr level 1, addr 2153245560';The following ORADEBUG command has the same effect
ORADEBUG DUMP HEAPDUMP_ADDR 1 2153245560In Oracle 9.2 and above, for a detailed dump
ALTER SESSION SET EVENTS 'immediate trace name heapdump_addr level 2, addr 2153245560';Note that in Oracle 9.2 it is no longer necessary to add 1 to the address
The following ORADEBUG command has the same effect
ORADEBUG DUMP HEAPDUMP_ADDR 2 2153245560
Dumping Process State
Process State
To dump the process state use:
ALTER SESSION SET EVENTS 'immediate trace name processstate level level';For example
ALTER SESSION SET EVENTS 'immediate trace name processstate level 10';The following ORADEBUG command has the same effect
ORADEBUG DUMP PROCESSSTATE levelThe amount of library cache dump output for state object dumps can be limited using event 10065
Dumping System State
System State
A system state dump contains the process state for every process.
Every state object for every process is dumped.
A state object represents the state of a database resource including
processes
sessions
enqueues (locks)
buffers
State objects are held in the SGA
A system state dump does not represent a snapshot of the instance because the database is not frozen for the duration of the dump. The start point of the dump will be earlier than the end point.
Oracle recommends the use of system state dumps to diagnose
hanging databases
slow databases
database errors
waiting processes
blocking processes
resource contention
To dump the system state use
ALTER SESSION SET EVENTS 'immediate trace name systemstate level level';For example
ALTER SESSION SET EVENTS 'immediate trace name systemstate level 10';The following ORADEBUG command has the same effect
ORADEBUG DUMP SYSTEMSTATE levelA system state dump can be triggered by an error, for example the following init.ora parameter
event = "60 trace name systemstate level 10"will generate a systemstate dump whenever a deadlock is detected (ORA-00060)
The amount of library cache dump output for state object dumps can be limited using event 10065
Dumping the Error Stack
Error Stack
An error stack describes the current state of a process. It includes the current SQL statement and the process state for the process.
Oracle recommends taking an error stack dump to diagnose
what the process is doing
a problem identified by a systemstate dump
processes looping or hanging
Error stack dumps can also be triggered by an error
To dump an error stack use
ALTER SESSION SET EVENTS 'immediate trace name errorstack level level';where level is one of the following
Level
Description
0
Error stack only
1
Error stack and function call stack
2
As level 1 plus the process state
3
As level 2 plus the context area
The following ORADEBUG command has the same effect
ORADEBUG DUMP ERRORSTACK levelAn alternative syntax for the same command is
ORADEBUG EVENT IMMEDIATE TRACE NAME ERRORSTACK levelTo dump a level 3 errorstack when ORA-00942 (table or view does not exist) use
ALTER SESSION SET EVENTS '942 trace name errorstack level 3';A conditional errorstack dump can also be specified without a level e.g.
ALTER SESSION SET EVENTS '604 trace name errorstack';Alternatively a conditional errorstack dump can be specified in the init.ora file
event = "942 trace name errorstack level 3"Errorstacks can also be dumped conditionally using ORADEBUG
ORADEBUG EVENT 942 TRACE NAME ERRORSTACK LEVEL 3A level 3 errorstack contains the following sections
Call Stack Trace
Files Currently Opened
Process State
Pinned Buffer History
Cursor Dump
Fixed PGA
Fixed SGA
Fixed UGA
In memory trace dump
Dumping Hang Analysis
Hang Analysis
This dump is available in Oracle 8.0.6 and Oracle 8.1.6 and above. It is not available in Oracle 8.1.5.
It contains
systemstate level 1 dump
processes currently waiting, blocking or spinning
errorstacks
The HANGANALYZE dump is more selective than a SYSTEMSTATE dump in that it only includes details of processes of interest. It is particularly intended for situations where a database is hanging.
For example
ALTER SESSION SET EVENTS 'immediate trace name hanganalyze level 5';The following ORADEBUG command has the same effect
ORADEBUG DUMP HANGANALYZE levele.g.
ORADEBUG DUMP HANGANALYZE 5A HANGANALYZE dump can also be generated on an error e.g. when a deadlock is detected (ORA-00060) using the init.ora file
event = "60 trace name hanganalyze level 5"or in the current session using
ALTER SESSION SET EVENTS '60 trace name hanganalyze level 5';
Dumping Work Areas
Work Areas
To dump the current workareas use
ALTER SESSION SET EVENTS 'immediate trace name workareatab_dump level level';Levels are (bitmask)
Level
Description
1
Global SGA Info
2
Workarea Table (Summary)
3
Workarea Table (Detail)
The following ORADEBUG command has the same effect
ORADEBUG DUMP WORKAREATAB_DUMP level
Dumping Enqueues
Enqueues
To dump the current enqueue states use
ALTER SESSION SET EVENTS 'immediate trace name enqueues level level';Levels are
Level
Description
1
Dump a summary of active resources and locks, the resource free list and the hash table
2
Include a dump of resource structures
3
Include a dump of lock structures
The following ORADEBUG command has the same effect
ORADEBUG DUMP ENQUEUES level
Dumping Latches
Latches
To dump the current latch status use
ALTER SESSION SET EVENTS 'immediate trace name latches level level';Levels are
Level
Description
1
Latches
2
Include statistics
The following ORADEBUG command has the same effect
ORADEBUG DUMP LATCHES level
Dumping Events
Events
To dump the events set for the current session
ALTER SESSION SET EVENTS 'immediate trace name events level level';Levels are
Level
Description
1
Session
2
Process
4
System
The following ORADEBUG command has the same effect
ORADEBUG DUMP EVENTS level
Dumping Shared Server (MTS) Processes
Shared Server (MTS) Processes
To dump buffer headers and buffer contents for buffers currently in the cache
ALTER SESSION SET EVENTS 'immediate trace name shared_server_state level level';where level is in the range 1 to 14
The following ORADEBUG command has the same effect
ORADEBUG DUMP SHARED_SERVER_STATE levelIn Oracle 8.1.7 and below, this dump is called MTSSTATE
Dumping Background Messages
Background process messages can be traced using
ALTER SESSION SET EVENTS 'immediate trace name bg_messages level level';where level identifies the background process (+1)
For example to find the level of SMON, first identify the index number using the following query
SELECT indx + 1 FROM x$ksbdp WHERE ksbdpnam = 'SMON';The following ORADEBUG command has the same effect
ORADEBUG DUMP BG_MESSAGES level
File Dumps
Dumping Columns
Columns
To dump the internal representation of columns use the DUMP built-in function
DUMP (column_value, format)where format is
Format
Description
8
Octal
10
Decimal
16
Hexadecimal
17
Single Character
For example
SELECT DUMP (1001,16) FROM dual;returns
Typ=2 Len=3: c2,b,2To output a column in hexadecimal use the 'XXXXXXXX' format mask e.g.
SELECT TO_CHAR (65536,'XXXXXXXX') FROM dual;returns
10000
Dumping Database Blocks
Database Blocks
The syntax used for dumping database blocks changed when Oracle8 was introduced
Oracle7 and below
Oracle8 and above
Oracle 7 and below
In Oracle7, blocks are identified by a file number and a block number. These must be converted into a data block address. The block can then be dumped using the ALTER SESSION command.
COLUMN decimalDBA new_value decimalDBA SELECT dbms_utility.make_data_block_address (&file,&block) decimalDBA FROM dual; ALTER SESSION SET EVENTS 'immediate trace name blockdump level &decimalDBA';Oracle 8 and above
In Oracle8 and above, blocks are uniquely identified by an absolute file number and a block number. The syntax of the ALTER SYSTEM command has been extended to include block dumps
To dump a block
ALTER SYSTEM DUMP DATAFILE absolute_file_number BLOCK block_number;To dump a range of blocks
ALTER SYSTEM DUMP DATAFILE absolute_file_number BLOCK MIN minimum_block_number BLOCK MAX maximum_block_number;The DATAFILE clause can specify an absolute file number of a datafile name. If the DATAFILE clause specifies a datafile name, the blocks can also be dumped from a closed database e.g.
ALTER SYSTEM DUMP DATAFILE 'file_name' BLOCK block_number;Normally a symbolic block dump is output. However, this may not be possible if the block has become corrupt. It is possible to output the block dump in hexadecimal.
To dump a block in hexadecimal, enable event 10289
ALTER SESSION SET EVENTS '10289 trace name context forever, level 1';dump the block(s) using one of the above commands and then disable 10289 again using
ALTER SESSION SET EVENTS '10289 trace name context off';On Unix systems blocks can also be dumped using the od utility.
dd bs=8k if=filename skip=200 count=4 | od -xwhere
bs is the Oracle block size e.g. 8k
if is the datafile name
skip is the number of blocks to skip from the start of the file
count is the number of blocks to dump
As blocks are written back to the datafiles asynchronously by DBWR, it is possible that changed blocks have not been written back to the disk when they are dumped using operating system utilities.
The probability that a block has been written back to disk can be increased by performing a checkpoint using
ALTER SYSTEM CHECKPOINT;or a logfile switch using
ALTER SYSTEM SWITCH LOGFILE;
Dumping Indexes
Index Tree Dumps
An index tree can be dumped using
ALTER SESSION SET EVENTS 'immediate trace name treedump level object_id';where object_id is the object number of the index (in DBA_OBJECTS)
The tree dump includes
branch block headers
leaf block headers
contents of leaf blocks
The following ORADEBUG command has the same effect
ORADEBUG DUMP TREEDUMP object_idIn Oracle 9.2 a treedump may crash if the index has been created by a primary / unique constraint e.g.
CREATE TABLE t1 (c1 NUMBER PRIMARY KEY);or
CREATE TABLE t1 (c1 NUMBER); ALTER TABLE t1 ADD CONSTRAINT t1pk PRIMARY KEY (c1);The treedump crashes when ind$.property > 256
This problem can be prevented by creating the index before creating the constraint
Dumping Undo Segment Headers
Undo Headers
To dump an undo segment header use the command function
ALTER SYSTEM DUMP UNDO_HEADER 'segment_name';In Oracle 9.0.1 and above, if system managed undo is enabled, the segment name has to be in double quotes and upper case. This is because there is a leading underscore in the segment name.
A list of undo segment IDs and names can be obtained using
SELECT segment_id, segment_name FROM dba_rollback_segs ORDER BY segment_id;
Dumping Undo Blocks
Undo Blocks
To dump an undo block use the equivalent datafile block dump command
For example to dump an undo block in Oracle8 and above use
ALTER SYSTEM DUMP DATABASE absolute_file_number BLOCK block_number;
Dumping Undo for a Transaction
Undo for a Transaction
To dump all the undo written for a specific transaction, first identify the transaction ID using
SELECT xidusn, xidslot, xidsqn FROM v$transaction;Dump the undo using the transaction ID
ALTER SYSTEM DUMP UNDO BLOCK 'segment_name' XID xidusn xidslot xidsqn;
Dumping File Headers
To dump all the datafile headers use
ALTER SESSION SET EVENTS 'immediate trace name file_hdrs level level';
Levels (circa Oracle 8.1.5) are
Level
Description
1
Dump datafile entry from control file
2
Level 1 + generic file header
3
Level 2 + datafile header
10
Same as level 3
In later versions, level 7 appears to generate additional trace
The following ORADEBUG command has the same effect
ORADEBUG DUMP FILE_HDRS level
Dumping Control Files
Controlfiles
To dump the current latch status use
ALTER SESSION SET EVENTS 'immediate trace name controlf level level';Levels (circa Oracle 8.1.5) are
Level
Description
1
Generic file header
2
Level 1 + database information + checkpoint progress records
3
Level 2 + reuse record section
10
Same as level 3
In later versions, level 15 appears to generate additional trace
The following ORADEBUG command has the same effect
ORADEBUG DUMP CONTROLF level
Dumping Redo Log Headers
Redo Log Headers
To dump the redo log headers
ALTER SESSION SET EVENTS 'immediate trace name redohdr level 1';Levels (circa Oracle 8.1.5) are
Level
Description
1
Dump redo log entry from control file
2
Level 1 + generic file header
3
Level 2 + log file header
10
Same as level 3
The following ORADEBUG command has the same effect
ORADEBUG DUMP REDOHDR level
Dumping Redo Logs
Redo Logs
To identify the current redo log use
SELECT member FROM v$logfile WHERE group# = ( SELECT group# FROM v$log WHERE status = 'CURRENT' );To dump a redo log file use
ALTER SYSTEM DUMP LOGFILE 'FileName';e.g.
ALTER SYSTEM DUMP LOGFILE 'R:\Oracle\Oradata\JD92001\Redo01.log';The syntax of this statement is as follows
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;The minimum and maximum SCN is a decimal number
The minimum and maximum time is a decimal number representing the number of seconds since midnight 01Jan1988. These are calculated using the following formula
time = (((((yyyy - 1988)) * 12 + mm - 1) * 31 + dd - 1) * 24 + hh) * 60 + mi) * 60 + ss;yyyy
Year
 
mm
month
01-12
dd
day
01-31
hh
hour
00-23
mi
minute
00-59
ss
second
00-59
where
This is the same formula that is used to represent time within the redo log
The layer and opcode are those used to indicate specific operations within the redo log e.g. LAYER 5 OPCODE 4 is an undo segment header commit operation
Note that there must be spaces around the periods in the DBA and RBA.
See Metalink Note 1031381.6 for further examples
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/47522341/archive/2008/11/17/3320790.aspx
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/20542911/viewspace-615750/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/20542911/viewspace-615750/