1207catalog copy的数据文件作为0级备份2

简介: [20151207]catalog copy的数据文件作为0级备份补充.txt --  前一阵子写了1篇blog,使用热备份模式备份的文件是否可以作为0级备份。 --  以及使用backpup as copy备份的数据文件是否可以作为0级备份. --  链接:http://blog.itpub.net/267265/viewspace-1832475/ --  当时困惑的是使用catalog datafilecopy '/home/oracle/backup/datafile_4_USERS.dbf' level 0 ;作为0级。

[20151207]catalog copy的数据文件作为0级备份补充.txt

--  前一阵子写了1篇blog,使用热备份模式备份的文件是否可以作为0级备份。
--  以及使用backpup as copy备份的数据文件是否可以作为0级备份.
--  链接:http://blog.itpub.net/267265/viewspace-1832475/

--  当时困惑的是使用catalog datafilecopy '/home/oracle/backup/datafile_4_USERS.dbf' level 0 ;作为0级。
--- 不知道那里能看出来这个copy备份作为1级备份呢?

-- 实际上通过v$datafile_copy视图就可以知道?还是通过例子来说明:

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

RMAN> list backup ;

using target database control file instead of recovery catalog
specification does not match any backup in the repository

RMAN> list copy ;

specification does not match any datafile copy in the repository
specification does not match any control file copy in the repository
specification does not match any archived log in the repository

--我删除了全部备份以及archivelog。


2.建立backup as copy备份:

RMAN> backup as copy datafile "/mnt/ramdisk/book/example01.dbf" format "/home/oracle/backup/example_%U.dbf";

Starting backup at 2015-12-07 08:20:08
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00005 name=/mnt/ramdisk/book/example01.dbf
output file name=/home/oracle/backup/example_data_D-BOOK_I-1337401710_TS-EXAMPLE_FNO-5_01qo71tp.dbf tag=TAG20151207T082008 RECID=2 STAMP=897812410
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 2015-12-07 08:20:10

RMAN> list copy ;

specification does not match any control file copy in the repository
specification does not match any archived log in the repository
List of Datafile Copies
=======================

Key     File S Completion Time     Ckp SCN    Ckp Time
------- ---- - ------------------- ---------- -------------------
2       5    A 2015-12-07 08:20:10 13212703957 2015-12-07 08:20:09
        Name: /home/oracle/backup/example_data_D-BOOK_I-1337401710_TS-EXAMPLE_FNO-5_01qo71tp.dbf
        Tag: TAG20151207T082008

SCOTT@book> select file#, tag, incremental_level, name from v$datafile_copy where deleted='NO' order by 1;
     FILE# TAG                              INCREMENTAL_LEVEL NAME
---------- -------------------------------- ----------------- ------------------------------------------------------------
         5 TAG20151207T082008                                 /home/oracle/backup/example_data_D-BOOK_I-1337401710_TS-EXAM
                                                              PLE_FNO-5_01qo71tp.dbf


3.改成0级备份:
RMAN> catalog datafilecopy '/home/oracle/backup/example_data_D-BOOK_I-1337401710_TS-EXAMPLE_FNO-5_01qo71tp.dbf' level 0 tag 'inc0';

cataloged datafile copy
datafile copy file name=/home/oracle/backup/example_data_D-BOOK_I-1337401710_TS-EXAMPLE_FNO-5_01qo71tp.dbf RECID=3 STAMP=897812572

RMAN> list copy ;

specification does not match any control file copy in the repository
specification does not match any archived log in the repository
List of Datafile Copies
=======================

Key     File S Completion Time     Ckp SCN    Ckp Time
------- ---- - ------------------- ---------- -------------------
3       5    A 2015-12-07 08:22:52 13212703957 2015-12-07 08:20:09
        Name: /home/oracle/backup/example_data_D-BOOK_I-1337401710_TS-EXAMPLE_FNO-5_01qo71tp.dbf
        Tag: INC0


--查看视图v$datafile_copy。
SCOTT@book> select file#, tag, incremental_level, name from v$datafile_copy where deleted='NO' order by 1;
     FILE# TAG                              INCREMENTAL_LEVEL NAME
