oracle redo log 分析

 

Environment:

OS: Ubuntu 10.10

Oracle: 11.1.0.6.0

 

 

Test table: test_user

Current data:

Operation:

 

Log File Dumps:

Symbolic dumps can be created for both online redo logs and archived redo logs using the following syntax:

For online redo logs the filename of the current redo log can be obtained using the following SQL:

Output dump file can be found with this command:

if ASM, use following command

SQL> oradebug setmypid;
Statement processed.
SQL> oradebug tracefile_name;
/u02/app/diag/rdbms/ora11g/ora11g/trace/ora11g_ora_20221.trc

Find the detail log info we just operated in dump file:

1. find the object id of the table

2. find log in dump file based on "object_id" and operation time.The  redo infomation as follows, note the "OBJ:71329" and the timestap "12/21/2010

 

 

Redo Log Analysis:

 

Redo Records Structure:

 

Reo Record Header

 

  • Thread - redo log thread number

              value: 1

  • RBA - redo byte address - address of redo record within redo log. Format is <sequence_number>.<block_number>.<offset>

              value: 0x00007.00012d3d.0010

                  sequence_number:  0x00007

                  block_number: 0x00012d3d

                  offset: 0x10


  • LEN - length of redo record in bytes including header

              value: 0x22c             

  • VLD -

              The VLD field determines the size of the redo record header. Known values are shown in the following table. These values may vary from one release to another.

 

 
MnemonicValueDescription
KCRVOID0The contents are not valid
KCRVALID1Includes change vectors
KCRDEPND2Includes commit SCN
KCRVOID4Includes dependent SCN
KCRNMARK8New SCN mark record. SCN allocated exactly at this point in the redo log by this instance
KCROMARK16Old SCN mark record. SCN allocated at or before this point in the redo. May be allocated by another instance
KCRORDER32New SCN was allocated to ensure redo for some block would be ordered by inc/seq# when redo sorted by SCN

              value: 0x0d  -  1101: "Includes change vectors" & "Includes dependent SCN" &  "New SCN mark record. SCN allocated exactly at this point in the redo log by this instance"

  • SCN - system change number of redo record

              value: 0x0000.000fddbd

  • SUBSCN: Unknown

              value: 1

  • Timestamp

              value: 12/21/2010 16:30:29

 

Change #1:

 

Change Header:

  • TYP - change type

              value: 2

  • CLS - class

 

 
ClassDescription
1Data Block
2Sort Block
3Deferred Undo Segment Blocks
4Segment Header Block (Table)
5Deferred Undo Segment Header Blocks
6Free List Blocks
7Extent Map Blocks
8Space Management Bitmap Blocks
9Space Management Index Blocks
10Unused
11 + 2rSegment Header for Undo Segment r
12 + 2rData Blocks for Undo Segment r

          value: 1  -  mean data block

  • AFN - Absolute File No

              get file info using this sql statement:

             

              value: 4  - means to "users01.dbf"

  • DBA - Database Block Address

              value: 0x01000195

                  File No: 4

                  Block No: 0x195

  • OBJ - object

              value: 71329

  • SCN - System change Number

              value: 0x0000.000fdd5e

                  wrap: 0x0000

                  base:  0xfdd5e

  • SEQ - Sequence Number

              value: 2

  • OP - Operation Code

 

Each change vector has an operation code. In Oracle 9.2 there were over 150 redo log operations; this number has grown significantly in Oracle 10.2 though the exact figure is not known. The operation code consists of a major number and a minor number.

The major number describes the level in the kernel where the redo is generated. The following table shows common levels:

 
LevelDescription
4Block Cleanout
5Transaction Layer (Undo)
10Index Operation
11Table Operation (DML)
13Block Allocation
14Extent Allocation
17Backup Management
18Online Backup
19Direct Load
20Transaction Metadata (LogMiner)
22Space Management (ASSM)
23Block Write (DBWR)
24DDL Statement

              For "Table Operation(DML)", description as follows:

 

 
