首页 > 开发 > 综合 > 正文

数据块转储及RDBA的转换

2024-07-21 02:33:58
字体:
来源:转载
供稿:网友

  很多时候我们在进行进一步研究时需要转储(dump)Oracle的数据块,以研究其内容,Oracle提供了很好的方式,我们通过以下例子简单说明一下:
  
  [oracle@jumper udump]$ sqlplus "/ as sysdba"
  
  SQL*Plus: Release 9.2.0.3.0 - PRodUCtion on Tue Aug 31 17:01:27 2004
  
  Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
  
  Connected to:
  Oracle9i Enterprise Edition Release 9.2.0.3.0 - Production
  With the Partitioning, OLAP and Oracle Data Mining options
  JServer Release 9.2.0.3.0 - Production
  
  SQL> select rowid,deptno,dname,loc from scott.dept;
  
  ROWID         DEPTNO DNAME     LOC
  ------------------ ---------- -------------- -------------
  AAADZ7AABAAAGK6AAA     10 ACCOUNTING   NEW YORK
  AAADZ7AABAAAGK6AAB     20 RESEARCH    DALLAS
  AAADZ7AABAAAGK6AAC     30 SALES     CHICAGO
  AAADZ7AABAAAGK6AAD     40 OperaTIONS   BOSTON
  
  SQL> select file_id,block_id,blocks from dba_extents where segment_name='DEPT';
  
  FILE_ID  BLOCK_ID   BLOCKS
  ---------- ---------- ----------
     1   25273     8
  
  SQL> alter system dump datafile 1 block min 25273 block max 25274;
  
  System altered.
  
  SQL> !
  [oracle@jumper udump]$ ls -l
  total 4
  -rw-r-----  1 oracle  dba     3142 Aug 31 17:04 hsjf_ora_13674.trc
  [oracle@jumper udump]$ more hsjf_ora_13674.trc
  /opt/oracle/admin/hsjf/udump/hsjf_ora_13674.trc
  Oracle9i Enterprise Edition Release 9.2.0.3.0 - Production
  With the Partitioning, OLAP and Oracle Data Mining options
  JServer Release 9.2.0.3.0 - Production
  ORACLE_HOME = /opt/oracle/product/9.2.0
  System name:  linux
  Node name:   jumper.hurray.com.cn
  Release:    2.4.18-14
  Version:    #1 Wed Sep 4 13:35:50 EDT 2002
  Machine:    i686
  Instance name: hsjf
  Redo thread mounted by this instance: 1
  Oracle process number: 9
  Unix process pid: 13674, image: oracle@jumper.hurray.com.cn (TNS V1-V3)
  
  *** 2004-08-31 17:04:27.820
  *** session ID:(8.3523) 2004-08-31 17:04:27.819
  Start dump data blocks tsn: 0 file#: 1 minblk 25273 maxblk 25274
  buffer tsn: 0 rdba: 0x004062b9 (1/25273)
  scn: 0x0000.0057c70d seq: 0x01 flg: 0x04 tail: 0xc70d1001
  frmt: 0x02 chkval: 0x12e3 type: 0x10=DATA SEGMENT HEADER - UNLIMITED
   Extent Control Header
   -----------------------------------------------------------------
   Extent Header:: spare1: 0   spare2: 0   #extents: 1   #blocks: 7
         last map 0x00000000 #maps: 0   offset: 4128
   Highwater:: 0x004062bb ext#: 0   blk#: 1   ext size: 7
   #blocks in seg. hdr's freelists: 1
   #blocks below: 1
   mapblk 0x00000000 offset: 0
          Unlocked
   Map Header:: next 0x00000000 #extents: 1  obj#: 13947 flag: 0x40000000
   Extent Map
   -----------------------------------------------------------------
  0x004062ba length: 7
  
   nfl = 1, nfb = 1 typ = 1 nxf = 0 ccnt = 1
   SEG LST:: flg: USED  lhd: 0x004062ba ltl: 0x004062ba
  buffer tsn: 0 rdba: 0x004062ba (1/25274)
  scn: 0x0000.0131909b seq: 0x07 flg: 0x04 tail: 0x909b0607
  frmt: 0x02 chkval: 0xa8e7 type: 0x06=trans data
  Block header dump: 0x004062ba
   Object id on Block?
