1207catalog copy的資料檔案作為0級備份2

lfree發表於2015-12-07

[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

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-1867253/,如需轉載,請註明出處,否則將追究法律責任。

相關文章