CodeMnemonicDescription
11.1IURUndo
11.2IRPInsert Row Piece
11.3DRPDelete Row Piece
11.4LKRLock Row
11.5URPUpdate Row Piece
11.6ORPOverflow Row Piece
11.7MFC 
11.8CFA 
11.9CKI 
11.10SKL 
11.11QMIInsert Row Array
11.12QMDDelete Row Array
11.14DSC 
11.16LMN 
11.17LLB 
11.1919Update Row Array
11.20SHK 
11.2121 

 

For "Transaction Layer (Undo)", description as follows:

 
CodeMnemonicDescription
5.11Undo Recorder
5.22Undo Header
5.44Commit

 

              values: 11.19

 

KTB Redo

KTB Redo records modifications to the transaction header of a block. The inverse operations are recorded in the undo segment

Each KTB Redo record has an operation type. Known codes include:

 
Numeric CodeAlphanumeric Code
0x1F
0x2C
0x3Z
0x4L
0x5R
0x11F
  • op: 0x01 - Numeric Code
  • ver: 0x01
  • op: F - Alphanumeric Code
  • xid: Transaction ID. Format is usn#.slot#.wrap# Components are:

     
    usn#Undo segment number
    slot#Slot number in undo segment
    wrap#Sequence number

    value: 0x000a.005.0000035a

        usn: 0x000a

        slot: 0x005

        wrap: 0x0000035a

  • uba: uba Undo block address. Format is dba.seq#.rec# Components are:
     
    dbaData block address of undo block
    seq#Sequence number of undo block
    rec#Record number within undo block

            value: 0x00c00478.01ca.28

                dba: 0x00c00478

                seq: 0x01ca

                rec:  0x28

 

  • tabn - specifies the table number. For non-clustered tables this will always be 0
  • slot - specifies the slot number. Each block has an variable length array of slots. Each element in this array specifies the location of a row within the block. The first slot in the block is 0. In this example the row was written to the third  slot in the table (slot 2)
  • flag - Unknown
  • lock - probably set to 1 indicating a lock has been taken on the row header, what's the mean 2?
  • ckix - Unknown

  • ncol - Number of columns in row piece
  • nnew - Number of changed columns in row piece
  • size - (Probably) change in size of row piece

  • Operation code: Update Row Piece
  • row dependencies - specifies whether row dependencies are disabled (default) or enabled for this table

  • xtype - transaction type. Can be XA, XR, CR or KDO_KDOM2. In this case the transaction type is KDO_KDOM2. This structure can potentially store an array of change vectors for an object.
  • flags - Unknown
  • bdba - block DBA. Data block address of this block
  • hdba - header DBA. Probably data block address of extent header

 

  • itli - specifes the ITL slot number of the transaction performing the operation. In this example the row is locked by the transaction in the first ITL slot.
  • ispac - Unknown
  • maxfr - Unknown

Update of column 1 (name) to 'ddd'

 

Change #2:

Change header:

  • TYP:  0
  • CLS: 35
  • AFN: 3  - refer to "undotbs01.dbf"
  • DBA: 0x00c00099
  • OBJ:  4294967259
  • SCN: 0x0000.000fdd85
  • SEQ: 1
  • OP: 5.2  -  means "Undo header"

Change body:

 

Change #3:

Change header:

  • TYP:  0
  • CLS: 35
  • AFN: 3  - refer to "undotbs01.dbf"
  • DBA: 0x00c00039
  • OBJ:  4294967295
  • SCN: 0x0000.000fddc3
  • SEQ: 1
  • OP: 5.4  -  means "Commit"

Change #4:

Change header:

  • TYP:  0
  • CLS: 24
  • AFN: 3  - refer to "undotbs01.dbf"
  • DBA: 0x00c005ba
  • OBJ:  4294967295
  • SCN: 0x0000.000fdd8a
  • SEQ: 3
  • OP: 5.1  -  means "Undo Recorder"

Change Body:

  • logon user: 106 - current user id, confirmed as follows:

 

RollBack:

Opration:

Redo Log:

 

Update Multiple rows:

Operation:

Redo Log:

 

Multi Operation One Commit:

operation:

Redo Log:

 

Reference:

http://www.juliandyke.com/Internals/Redo/Redo.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

duanbeibei

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值