Y
   seg/obj: 0x367b csc: 0x00.131909a itc: 2 flg: O typ: 1 - DATA
   fsl: 0 fnx: 0x0 ver: 0x01
  
   Itl      Xid         Uba     Flag Lck    Scn/Fsc
  0x01  0x0001.02a.000003f3 0x0080000b.0188.08 C---  0 scn 0x0000.0057c70e
  0x02  0x0000.000.00000000 0x00000000.0000.00 ----  0 fsc 0x0000.00000000
  
  data_block_dump,data header at 0xadb505c
  ===============
  tsiz: 0x1fa0
  hsiz: 0x1a
  pbl: 0x0adb505c
  bdba: 0x004062ba
   76543210
  flag=--------
  ntab=1
  nrow=4
  frre=-1
  fsbo=0x1a
  fSEO=0x1f44
  avsp=0x1f2a
  tosp=0x1f2a
  0xe:pti[0]   nrow=4 offs=0
  0x12:pri[0]   offs=0x1f86
  0x14:pri[1]   offs=0x1f70
  0x16:pri[2]   offs=0x1f5c
  0x18:pri[3]   offs=0x1f44
  block_row_dump:
  tab 0, row 0, @0x1f86
  tl: 26 fb: --H-FL-- lb: 0x0 cc: 3
  col 0: [ 2] c1 0b
  col 1: [10] 41 43 43 4f 55 4e 54 49 4e 47
  col 2: [ 8] 4e 45 57 20 59 4f 52 4b
  tab 0, row 1, @0x1f70
  tl: 22 fb: --H-FL-- lb: 0x0 cc: 3
  col 0: [ 2] c1 15
  col 1: [ 8] 52 45 53 45 41 52 43 48
  col 2: [ 6] 44 41 4c 4c 41 53
  tab 0, row 2, @0x1f5c
  tl: 20 fb: --H-FL-- lb: 0x0 cc: 3
  col 0: [ 2] c1 1f
  col 1: [ 5] 53 41 4c 45 53
  col 2: [ 7] 43 48 49 43 41 47 4f
  tab 0, row 3, @0x1f44
  tl: 24 fb: --H-FL-- lb: 0x0 cc: 3
  col 0: [ 2] c1 29
  col 1: [10] 4f 50 45 52 41 54 49 4f 4e 53
  col 2: [ 6] 42 4f 53 54 4f 4e
  end_of_block_dump
  End dump data blocks tsn: 0 file#: 1 minblk 25273 maxblk 25274
  
  很多人经常提出的一个问题是,rdba是如何转换的?
  
  rdba: 0x004062ba (1/25274)
  
  我们通过这个例子介绍一下.
  
  rdba从Oracle6->Oracle7->Oracle8发生了三次改变:
  
  在Oracle6中,rdba由6位2进制数表示,也就是说数据块最多只能有2^6=64个数据文件(去掉全0和全1, 实际上最多只能代表62个文件)
  
  在Oracle7中,rdba中的文件号增加为10位,为了向后兼容,从Block号的高位拿出4位作为文件号的高位.这样从6->7的Rowid无需发生变化.
  
  在Oracle8中,文件号仍然用10位表示,只是不再需要置换,为了向后兼容,同时引入了相对文件号(rfile#),所以从Oracle7到Oracle8,Rowid仍然无需发生变化.
  
  举例说明如下:
  
  在Oracle6中:
  比如: file 8, block 56892
   26位block号==56892
   vv vvvvvvvv vvvvvvvv vvvvvvvv
  00100000 00000000 11011110 00111100
  ^^^^^^
  6位文件号==8
  
  在Oracle7中:
  比如:File 255, block 56892
  
  11111100 11000000 11011110 00111100
   F  C  C  0   D  E   3 C
  /_____//___//_______________________/
       
     Block = 0xDE3C = 56892
  /_____________
           V  V
    0011  111111 = 0xFF = 255 --注重这里高位和低位要置换才能得出正确的file#
  
  在Oracle8中:
  比如:File 255, block 56892
  
  11111100 11000000 11011110 00111100
   F  C  C  0   D  E   3 C
  /_____//___//_______________________/
       
     Block = 0xDE3C = 56892
  /_____________
           V  V
   0011 1111 0011 = 03F3 = 1011 --这就是相对文件号
  
  对于我们测试中的例子:
  
  rdba: 0x004062ba (1/25274)
  
  也就是:0000 0000 0100 0000 0110 0010 1011 1010
  
  前10位为rfile#: 0000 0000 01 = 1
  
  后22位为Block#:00 0000 0110 0010 1011 1010 = 25274 right">(出处:清风软件下载学院)

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表