[20161114]rman备份的疑问.txt

[20161114]rman备份的疑问.txt

--这个是我前几天做测试时遇到的疑问,不知道为什么rman 备份要修改数据块的dba地址。

1.环境:
SCOTT@book> @ &r/ver1
PORT_STRING                    VERSION        BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx            11.2.0.4.0     Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

CREATE TABLESPACE SUGAR DATAFILE
  '/mnt/ramdisk/book/sugar01.dbf' SIZE 40M AUTOEXTEND ON NEXT 16M MAXSIZE UNLIMITED
LOGGING
ONLINE
EXTENT MANAGEMENT LOCAL AUTOALLOCATE
BLOCKSIZE 8K
SEGMENT SPACE MANAGEMENT AUTO
FLASHBACK ON;

create table t1 tablespace sugar as select rownum id ,to_char(rownum,'FM000000')||lpad('A',26,'A') name from dual connect by level<=1e5;
--建立大小5M的表。
create table t2 tablespace sugar as select rownum id ,to_char(rownum,'FM000000')||lpad('B',26,'B') name from dual connect by level<=2e5;
create table t3 tablespace sugar as select rownum id ,to_char(rownum,'FM000000')||lpad('C',26,'C') name from dual connect by level<=2e5;
alter system checkpoint;

2.备份数据文件6:
RMAN> backup datafile 6 format '/u01/backup/d6_1.bak' ;
Starting backup at 2016-11-11 17:02:48
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00006 name=/mnt/ramdisk/book/sugar01.dbf
channel ORA_DISK_1: starting piece 1 at 2016-11-11 17:02:49
channel ORA_DISK_1: finished piece 1 at 2016-11-11 17:02:50
piece handle=/u01/backup/d6_1.bak tag=TAG20161111T170248 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2016-11-11 17:02:50

$ strings -td /u01/backup/d6_1.bak| egrep '000996'
1125139 a 000996AAAAAAAAAAAAAAAAAAAAAAAAAA,
6146835 a 000996BBBBBBBBBBBBBBBBBBBBBBBBBB,
16132883 a 000996CCCCCCCCCCCCCCCCCCCCCCCCCC,

--1125139/8192=137.3460693359375
--6146835/8192=750.3460693359375
--16132883/8192=1969.3460693359375
--对应的信息在备份块中137,750,1969.

BBED> set filename '/u01/backup/d6_1.bak'
        FILENAME        /u01/backup/d6_1.bak

p block 137 kcbh.rdba_kcbh
p block 750 kcbh.rdba_kcbh
p block 1969 kcbh.rdba_kcbh

BBED> p block 137 kcbh.rdba_kcbh
ub4 rdba_kcbh                               @4        0x01800089

BBED> p block 750 kcbh.rdba_kcbh
ub4 rdba_kcbh                               @4        0x018003ee

BBED> p block 1969 kcbh.rdba_kcbh
ub4 rdba_kcbh                               @4        0x018008b1

BBED> set dba 0x01800089
        DBA             0x01800089 (25165961 6,137)

BBED> set dba 0x018003ee
        DBA             0x018003ee (25166830 6,1006)

BBED> set dba 0x018008b1
        DBA             0x018008b1 (25168049 6,2225)

SCOTT@book> column name format a32
SCOTT@book> select rowid,t1.id from t1 where name='000996AAAAAAAAAAAAAAAAAAAAAAAAAA';
ROWID                      ID
------------------ ----------
AAAVuXAAGAAAACIACF        996

SCOTT@book> @ &r/rowid AAAVuXAAGAAAACIACF
    OBJECT       FILE      BLOCK        ROW ROWID_DBA            DBA                  TEXT
---------- ---------- ---------- ---------- -------------------- -------------------- ----------------------------------------
     88983          6        136        133  0x1800088           6,136                alter system dump datafile 6 block 136 ;

SCOTT@book> select rowid,t2.* from t2 where name='000996BBBBBBBBBBBBBBBBBBBBBBBBBB';
ROWID                      ID NAME
------------------ ---------- --------------------------------
AAAVuYAAGAAAAMIACF        996 000996BBBBBBBBBBBBBBBBBBBBBBBBBB

SCOTT@book> @ &r/rowid AAAVuYAAGAAAAMIACF
    OBJECT       FILE      BLOCK        ROW ROWID_DBA            DBA                  TEXT