---------- -------------------------------- ----------------- ------------------------------------------------------------
         5 INC0                                             0 /home/oracle/backup/example_data_D-BOOK_I-1337401710_TS-EXAM
                                                              PLE_FNO-5_01qo71tp.dbf

--当时主要精力查询含有RMAN以及BACKUP字串的视图,忽略了还要查询包含COPY字串的视图。
--可以发现通过这个视图可以确定backup as copy的备份以及修改为0级备份。

4.还可以不断应用日志:

SCOTT@book> select file#, tag, incremental_level, name ,CHECKPOINT_CHANGE#  from v$datafile_copy where deleted='NO' order by 1;
       FILE# TAG                              INCREMENTAL_LEVEL NAME                                               CHECKPOINT_CHANGE#
------------ -------------------------------- ----------------- -------------------------------------------------- ------------------
           5 INC0                                             0 /home/oracle/backup/example_data_D-BOOK_I-13374017        13212705401
                                                                10_TS-EXAMPLE_FNO-5_01qo71tp.dbf

--RMAN> backup incremental level 1 for recover of copy with tag 'inc0' datafile "/mnt/ramdisk/book/example01.dbf";
RMAN> backup incremental level 1 for recover of copy with tag 'inc0' datafile 5;

Starting backup at 2015-12-07 08:56:47
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=00005 name=/mnt/ramdisk/book/example01.dbf
channel ORA_DISK_1: starting piece 1 at 2015-12-07 08:56:47
channel ORA_DISK_1: finished piece 1 at 2015-12-07 08:56:48
piece handle=/u01/app/oracle/fast_recovery_area/BOOK/backupset/2015_12_07/o1_mf_nnnd1_INC0_c69pbhf2_.bkp tag=INC0 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2015-12-07 08:56:48

SCOTT@book> select file#, tag, incremental_level, name ,CHECKPOINT_CHANGE#  from v$datafile_copy where deleted='NO' order by 1;
       FILE# TAG                              INCREMENTAL_LEVEL NAME                                               CHECKPOINT_CHANGE#
------------ -------------------------------- ----------------- -------------------------------------------------- ------------------
           5 INC0                                             0 /home/oracle/backup/example_data_D-BOOK_I-13374017        13212705401
                                                                10_TS-EXAMPLE_FNO-5_01qo71tp.dbf

-- 奇怪并没有变化CHECKPOINT_CHANGE#。

RMAN> list backup;
List of Backup Sets
===================
BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -------------------
8       Incr 1  32.00K     DISK        00:00:00     2015-12-07 08:56:47
        BP Key: 8   Status: AVAILABLE  Compressed: NO  Tag: INC0
        Piece Name: /u01/app/oracle/fast_recovery_area/BOOK/backupset/2015_12_07/o1_mf_nnnd1_INC0_c69pbhf2_.bkp
  List of Datafiles in backup set 8
  File LV Type Ckp SCN    Ckp Time            Name
  ---- -- ---- ---------- ------------------- ----
  5    1  Incr 13212705949 2015-12-07 08:56:47 /mnt/ramdisk/book/example01.dbf

-- 实际上增加1个1级备份,以这个copy备份为基础。看了一些文档发现要不断应用日志,执行的是如下:
RUN {
  RECOVER COPY OF DATABASE WITH TAG 'incr_update';
  BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG 'incr_update' DATABASE;
}

正确的应该是:

RMAN> recover copy of datafile 5;

Starting recover at 2015-12-07 08:59:52
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: specifying datafile copies to recover
recovering datafile copy file number=00005 name=/home/oracle/backup/example_data_D-BOOK_I-1337401710_TS-EXAMPLE_FNO-5_01qo71tp.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/BOOK/backupset/2015_12_07/o1_mf_nnnd1_INC0_c69pbhf2_.bkp
channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/BOOK/backupset/2015_12_07/o1_mf_nnnd1_INC0_c69pbhf2_.bkp tag=INC0
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished recover at 2015-12-07 08:59:53


SCOTT@book> select file#, tag, incremental_level, name ,CHECKPOINT_CHANGE#  from v$datafile_copy where deleted='NO' order by 1;
       FILE# TAG                              INCREMENTAL_LEVEL NAME                                               CHECKPOINT_CHANGE#
