天天看點

[20151116]rman 全備份以及增量0級備份.txt

[20151116]rman 全備份以及增量0級備份.txt

--前一陣子寫了一篇将as copy作為增量0級備份的文章,今天對比全備份以及增量0級備份的不同。

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

--設定表空間隻讀,為了比較的友善:

SCOTT@book> alter tablespace example read only ;

Tablespace altered.

--為了測試友善清除全部備份級以及copy備份。

RMAN> backup datafile 5  format '/home/oracle/backup/full_example_%u.dbf' tag='FULL';

Starting backup at 2015-11-16 16:21:15

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=00005 name=/mnt/ramdisk/book/example01.dbf

channel ORA_DISK_1: starting piece 1 at 2015-11-16 16:21:15

channel ORA_DISK_1: finished piece 1 at 2015-11-16 16:21:16

piece handle=/home/oracle/backup/full_example_3uqmdtrr.dbf tag=FULL comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

Finished backup at 2015-11-16 16:21:16

RMAN> backup incremental level 0 datafile 5  format '/home/oracle/backup/inc0_example_%u.dbf' TAG='INC0';

Starting backup at 2015-11-16 16:21:28

channel ORA_DISK_1: starting incremental level 0 datafile backup set

channel ORA_DISK_1: starting piece 1 at 2015-11-16 16:21:29

channel ORA_DISK_1: finished piece 1 at 2015-11-16 16:21:30

piece handle=/home/oracle/backup/inc0_example_3vqmdts9.dbf tag=INC0 comment=NONE

Finished backup at 2015-11-16 16:21:30

--檢視檔案:

]$ ls -l /home/oracle/backup/[fi]*example*.dbf

-rw-r----- 1 oracle oinstall 72187904 2015-11-16 16:21:15 /home/oracle/backup/full_example_3uqmdtrr.dbf

-rw-r----- 1 oracle oinstall 72187904 2015-11-16 16:21:29 /home/oracle/backup/inc0_example_3vqmdts9.dbf

--可以發現2個檔案大小一緻。

2.比較:

--先轉換成ascii檔案:

$  hexdump  -C full_example_3uqmdtrr.dbf > full.txt

$  hexdump  -C inc0_example_3vqmdts9.dbf > inc0.txt

$ diff  full.txt inc0.txt

7,8c7,8

< 00002010  98 6f 00 00 00 04 20 0b  00 04 20 0b 45 8b 9b 4f  |.o.... ... .E..O|

< 00002020  42 4f 4f 4b 00 00 00 00  e2 24 00 00 00 00 00 00  |BOOK....?......|

---

> 00002010  63 08 00 00 00 04 20 0b  00 04 20 0b 45 8b 9b 4f  |c..... ... .E..O|

            ~~~~~

> 00002020  42 4f 4f 4b 00 00 00 00  eb 24 00 00 00 00 00 00  |BOOK....?......|

12,13c12,13

