Redo內部解析(二)

yezhibin發表於2009-06-24
五、DUMP Redo 命令格式

 1、DUMP日誌檔案內容

        SQL>alter system dump logfile 'pathname'

 2、Dump 指定一段資料檔案塊日誌檔案

        SQL>alter system dump logfile 'pathname'
                   DBA  Min .
                   DBA  MAX .

 3、Dump 指定RBA(REDO BYTE ADDRESS)日誌檔案

        SQL>alter system dump logfile 'pathname'
                  RBA MIN.
                  RBA MAX.

 4、具體的LAYER和Opcode(操作程式碼)
      
        SQL>alter system dump logfile 'pathname'
                  LAYER
                  OPCODE

  5、SCN
         SQL>alter system dump logfile 'pathname'
                   SCN MIN min_scn
                   SCN MAX max_scn

   6、DUMP Redo 日誌檔案頭

        SQL>alter session set events 'immediate trace name redohdr level xx'
     或SQL>oradebug dump redohdr level xx
        Level說明:
                 1-- 從控制檔案中Dump redo log記錄
                 2-- Level 1 + generic file header
                 3-- level 2 + log file header
                10-- same as level 3

說明:dump 日誌所用SCN的十進位制,具體計算如下:
         
                time=(((((yyyy - 1988)) * 12 + mm - 1) * 31 + dd - 1) * 24 + hh)
                           * 60 + mi) * 60 + ss;
         
                 其中mm: 01~12
                         dd: 01~31
                         hh: 01~23
                         mi: 00~59
                         ss: 00~59
 
六、DUMP資料格式說明

1、redo records dump檔案格式說明

       SQL> create table test.test (id number, test varchar(20));
      
       SQL>insert into test.test values('1', 'TEST1');
       SQL>commit;
      
       SQL>select   SEGMENT_NAME,
                               FILE_ID ,
                               BLOCK_ID,
                               BLOCKS,
                               RELATIVE_FNO 
                  from dba_extents
                  where segment_name='TEST' and wner='TEST';

SEGMENT_NAME   FILE_ID   BLOCK_ID     BLOCKS RELATIVE_FNO
------------------------------ ---------- ---------- ---------- ------------
    TEST                                8          9                            8            8
      
        SQL>Alter system dump logfile '/home/oracle/app/oradata/orcl/redo0301.log'
                   dba min 8 9
                   dba max 8 16
           
節選一段格式說明:
REDO RECORD - Thread:1 RBA: 0x000015.0006dc4e.0010 LEN: 0x01e0 VLD: 0x0d SCN: 0x0000.0035c4b9 SUBSCN:  3 06/25/2009 15:38:39

RBA:..

LEN:16進位制的redo records長度,如0x01e0 =480 bytes


SCN:16進位制,RBA改變的時間,如0x0000.0035c4b9


SUBSCN:在SCN下的順序


CHANGE #1 TYP:2 CLS: 1 AFN:8 DBA:0x0200000f OBJ:49577 SCN:0x0000.00353ef6 SEQ:  1 OP:11.2
KTB Redo
op: 0x01  ver: 0x01
op: F  xid:  0x000a.007.000002d2    uba: 0x00c018c3.00c6.2d
KDO Op code: IRP row dependencies Disabled
  xtype: XA flags: 0x00000000  bdba: 0x0200000f  hdba: 0x0200000b
itli: 2  ispac: 0  maxfr: 4858
tabn: 0 slot: 1(0x1) size/delt: 12

TYP:  0 - normal,1- new block, 2 - delayed logging

CLS:  block型別,除了undo block/undo header型別外,與x$bh.class相同

             1 -- Data Block
             2 -- Sort Block
             3 -- Deffered Undo Segment Blocks
             4 -- Segment Header Block (Table)
             5 -- Deffered Undo Segment Header Blocks
             6 -- Free List Block
             7 -- Extent Map Blocks
             8 -- Space Management Bitmap Blocks
             9 -- Space Management Index Blocks
            10-- Unused
            11+2r -- Segment Header for undo segment r
            12+2r -- Data blocks for undo Segment r

AFN:  檔案編號


DBA:  data block address, 如0200000f,以下是將DBA對應file#和block#

          SQL>select to_number('200000f', 'xxxxxxx') from dual;
                        TO_NUMBER('200000F','XXXXXXXX')
                       -------------------------------
                                  33554447
          SQL>select dbms_utility.data_block_address_file('33554447')  file_id,
                                dbms_utility.data_block_address_block('33554447')  blok_id
                     from dual;
                            FILE_ID    BLOK_ID
                              ---------- ----------
                                     8         15

: block version


OP:  layer.opcode 操作程式碼,詳細的對應關係見後面介紹,11.2表示insert


xid:  當前的事務處理ID,usn#.slot#.wrap#,其中usn#: undo segment  number; slot#: 事務slot編號; wrap# sequence編號

UBA: 在undo block發生改變的地址如uba: 0x00c018c3.00c6.2d
                undo 資料塊地址:00c018c3
                Sequence Number: 00c6
                Record number: 4

KDO undo record:
KTB Redo
op: 0x03  ver: 0x01
op: Z
KDO Op code: DRP row dependencies Disabled
  xtype: XA flags: 0x00000000  bdba: 0x0200000f  hdba: 0x0200000b
itli: 2  ispac: 0  maxfr: 4858
tabn: 0 slot: 1(0x1)

表示undo編號的change vector,undo發生的變化是對應DBA 0x0200000f ,slot 1
 

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

相關文章