[20151112]catalog copy的数据文件作为0级备份.txt
--使用热备份模式备份的文件是否可以作为0级备份呢?
--以前学习rman这部分内容时候有点混乱,无法理解为什么使用rman backup as copy 的数据文件与0级备份的数据文件存在那些不同.
--是否使用热备份以及backpup as copy备份的数据文件是否可以作为0级备份.
--通过例子来说明:
1.测试环境:
SYS@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
SYS@book> alter tablespace users begin backup ;
Tablespace altered.
$ cp /mnt/ramdisk/book/users01.dbf /home/oracle/backup/
SYS@book> alter tablespace users end backup ;
Tablespace altered.
RMAN> list copy of tablespace users;
specification does not match any datafile copy in the repository
RMAN> list copy of datafile 4;
specification does not match any datafile copy in the repository
--可以发现使用热备份模式的方式控制文件不会记录,毕竟这个os命令完成的备份,这也是淘汰热备份模式主要原因.管理问题.
2.使用catalog注册.
RMAN> catalog start with '/home/oracle/backup/users01.dbf';
searching for all files that match the pattern /home/oracle/backup/users01.dbf
List of Files Unknown to the Database
=====================================
File Name: /home/oracle/backup/users01.dbf
Do you really want to catalog the above files (enter YES or NO)? yes
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /home/oracle/backup/users01.dbf
RMAN> list copy of tablespace users;
List of Datafile Copies
=======================
Key File S Completion Time Ckp SCN Ckp Time
------- ---- - ------------------- ---------- -------------------
2 4 A 2015-11-12 09:20:23 1558886 2015-11-12 09:14:58
Name: /home/oracle/backup/users01.dbf
--可以发现记录的备份是按照copy方式做了.
RMAN> backup as copy datafile 4 format '/home/oracle/backup/datafile_4_%N.dbf';
Starting backup at 2015-11-12 09:27:07
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=/mnt/ramdisk/book/users01.dbf
output file name=/home/oracle/backup/datafile_4_USERS.dbf tag=TAG20151112T092707 RECID=3 STAMP=895570027
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 2015-11-12 09:27:08
RMAN> list copy of datafile 4;
List of Datafile Copies
=======================
Key File S Completion Time Ckp SCN Ckp Time
------- ---- - ------------------- ---------- -------------------
3 4 A 2015-11-12 09:27:07 1559316 2015-11-12 09:27:07
Name: /home/oracle/backup/datafile_4_USERS.dbf
Tag: TAG20151112T092707
2 4 A 2015-11-12 09:20:23 1558886 2015-11-12 09:14:58
Name: /home/oracle/backup/users01.dbf
3.理论讲这些文件可以作为0级备份:
RMAN> catalog datafilecopy '/home/oracle/backup/users01.dbf' level 0 ;
cataloged datafile copy
RMAN> list copy of datafile 4;
List of Datafile Copies
=======================
Key File S Completion Time Ckp SCN Ckp Time
------- ---- - ------------------- ---------- -------------------
3 4 A 2015-11-12 09:27:07 1559316 2015-11-12 09:27:07
Name: /home/oracle/backup/datafile_4_USERS.dbf
Tag: TAG20151112T092707
5 4 A 2015-11-12 09:30:59 1558886 2015-11-12 09:14:58
Name: /home/oracle/backup/users01.dbf
--注意看key已经变成了5.
RMAN> BACKUP INCREMENTAL LEVEL 1 datafile 4 format '/home/oracle/backup/inc_user01_%U.dbf';
Starting backup at 2015-11-12 09:37:25
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental level 1 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00004 name=/mnt/ramdisk/book/users01.dbf
channel ORA_DISK_1: starting piece 1 at 2015-11-12 09:37:26
channel ORA_DISK_1: finished piece 1 at 2015-11-12 09:37:27
piece handle=/home/oracle/backup/inc_user01_08qm2kmm_1_1.dbf tag=TAG20151112T093725 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2015-11-12 09:37:27
$ ll /home/oracle/backup/
total 97440
-rw-r----- 1 oracle oinstall 49815552 Nov 12 09:27 datafile_4_USERS.dbf
-rw-r----- 1 oracle oinstall 40960 Nov 12 09:37 inc_user01_08qm2kmm_1_1.dbf
-rw-r----- 1 oracle oinstall 49815552 Nov 12 09:15 users01.dbf
RMAN> list backupset ;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -------------------
7 Incr 1 32.00K DISK 00:00:00 2015-11-12 09:37:26
BP Key: 7 Status: AVAILABLE Compressed: NO Tag: TAG20151112T093725
Piece Name: /home/oracle/backup/inc_user01_08qm2kmm_1_1.dbf
List of Datafiles in backup set 7
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- ------------------- ----
4 1 Incr 1560000 2015-11-12 09:37:26 /mnt/ramdisk/book/users01.dbf
--文件大小也可以说明问题.可以确定热备份已经作为0级备份.
4.对比看看:
--使用增量0级备份看看:
RMAN> BACKUP INCREMENTAL LEVEL 0 datafile 4 format '/home/oracle/backup/inc0_user01_%U.dbf';
Starting backup at 2015-11-12 09:39:44
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental level 0 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00004 name=/mnt/ramdisk/book/users01.dbf
channel ORA_DISK_1: starting piece 1 at 2015-11-12 09:39:44
channel ORA_DISK_1: finished piece 1 at 2015-11-12 09:39:45
piece handle=/home/oracle/backup/inc0_user01_09qm2kr0_1_1.dbf tag=TAG20151112T093944 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2015-11-12 09:39:45
RMAN> host "ls -l /home/oracle/backup";
total 142088
-rw-r----- 1 oracle oinstall 49815552 Nov 12 09:27 datafile_4_USERS.dbf
-rw-r----- 1 oracle oinstall 45670400 Nov 12 09:39 inc0_user01_09qm2kr0_1_1.dbf
-rw-r----- 1 oracle oinstall 40960 Nov 12 09:37 inc_user01_08qm2kmm_1_1.dbf
-rw-r----- 1 oracle oinstall 49815552 Nov 12 09:15 users01.dbf
host command complete
RMAN> host "ls -l /mnt/ramdisk/book/users01.dbf";
-rw-r----- 1 oracle oinstall 49815552 Nov 12 09:39 /mnt/ramdisk/book/users01.dbf
host command complete
--注意看文件大小,实际上0级备份与copy方式两者存在不同.0级备份也是备份仅仅使用的块,以这个备份为基础,做1级备份,或者1级累积
--备份.实际上还可以在备份时选择压缩模式.
RMAN> BACKUP as compressed backupset INCREMENTAL LEVEL 0 datafile 4 format '/home/oracle/backup/inc0_user01_%U.dbf';
Starting backup at 2015-11-12 09:49:01
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed incremental level 0 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00004 name=/mnt/ramdisk/book/users01.dbf
channel ORA_DISK_1: starting piece 1 at 2015-11-12 09:49:01
channel ORA_DISK_1: finished piece 1 at 2015-11-12 09:49:02
piece handle=/home/oracle/backup/inc0_user01_0aqm2lcd_1_1.dbf tag=TAG20151112T094901 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2015-11-12 09:49:02
RMAN> host "ls -l /home/oracle/backup";
total 143452
-rw-r----- 1 oracle oinstall 49815552 Nov 12 09:27 datafile_4_USERS.dbf
-rw-r----- 1 oracle oinstall 45670400 Nov 12 09:39 inc0_user01_09qm2kr0_1_1.dbf
-rw-r----- 1 oracle oinstall 1392640 Nov 12 09:49 inc0_user01_0aqm2lcd_1_1.dbf
-rw-r----- 1 oracle oinstall 40960 Nov 12 09:37 inc_user01_08qm2kmm_1_1.dbf
-rw-r----- 1 oracle oinstall 49815552 Nov 12 09:15 users01.dbf
host command complete
-- 注意看文件大小.
5.好了,现在删除一些备份,仅仅留下as copy方式的备份:
RMAN> delete backupset 7,8,9;
using channel ORA_DISK_1
List of Backup Pieces
BP Key BS Key Pc# Cp# Status Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
7 7 1 1 AVAILABLE DISK /home/oracle/backup/inc_user01_08qm2kmm_1_1.dbf
8 8 1 1 AVAILABLE DISK /home/oracle/backup/inc0_user01_09qm2kr0_1_1.dbf
9 9 1 1 AVAILABLE DISK /home/oracle/backup/inc0_user01_0aqm2lcd_1_1.dbf
Do you really want to delete the above objects (enter YES or NO)? yes
deleted backup piece
backup piece handle=/home/oracle/backup/inc_user01_08qm2kmm_1_1.dbf RECID=7 STAMP=895570646
deleted backup piece
backup piece handle=/home/oracle/backup/inc0_user01_09qm2kr0_1_1.dbf RECID=8 STAMP=895570784
deleted backup piece
backup piece handle=/home/oracle/backup/inc0_user01_0aqm2lcd_1_1.dbf RECID=9 STAMP=895571341
Deleted 3 objects
RMAN> delete copy of datafile 4 completed after '2015-11-12 09:30:59';
released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=394 device type=DISK
List of Datafile Copies
=======================
Key File S Completion Time Ckp SCN Ckp Time
------- ---- - ------------------- ---------- -------------------
5 4 A 2015-11-12 09:30:59 1558886 2015-11-12 09:14:58
Name: /home/oracle/backup/users01.dbf
Do you really want to delete the above objects (enter YES or NO)? yes
deleted datafile copy
datafile copy file name=/home/oracle/backup/users01.dbf RECID=5 STAMP=895570259
Deleted 1 objects
RMAN> list copy of database;
List of Datafile Copies
=======================
Key File S Completion Time Ckp SCN Ckp Time
------- ---- - ------------------- ---------- -------------------
3 4 A 2015-11-12 09:27:07 1559316 2015-11-12 09:27:07
Name: /home/oracle/backup/datafile_4_USERS.dbf
Tag: TAG20151112T092707
RMAN> list backupset summary;
specification does not match any backup in the repository
--做1个增量1级备份:
RMAN> BACKUP INCREMENTAL LEVEL 1 datafile 4 format '/home/oracle/backup/inc1_user01_%U.dbf';
Starting backup at 2015-11-12 10:30:44
using channel ORA_DISK_1
no parent backup or copy of datafile 4 found
channel ORA_DISK_1: starting incremental level 0 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00004 name=/mnt/ramdisk/book/users01.dbf
channel ORA_DISK_1: starting piece 1 at 2015-11-12 10:30:44
channel ORA_DISK_1: finished piece 1 at 2015-11-12 10:30:45
piece handle=/home/oracle/backup/inc1_user01_0bqm2nqk_1_1.dbf tag=TAG20151112T103044 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2015-11-12 10:30:45
RMAN> host "ls -l /home/oracle/backup";
total 93348
-rw-r----- 1 oracle oinstall 49815552 Nov 12 09:27 datafile_4_USERS.dbf
-rw-r----- 1 oracle oinstall 45670400 Nov 12 10:30 inc1_user01_0bqm2nqk_1_1.dbf
host command complete
--可以发现增量备份虽然是1级,因为不存在0级备份,备份文件实际上是0级.as copy方式的备份没有作为0级备份.
RMAN> list backupset ;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -------------------
10 Incr 0 43.55M DISK 00:00:00 2015-11-12 10:30:44
BP Key: 10 Status: AVAILABLE Compressed: NO Tag: TAG20151112T103044
Piece Name: /home/oracle/backup/inc1_user01_0bqm2nqk_1_1.dbf
List of Datafiles in backup set 10
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- ------------------- ----
4 0 Incr 1562428 2015-11-12 10:30:44 /mnt/ramdisk/book/users01.dbf
--注意看LV=0 , 表示0级备份,说明没有指定as copy作为0级备份.
RMAN> BACKUP INCREMENTAL LEVEL 1 datafile 4 format '/home/oracle/backup/inc1_user01_%U.dbf';
Starting backup at 2015-11-12 10:34:13
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental level 1 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00004 name=/mnt/ramdisk/book/users01.dbf
channel ORA_DISK_1: starting piece 1 at 2015-11-12 10:34:13
channel ORA_DISK_1: finished piece 1 at 2015-11-12 10:34:14
piece handle=/home/oracle/backup/inc1_user01_0cqm2o15_1_1.dbf tag=TAG20151112T103413 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2015-11-12 10:34:14
RMAN> host "ls -l /home/oracle/backup";
total 93388
-rw-r----- 1 oracle oinstall 49815552 Nov 12 09:27 datafile_4_USERS.dbf
-rw-r----- 1 oracle oinstall 45670400 Nov 12 10:30 inc1_user01_0bqm2nqk_1_1.dbf
-rw-r----- 1 oracle oinstall 40960 Nov 12 10:34 inc1_user01_0cqm2o15_1_1.dbf
host command complete
RMAN> list backupset summary;
List of Backups
===============
Key TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
------- -- -- - ----------- ------------------- ------- ------- ---------- ---
10 B 0 A DISK 2015-11-12 10:30:44 1 1 NO TAG20151112T103044
11 B 1 A DISK 2015-11-12 10:34:13 1 1 NO TAG20151112T103413
--注意看lv,第2次才是1级备份,前面第1次是0级备份(因为0级不存在).再看看这个as copy的备份能否作为0级备份.
RMAN> catalog datafilecopy '/home/oracle/backup/datafile_4_USERS.dbf' level 0 ;
cataloged datafile copy
datafile copy file name=/home/oracle/backup/datafile_4_USERS.dbf RECID=6 STAMP=895574253
RMAN> list datafilecopy all;
List of Datafile Copies
=======================
Key File S Completion Time Ckp SCN Ckp Time
------- ---- - ------------------- ---------- -------------------
6 4 A 2015-11-12 10:37:33 1559316 2015-11-12 09:27:07
Name: /home/oracle/backup/datafile_4_USERS.dbf
Tag: TAG20151112T092707
--key变成了6.不过那里能看出来这个copy备份作为0级备份呢?
RMAN> catalog datafilecopy '/home/oracle/backup/datafile_4_USERS.dbf' level 1 ;
cataloged datafile copy
datafile copy file name=/home/oracle/backup/datafile_4_USERS.dbf RECID=7 STAMP=895574636
--key变成了7. 还是不知道那里能看出来这个copy备份作为1级备份呢?不知道那位知道.
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/267265/viewspace-1832475/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/267265/viewspace-1832475/