---------- ---------- ---------- ---------- -------------------- -------------------- ----------------------------------------
     88984          6        776        133  0x1800308           6,776                alter system dump datafile 6 block 776 ;

SCOTT@book> select rowid,t3.* from t3 where name='000996CCCCCCCCCCCCCCCCCCCCCCCCCC';
ROWID                      ID NAME
------------------ ---------- --------------------------------
AAAVuZAAGAAAAgIACF        996 000996CCCCCCCCCCCCCCCCCCCCCCCCCC

SCOTT@book> @ &r/rowid AAAVuZAAGAAAAgIACF
    OBJECT       FILE      BLOCK        ROW ROWID_DBA            DBA                  TEXT
---------- ---------- ---------- ---------- -------------------- -------------------- ----------------------------------------
     88985          6       2056        133  0x1800808           6,2056               alter system dump datafile 6 block 2056

--你可以发现备份是修改了dba地址。

BBED> set filename '/u01/backup/d6_1.bak'
        FILENAME        /u01/backup/d6_1.bak

BBED> x /rnc block 137  *kdbr[133]
rowdata[1519]                               @2829
-------------
flag@2829: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@2830: 0x00
cols@2831:    2

col    0[3] @2832: 996
col   1[32] @2836: 000996AAAAAAAAAAAAAAAAAAAAAAAAAA

BBED> x /rnc block 750  *kdbr[133]
rowdata[1519]                               @2829
-------------
flag@2829: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@2830: 0x00
cols@2831:    2

col    0[3] @2832: 996
col   1[32] @2836: 000996BBBBBBBBBBBBBBBBBBBBBBBBBB

BBED> x /rnc block 1969  *kdbr[133]
rowdata[1519]                               @2829
-------------
flag@2829: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@2830: 0x00
cols@2831:    2

col    0[3] @2832: 996
col   1[32] @2836: 000996CCCCCCCCCCCCCCCCCCCCCCCCCC

--//与数据块对比。
BBED> x /rnc dba 6,2056  *kdbr[133]
rowdata[1519]                               @2829
-------------
flag@2829: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@2830: 0x00
cols@2831:    2

col    0[3] @2832: 996
col   1[32] @2836: 000996CCCCCCCCCCCCCCCCCCCCCCCCCC

--你可以发现rman在备份时改变了dba地址,为什么?因为你改变dba地址,意味检查和也做了改变或者要重新计算。

3.单独保存对应数据块。

bvi -b 16842752 -s 8192 /mnt/ramdisk/book/sugar01.dbf   --//保存sugar2056.bin
bvi -b 16130048 -s 8192 /u01/backup/d6_1.bak            --//保存bak1969.bin

$ xxd -c 16 sugar2056.bin > aa1
$ xxd -c 16 bak1969.bin   > aa2

$ diff -Nur aa1 aa2
--- aa1 2016-11-11 17:36:44.000000000 +0800
+++ aa2 2016-11-11 17:36:51.000000000 +0800
@@ -1,5 +1,5 @@
-0000000: 06a2 0000 0808 8001 a883 6000 0000 0204  ..........`.....
-0000010: 6406 0000 0100 0000 995b 0100 a183 6000  d........[....`.
+0000000: 06a2 0000 b108 8001 a883 6000 0000 0204  ..........`.....
                    ~~~~~~~~~
+0000010: d606 0100 0100 0000 995b 0100 a183 6000  ?.......[....`.
          ~~~~~~~~~
