[20151207]不断应用日志.txt
--许多讲rman的书都提到这个类似的脚本:
RUN {
RECOVER COPY OF DATABASE WITH TAG 'incr_update';
BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG 'incr_update' DATABASE format '/home/oracle/backup/%U';
}
--通过不断的应用日志(最好打开块跟踪),减少切换事件,自己也测试看看,先删除备份再测试:
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 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
RMAN> list backup;
specification does not match any backup in the repository
2.先测试format '%b'是否有效:
RMAN> BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG 'incr_update' datafile 5 format '/home/oracle/backup/%b';
Starting backup at 2015-12-07 09:26:37
using channel ORA_DISK_1
no parent backup or copy of datafile 5 found
channel ORA_DISK_1: starting datafile copy
input datafile file number=00005 name=/mnt/ramdisk/book/example01.dbf
output file name=/u01/app/oracle/fast_recovery_area/BOOK/datafile/o1_mf_example_c69r2f64_.dbf tag=INCR_UPDATE RECID=19 STAMP=897816398
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
Finished backup at 2015-12-07 09:26:40
RMAN> BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG 'incr_update' datafile 5 format '/home/oracle/backup/%b';
Starting backup at 2015-12-07 09:26:44
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:26:44
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of backup command on ORA_DISK_1 channel at 12/07/2015 09:26:44
ORA-19715: invalid format b for generated name
ORA-27302: failure occurred at: slgpn
--可以发现这样格式无效。
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
------- ---- - ------------------- ---------- -------------------
19 5 A 2015-12-07 09:26:38 13212707504 2015-12-07 09:26:37
Name: /u01/app/oracle/fast_recovery_area/BOOK/datafile/o1_mf_example_c69r2f64_.dbf
Tag: INCR_UPDATE
RMAN> delete copy of database ;
released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=134 device type=DISK
List of Datafile Copies
=======================
Key File S Completion Time Ckp SCN Ckp Time
------- ---- - ------------------- ---------- -------------------
19 5 A 2015-12-07 09:26:38 13212707504 2015-12-07 09:26:37
Name: /u01/app/oracle/fast_recovery_area/BOOK/datafile/o1_mf_example_c69r2f64_.dbf
Tag: INCR_UPDATE
Do you really want to delete the above objects (enter YES or NO)? yes
deleted datafile copy
datafile copy file name=/u01/app/oracle/fast_recovery_area/BOOK/datafile/o1_mf_example_c69r2f64_.dbf RECID=19 STAMP=897816398
Deleted 1 objects
3.先建立as copy 备份
--要保持原来的文件名,必须先执行如下:
RMAN> backup as copy database format '/home/oracle/backup/%b';
Starting backup at 2015-12-07 09:29:45
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/users01.dbf tag=TAG20151207T092945 RECID=20 STAMP=897816589
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=/mnt/ramdisk/book/system01.dbf
output file name=/home/oracle/backup/system01.dbf tag=TAG20151207T092945 RECID=21 STAMP=897816595
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=/mnt/ramdisk/book/sysaux01.dbf
output file name=/home/oracle/backup/sysaux01.dbf tag=TAG20151207T092945 RECID=22 STAMP=897816598
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting datafile copy
input datafile file number=00005 name=/mnt/ramdisk/book/example01.dbf
output file name=/home/oracle/backup/example01.dbf tag=TAG20151207T092945 RECID=23 STAMP=897816600
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=/mnt/ramdisk/book/undotbs01.dbf
output file name=/home/oracle/backup/undotbs01.dbf tag=TAG20151207T092945 RECID=24 STAMP=897816603
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting datafile copy
copying current control file
RMAN-03009: failure of backup command on ORA_DISK_1 channel at 12/07/2015 09:30:03
ORA-19715: invalid format b for generated name
ORA-27302: failure occurred at: slgpn
continuing other job steps, job failed will not be re-run
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 2015-12-07 09:30:03
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of backup command on ORA_DISK_1 channel at 12/07/2015 09:30:03
ORA-19715: invalid format b for generated name
ORA-27302: failure occurred at: slgpn
--注意后面的错误并不重要,主要问题是格式%b无法建立spfile以及控制文件的备份。
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
------- ---- - ------------------- ---------- -------------------
21 1 A 2015-12-07 09:29:55 13212707624 2015-12-07 09:29:52
Name: /home/oracle/backup/system01.dbf
Tag: TAG20151207T092945
22 2 A 2015-12-07 09:29:58 13212707626 2015-12-07 09:29:56
Name: /home/oracle/backup/sysaux01.dbf
Tag: TAG20151207T092945
24 3 A 2015-12-07 09:30:03 13212707630 2015-12-07 09:30:02
Name: /home/oracle/backup/undotbs01.dbf
Tag: TAG20151207T092945
20 4 A 2015-12-07 09:29:49 13212707621 2015-12-07 09:29:45
Name: /home/oracle/backup/users01.dbf
Tag: TAG20151207T092945
23 5 A 2015-12-07 09:30:00 13212707628 2015-12-07 09:29:59
Name: /home/oracle/backup/example01.dbf
Tag: TAG20151207T092945
--可以发现现在的copy备份保存的文件名与原来一样。
4.转换为0级备份:
catalog datafilecopy '/home/oracle/backup/system01.dbf' level 0 tag 'incr_update';
catalog datafilecopy '/home/oracle/backup/sysaux01.dbf' level 0 tag 'incr_update';
catalog datafilecopy '/home/oracle/backup/undotbs01.dbf' level 0 tag 'incr_update';
catalog datafilecopy '/home/oracle/backup/users01.dbf' level 0 tag 'incr_update';
catalog datafilecopy '/home/oracle/backup/example01.dbf' level 0 tag 'incr_update';
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
------- ---- - ------------------- ---------- -------------------
25 1 A 2015-12-07 09:36:15 13212707624 2015-12-07 09:29:52
Name: /home/oracle/backup/system01.dbf
Tag: INCR_UPDATE
26 2 A 2015-12-07 09:36:15 13212707626 2015-12-07 09:29:56
Name: /home/oracle/backup/sysaux01.dbf
Tag: INCR_UPDATE
27 3 A 2015-12-07 09:36:15 13212707630 2015-12-07 09:30:02
Name: /home/oracle/backup/undotbs01.dbf
Tag: INCR_UPDATE
20 4 A 2015-12-07 09:29:49 13212707621 2015-12-07 09:29:45
Name: /home/oracle/backup/users01.dbf
Tag: TAG20151207T092945
28 5 A 2015-12-07 09:36:15 13212707628 2015-12-07 09:29:59
Name: /home/oracle/backup/example01.dbf
Tag: INCR_UPDATE
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#
------------ -------------------------------- ----------------- -------------------------------------------------- ------------------
1 INCR_UPDATE 0 /home/oracle/backup/system01.dbf 13212707624
2 INCR_UPDATE 0 /home/oracle/backup/sysaux01.dbf 13212707626
3 INCR_UPDATE 0 /home/oracle/backup/undotbs01.dbf 13212707630
4 INCR_UPDATE 0 /home/oracle/backup/users01.dbf 13212707621
5 INCR_UPDATE 0 /home/oracle/backup/example01.dbf 13212707628
5.建立脚本:
RUN {
RECOVER COPY OF DATABASE WITH TAG 'incr_update';
BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG 'incr_update' DATABASE format '/home/oracle/backup/%U';
}
--不断执行就可以保证日志不断应用到备份。
Starting recover at 2015-12-07 09:39:13
using channel ORA_DISK_1
no copy of datafile 1 found to recover
no copy of datafile 2 found to recover
no copy of datafile 3 found to recover
no copy of datafile 4 found to recover
no copy of datafile 5 found to recover
Finished recover at 2015-12-07 09:39:13
Starting backup at 2015-12-07 09:39: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
input datafile file number=00001 name=/mnt/ramdisk/book/system01.dbf
input datafile file number=00002 name=/mnt/ramdisk/book/sysaux01.dbf
input datafile file number=00005 name=/mnt/ramdisk/book/example01.dbf
input datafile file number=00003 name=/mnt/ramdisk/book/undotbs01.dbf
channel ORA_DISK_1: starting piece 1 at 2015-12-07 09:39:14
channel ORA_DISK_1: finished piece 1 at 2015-12-07 09:39:17
piece handle=/home/oracle/backup/11qo76i2_1_1 tag=INCR_UPDATE comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting incremental level 1 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 2015-12-07 09:39:18
channel ORA_DISK_1: finished piece 1 at 2015-12-07 09:39:19
piece handle=/home/oracle/backup/12qo76i5_1_1 tag=INCR_UPDATE comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2015-12-07 09:39:19
$ ll | grep -v "dbf"
total 3121492
-rw-r----- 1 oracle oinstall 196608 2015-12-07 09:39:15 11qo76i2_1_1
-rw-r----- 1 oracle oinstall 10321920 2015-12-07 09:39:18 12qo76i5_1_1
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#
------------ -------------------------------- ----------------- -------------------------------------------------- ------------------
1 INCR_UPDATE 0 /home/oracle/backup/system01.dbf 13212707624
2 INCR_UPDATE 0 /home/oracle/backup/sysaux01.dbf 13212707626
3 INCR_UPDATE 0 /home/oracle/backup/undotbs01.dbf 13212707630
4 INCR_UPDATE 0 /home/oracle/backup/users01.dbf 13212707621
5 INCR_UPDATE 0 /home/oracle/backup/example01.dbf 13212707628
--可以发现第1次因为没有1级备份,日志不应用。下次就ok了。
Starting recover at 2015-12-07 09:41:15
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=00001 name=/home/oracle/backup/system01.dbf
recovering datafile copy file number=00002 name=/home/oracle/backup/sysaux01.dbf
recovering datafile copy file number=00003 name=/home/oracle/backup/undotbs01.dbf
recovering datafile copy file number=00004 name=/home/oracle/backup/users01.dbf
recovering datafile copy file number=00005 name=/home/oracle/backup/example01.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/backup/11qo76i2_1_1
channel ORA_DISK_1: piece handle=/home/oracle/backup/11qo76i2_1_1 tag=INCR_UPDATE
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:41:16
Starting backup at 2015-12-07 09:41:16
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
input datafile file number=00001 name=/mnt/ramdisk/book/system01.dbf
input datafile file number=00002 name=/mnt/ramdisk/book/sysaux01.dbf
input datafile file number=00005 name=/mnt/ramdisk/book/example01.dbf
input datafile file number=00003 name=/mnt/ramdisk/book/undotbs01.dbf
channel ORA_DISK_1: starting piece 1 at 2015-12-07 09:41:16
channel ORA_DISK_1: finished piece 1 at 2015-12-07 09:41:19
piece handle=/home/oracle/backup/13qo76ls_1_1 tag=INCR_UPDATE comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting incremental level 1 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 2015-12-07 09:41:20
channel ORA_DISK_1: finished piece 1 at 2015-12-07 09:41:21
piece handle=/home/oracle/backup/14qo76lv_1_1 tag=INCR_UPDATE comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2015-12-07 09:41:21
$ ll | grep -v "dbf"
total 3131808
-rw-r----- 1 oracle oinstall 196608 2015-12-07 09:39:15 11qo76i2_1_1
-rw-r----- 1 oracle oinstall 10321920 2015-12-07 09:39:18 12qo76i5_1_1
-rw-r----- 1 oracle oinstall 221184 2015-12-07 09:41:17 13qo76ls_1_1
-rw-r----- 1 oracle oinstall 10321920 2015-12-07 09:41:20 14qo76lv_1_1
--看来增量备份不能放在这个目录,这样比较混乱。
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#
------------ -------------------------------- ----------------- -------------------------------------------------- ------------------
1 INCR_UPDATE 0 /home/oracle/backup/system01.dbf 13212707950
2 INCR_UPDATE 0 /home/oracle/backup/sysaux01.dbf 13212707950
3 INCR_UPDATE 0 /home/oracle/backup/undotbs01.dbf 13212707950
4 INCR_UPDATE 0 /home/oracle/backup/users01.dbf 13212707950
5 INCR_UPDATE 0 /home/oracle/backup/example01.dbf 13212707950
--补充如果
RMAN> backup as copy database format '/home/oracle/backup/%b';
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#
------------ -------------------------------- ----------------- -------------------------------------------------- ------------------
1 TAG20151207T094732 /home/oracle/backup/system01.dbf 13212708292
2 TAG20151207T094732 /home/oracle/backup/sysaux01.dbf 13212708294
3 TAG20151207T094732 /home/oracle/backup/undotbs01.dbf 13212708298
4 TAG20151207T094732 /home/oracle/backup/users01.dbf 13212708288
5 TAG20151207T094732 /home/oracle/backup/example01.dbf 13212708296
-- INCREMENTAL_LEVEL = NULL.
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/267265/viewspace-1867921/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/267265/viewspace-1867921/