------------ -------------------------------- ----------------- -------------------------------------------------- ------------------
           5 INC0                                             0 /home/oracle/backup/example_data_D-BOOK_I-13374017        13212705949
                                                                10_TS-EXAMPLE_FNO-5_01qo71tp.dbf

--这样inc0就变化了。如下执行不存在1级会不应用的的。

RMAN> RECOVER COPY OF datafile 5 WITH TAG 'inc0';

Starting recover at 2015-12-07 09:05:05
using channel ORA_DISK_1
no copy of datafile 5 found to recover
Finished recover at 2015-12-07 09:05:05

RMAN> recover copy of datafile 5;

Starting recover at 2015-12-07 09:08:37
using channel ORA_DISK_1
no copy of datafile 5 found to recover
Finished recover at 2015-12-07 09:08:37

--必须存在1级备份才会应用:

RMAN> backup incremental level 1 for recover of copy with tag 'inc0' datafile 5;

Starting backup at 2015-12-07 09:08:42
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=00005 name=/mnt/ramdisk/book/example01.dbf
channel ORA_DISK_1: starting piece 1 at 2015-12-07 09:08:42
channel ORA_DISK_1: finished piece 1 at 2015-12-07 09:08:43
piece handle=/u01/app/oracle/fast_recovery_area/BOOK/backupset/2015_12_07/o1_mf_nnnd1_INC0_c69q0tmf_.bkp tag=INC0 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2015-12-07 09:08:43

RMAN> recover copy of datafile 5;

Starting recover at 2015-12-07 09:08:45
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: specifying datafile copies to recover
recovering datafile copy file number=00005 name=/home/oracle/backup/example_data_D-BOOK_I-1337401710_TS-EXAMPLE_FNO-5_01qo71tp.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/BOOK/backupset/2015_12_07/o1_mf_nnnd1_INC0_c69q0tmf_.bkp
channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/BOOK/backupset/2015_12_07/o1_mf_nnnd1_INC0_c69q0tmf_.bkp tag=INC0
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished recover at 2015-12-07 09:08:46

目录
相关文章
|
SQL Oracle 关系型数据库
Oracle rman备份保留策略,归档删除策略及delete命令的使用
oracle rman备份保留策略、归档策略的使用及对delete命令的影响
1925 0
|
SQL Oracle 关系型数据库
|
Oracle 关系型数据库 数据库
|
Oracle 关系型数据库 数据库管理
[20161101]rman备份与数据文件变化7.txt
[20161101]rman备份与数据文件变化7.txt --//想象一下,如果备份文件时间很长,而这个时候数据文件大小发生了变化,oracle的备份如何解决这个问题呢? --//去年已经测试了建立备份集的情况,一直想做一次image copy的测试,一直脱,主要原因自己不想做这个测试.
1187 0
|
Oracle 关系型数据库 OLAP
[20171123]rman备份与数据文件变化6.txt
[20171123]rman备份与数据文件变化6.txt --//想象一下,如果备份文件时间很长,而这个时候数据文件大小发生了变化,oracle的备份如何解决这个问题呢? --//去年已经测试了建立备份集的情况,一直想做一次image copy的测试,一直脱,主要原因自己不想做这个测试.
792 0
|
存储 Oracle 关系型数据库
|
Oracle 关系型数据库 数据库管理
[20161102]rman备份与数据文件变化5.txt
[20161102]rman备份与数据文件变化5.txt --想象一下,如果备份文件时间很长,而这个时候数据文件大小发生了变化,oracle的备份如何解决这个问题呢? --前面我已经做了增大数据文件,参考链接:http://blog.itpub.net/267265/viewspace-2127386/ --这次测试减少数据文件大小看看。
732 0
|
Oracle 关系型数据库 数据库管理
[20161031]rman备份与数据文件变化2.txt
[20161031]rman备份与数据文件变化2.txt --想象一下,如果备份文件时间很长,而这个时候数据文件大小发生了变化,oracle的备份如何解决这个问题呢? 1.
924 0