< 00002060  01 00 00 00 7b f7 66 35  7e 00 00 00 01 00 00 00  |....{鱢5~.......|

< 00002070  01 00 00 00 46 55 4c 4c  00 00 00 00 00 00 00 00  |....FULL........|

> 00002060  01 00 00 00 89 f7 66 35  7f 00 00 00 01 00 00 00  |.....鱢5........|

                        ~~           ~~

> 00002070  01 00 00 00 49 4e 43 30  00 00 00 00 00 00 00 00  |....INC0........|

                        ~~~~~~~~~~~

                        tag不同比較容易發現

15c15

< 00002090  00 00 00 00 04 04 00 00  4b 01 00 00 03 a5 00 00  |........K....?.|

> 00002090  00 00 00 00 05 04 00 00  4b 01 00 00 03 a5 00 00  |........K....?.|

                        ~~

--注意僅僅辨別~ 的部分不同。

SCOTT@book> @ &r/16to10 2010

16 to 10 DEC

------------

        8208

SCOTT@book> @ &r/16to10 2090

        8336

--如果以8k作為1個塊,僅僅第2塊不同。

RMAN> list backupset ;

List of Backup Sets

===================

BS Key  Type LV Size       Device Type Elapsed Time Completion Time

------- ---- -- ---------- ----------- ------------ -------------------

116     Full    68.84M     DISK        00:00:00     2015-11-16 16:21:15

        BP Key: 116   Status: AVAILABLE  Compressed: NO  Tag: FULL

        Piece Name: /home/oracle/backup/full_example_3uqmdtrr.dbf

  List of Datafiles in backup set 116

  File LV Type Ckp SCN    Ckp Time            Name

  ---- -- ---- ---------- ------------------- ----

  5       Full 1774661    2015-11-16 16:16:33 /mnt/ramdisk/book/example01.dbf

117     Incr 0  68.84M     DISK        00:00:00     2015-11-16 16:21:29

        BP Key: 117   Status: AVAILABLE  Compressed: NO  Tag: INC0

        Piece Name: /home/oracle/backup/inc0_example_3vqmdts9.dbf

  List of Datafiles in backup set 117

  5    0  Incr 1774661    2015-11-16 16:16:33 /mnt/ramdisk/book/example01.dbf

--除了tag辨別比較容易識别外,其它看不出來。

--116 = 0x74  1774661 = 0x1b1445

3.感覺兩者差别不大,不過rman的catalog指令并不能把full備份的備份集換成增量備份集。

RMAN> catalog backuppiece "/home/oracle/backup/full_example_3uqmdtrr.dbf" level 0;

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00558: error encountered while parsing input commands

RMAN-01009: syntax error: found "level": expecting one of: "comma, ;"

RMAN-01007: at line 1 column 69 file: standard input

What might these mean?

Here’s a possible explanation:

0x2094 = 0x04 = FULL

0x2094 = 0x05 = Incremental

0x2095 = 0x04 = level 0 if the previous byte is 0x05

0x2095 = 0x00 = level 1 if the previous byte is 0x05

---如果我改動偏移0x2094=0x05 是否可以變成增量呢?測試看看。

4.繼續測試:

RMAN> change backuppiece "/home/oracle/backup/full_example_3uqmdtrr.dbf" uncatalog ;

uncataloged backup piece

backup piece handle=/home/oracle/backup/full_example_3uqmdtrr.dbf RECID=116 STAMP=895940475

Uncataloged 1 objects

$  bvi -b 0 -s 16384 full_example_3uqmdtrr.dbf

-- 改動偏移0x2094 ,0x04=>0x05.

-- 使用bbed修改檢查和。

BBED> set dba 20,1

        DBA             0x05000001 (83886081 20,1)

BBED> sum

Check value for File 20, Block 1:

current = 0x6f98, required = 0x6f99

BBED> sum apply

current = 0x6f99, required = 0x6f99

--注:從這裡可以推出:0x2010 處是 檢查和。

--注: 如果不改檢查和,會報錯:

RMAN> catalog backuppiece "/home/oracle/backup/full_example_3uqmdtrr.dbf" ;

ORA-19870: error while restoring backup piece /home/oracle/backup/full_example_3uqmdtrr.dbf

ORA-19608: /home/oracle/backup/full_example_3uqmdtrr.dbf is not a backup piece

RMAN-03002: failure of catalog command at 11/17/2015 08:21:01

RMAN-06209: List of failed objects

RMAN-06211: ==========================

RMAN-06212:   Object Type   Filename/Handle

RMAN-06213: --------------- ---------------------------------------------------

RMAN-06214: Backup Piece    /home/oracle/backup/full_example_3uqmdtrr.dbf

--------------------

cataloged backup piece

backup piece handle=/home/oracle/backup/full_example_3uqmdtrr.dbf RECID=118 STAMP=895998477

--OK注冊成功!RECID=118

118     Incr 0  68.84M     DISK        00:00:00     2015-11-16 16:21:15

        BP Key: 118   Status: AVAILABLE  Compressed: NO  Tag: FULL

  List of Datafiles in backup set 118

--注意看BS_KEY=118 的TAG=FULL.

--驗證看看是否可以使用:

RMAN> change backuppiece tag INC0 uncatalog;

backup piece handle=/home/oracle/backup/inc0_example_3vqmdts9.dbf RECID=117 STAMP=895940489

RMAN> restore datafile 5 preview;

Starting restore at 2015-11-17 08:44:55

Finished restore at 2015-11-17 08:44:55

RMAN> recover datafile 5 preview;

Starting recover at 2015-11-17 08:45:01

List of Archived Log Copies for database with db_unique_name BOOK

=====================================================================

Key     Thrd Seq     S Low Time

------- ---- ------- - -------------------

37      1    43      A 2015-11-14 10:07:15

        Name: /u01/app/oracle/archivelog/book/1_43_894797959.dbf

Media recovery start SCN is 1774661

Recovery must be done beyond SCN 1774661 to clear datafile fuzziness

Finished recover at 2015-11-17 08:45:01

--至少驗證通過,說明full備份與0級備份檔案差别不大,僅僅存在細微的差别。

--說實在知道這些沒有意義,僅僅做一些簡單探究。