[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级备份文件差别不大,仅仅存在细微的差别。
--说实在知道这些没有意义,仅仅做一些简单探究。