0000020: 0000 0000 0300 3201 0008 8001 ffff 0000  ......2.....??..
0000030: 0000 0000 0000 0000 0000 0000 0080 0000  ................
0000040: a183 6000 0000 0000 0000 0000 0000 0000  ..`.............
@@ -509,4 +509,4 @@
0001fc0: 4343 4343 4343 4343 4343 4343 4343 4343  CCCCCCCCCCCCCCCC
0001fd0: 4343 4343 2c00 0203 c209 4020 3030 3038  CCCC,...?@ 0008
0001fe0: 3633 4343 4343 4343 4343 4343 4343 4343  63CCCCCCCCCCCCCC
-0001ff0: 4343 4343 4343 4343 4343 4343 0206 a883  CCCCCCCCCCCC....
+0001ff0: 4343 4343 4343 4343 4343 4343 0806 a883  CCCCCCCCCCCC....
                                        ~~~~
--注意看~的地方。
--b108 8001 是rdba_kcbh dba地址。
--d606      是 chkval_kcbh 检查和
--0100      是 spare3_kcbh
-- 0806 a883是 tailchk

5.比较备份与数据文件中的kcbh.spare3_kcbh

BBED> p dba 6,136  kcbh.spare3_kcbh
ub2 spare3_kcbh                             @18       0x0000

BBED> p dba 6,776  kcbh.spare3_kcbh
ub2 spare3_kcbh                             @18       0x0000

BBED> p dba 6,2056 kcbh.spare3_kcbh
ub2 spare3_kcbh                             @18       0x0000

BBED> p filename '/u01/backup/d6_1.bak' block 137 kcbh.spare3_kcbh
ub2 spare3_kcbh                             @18       0x0001

BBED> p filename '/u01/backup/d6_1.bak' block 750 kcbh.spare3_kcbh
ub2 spare3_kcbh                             @18       0x0001

BBED> p filename '/u01/backup/d6_1.bak' block 1969 kcbh.spare3_kcbh
ub2 spare3_kcbh                             @18       0x0001

-- 你可以发现备份修改kcbh.spare3_kcbh=0x0001.

6.比较备份与数据文件中的tailchk.

BBED> p dba 6,136  tailchk
ub4 tailchk                                 @8188     0x83290602

BBED> p dba 6,776  tailchk
ub4 tailchk                                 @8188     0x83640602

BBED> p dba 6,2056  tailchk
ub4 tailchk                                 @8188     0x83a80602

BBED> p filename '/u01/backup/d6_1.bak' block 137 tailchk
ub4 tailchk                                 @8188     0x83290688

BBED> p filename '/u01/backup/d6_1.bak' block 750 tailchk
ub4 tailchk                                 @8188     0x83640608

BBED> p filename '/u01/backup/d6_1.bak' block 1969 tailchk
ub4 tailchk                                 @8188     0x83a80608

--前4位,对应块提交的scn低4位,没有变动。后面2位数据文件都是0x02, 而备份不同还真看出来如何还原。

7.回来看看备份与数据文件中的rdba_kcbh。
BBED> p dba 6,136  rdba_kcbh
ub4 rdba_kcbh                               @4        0x01800088

BBED> p dba 6,776  rdba_kcbh
ub4 rdba_kcbh                               @4        0x01800308

BBED> p dba 6,2056  rdba_kcbh
ub4 rdba_kcbh                               @4        0x01800808

BBED> p filename '/u01/backup/d6_1.bak' block 137 rdba_kcbh
ub4 rdba_kcbh                               @4        0x01800089

BBED> p filename '/u01/backup/d6_1.bak' block 750 rdba_kcbh
ub4 rdba_kcbh                               @4        0x018003ee

BBED> p filename '/u01/backup/d6_1.bak' block 1969 rdba_kcbh
ub4 rdba_kcbh                               @4        0x018008b1

--做一个推测tailchk的低2位实际上是真实数据块的rdba_kcbh的低2位。

BBED> p filename '/u01/backup/d6_1.bak' block 137 rdba_kcbh
ub4 rdba_kcbh                               @4        0x01800089

--备份的rdba_kcbh低2位是0x89,替换尾部0x88,变成0x01800088
BBED> set dba 0x01800088
        DBA             0x01800088 (25165960 6,136)
--这样对应相应的数据块。

8.反向推测看看(随便找一个块看看):

BBED> p filename '/u01/backup/d6_1.bak' block 770 rdba_kcbh
ub4 rdba_kcbh                               @4        0x01800382

BBED> p filename '/u01/backup/d6_1.bak' block 770 tailchk
ub4 tailchk                                 @8188     0x8368061c

BBED> p filename '/u01/backup/d6_1.bak' block 770 spare3_kcbh
ub2 spare3_kcbh                             @18       0x0001

--可以推出这个备份块对应的数据块dba是0x0180031c

BBED> set dba 0x0180031c
        DBA             0x0180031c (25166620 6,796)

--验证看看:
BBED> x /rnc dba 0x0180031c  *kdbr[133]
rowdata[1519]                               @2829
-------------
flag@2829: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@2830: 0x00
cols@2831:    2

col    0[3] @2832: 4264
col   1[32] @2836: 004264BBBBBBBBBBBBBBBBBBBBBBBBBB

BBED> x /rnc filename '/u01/backup/d6_1.bak' block 770 *kdbr[133]
rowdata[1519]                               @2829
-------------
flag@2829: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@2830: 0x00
cols@2831:    2

col    0[3] @2832: 4264
col   1[32] @2836: 004264BBBBBBBBBBBBBBBBBBBBBBBBBB

--你可以发现备份与数据块信息对应。

--以上都是我的猜测,也许不对。为什么oracle的rman备份要这样设置,那位知道...........

时间: 2024-09-07 15:00:59

[20161114]rman备份的疑问.txt的相关文章

[20161118]rman备份的疑问2.txt

[20161118]rman备份的疑问2.txt --这个是我前几天做测试时遇到的疑问,不知道为什么rman 备份要修改数据块的dba地址. --我在itpub上也问了这个问题,链接http://www.itpub.net/thread-2071504-1-1.html,可惜没有人解答. --具体细节不清楚,读取数据文件然后重新编码组织数据,将kcbh.rdba_kcbh的后2位放入tailchk中,设置spare3_kcbh=0x0001, --也许为了区分备份与数据文件,当然还有别的目的,再

[20171031]rman备份压缩模式.txt

[20171031]rman备份压缩模式.txt --//测试rman备份压缩模式,那种效果好,我记忆里选择medium在备份时间和备份文件大小综合考虑最佳. --//还是通过脚本测试: 1.环境: SCOTT@book> @ &r/ver1 PORT_STRING                    VERSION        BANNER ------------------------------ -------------- ---------------------------

[20171130]关于rman备份疑问.txt

[20171130]关于rman备份疑问.txt --//前面测试太乱,重新做一些rman as copy相关测试. 1.环境: SCOTT@book> @ &r/ver1 PORT_STRING                    VERSION        BANNER ------------------------------ -------------- --------------------------------------------------------------

[20171204]关于rman备份疑问4.txt

[20171204]关于rman备份疑问4.txt --//上午排除我几天在做rman测试的疑问. --//链接如下:http://blog.itpub.net/267265/viewspace-2148029/ --//顺便测试备份集包含5个数据文件的情况(本来不想做,还是做看看),验证自己的判断是否正确. 1.环境: SCOTT@book> @ &r/ver1 PORT_STRING                    VERSION        BANNER -----------

[20160523]rman备份与检查点2.txt

[20160523]rman备份与检查点2.txt --写过几篇关于检查点的文章,测试看看如果rman做备份时是否写检查点. 1.环境: SCOTT@book> @ &r/ver1 PORT_STRING         VERSION        BANNER ------------------- -------------- ---------------------------------------------------------------------------- x86

[20160523]rman备份与检查点3.txt

[20160523]rman备份与检查点3.txt --从前面的测试可以发现: --1.通过以上信息可以确定备份文件会写检查点. --2.而且备份文件是先写检查点,再做备份. --我这里就产生1个疑问,假设某个数据文件备份时间很长,这样数据文件的某个数据块的scn可能大于文件头的CHECKPOINT_CHANGE#.当我 --们恢复使用不完全恢复到某个时间点或者SCN,应该使用那个备份文件呢?做一个测试来说明问题. 1.环境: SCOTT@book> @ &r/ver1 PORT_STRIN

[20161220]rman恢复时间点的疑问.txt

[20161220]rman恢复时间点的疑问.txt --昨天在恢复时遇到缺少归档的问题,自己开始感觉奇怪,做一点分析记录. RMAN> list backupset summary ; List of Backups =============== Key     TY LV S Device Type Completion Time     #Pieces #Copies Compressed Tag ------- -- -- - ----------- -----------------

[20161101]rman备份与数据文件变化7.txt

[20161101]rman备份与数据文件变化7.txt --//想象一下,如果备份文件时间很长,而这个时候数据文件大小发生了变化,oracle的备份如何解决这个问题呢? --//去年已经测试了建立备份集的情况,一直想做一次image copy的测试,一直脱,主要原因自己不想做这个测试.... --//而且当时的测试很乱,自己主要一边做一边想.... --//链接: http://blog.itpub.net/267265/viewspace-2127386/ http://blog.itpub

[20171123]rman备份与数据文件变化6.txt

[20171123]rman备份与数据文件变化6.txt --//想象一下,如果备份文件时间很长,而这个时候数据文件大小发生了变化,oracle的备份如何解决这个问题呢? --//去年已经测试了建立备份集的情况,一直想做一次image copy的测试,一直脱,主要原因自己不想做这个测试.... --//而且当时的测试很乱,自己主要一边做一边想.... --//链接: http://blog.itpub.net/267265/viewspace-2127386/ http://blog.itpub