--*******************************************
-- RMAN 备份 路 径 困惑 ( 使用 plus archivelog 时 )
--*******************************************
最近 RMAN 备份时 , 碰 到一点疑惑。即使用 plus archivelog 时 不管是使用 format 参数 指定 备份 文件的路 径还 是使用 configure 配置 RMAN 备份 路 径 ,都不能
将数 据文件和日志文件 备份 到同一路 径 。在因 为 以前使用 RMAN 备份 ,都是 单独备份数 据文件和日志文件,所以一直 没 有在意 这个问题 。下面 给 出具体事例。
一、指定 备份 路 径备份数 据 库 及 归档 日志
RMAN> backup database format '/u01/bk/bk_db_%U' plus archivelog ;
Starting backup at 02 -MAY- 11
current log archived
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid = 146 devtype= DISK
channel ORA_DISK_1: starting archive log backupset
channel ORA_DISK_1: specifying archive log (s) in backup set
input archive log thread = 1 sequence = 50 recid= 10 stamp= 750091269
input archive log thread = 1 sequence = 51 recid= 11 stamp= 750091281
input archive log thread = 1 sequence = 52 recid= 12 stamp= 750091286
input archive log thread = 1 sequence = 53 recid= 13 stamp= 750092325
input archive log thread = 1 sequence = 54 recid= 14 stamp= 750092487
input archive log thread = 1 sequence = 55 recid= 15 stamp= 750093621
input archive log thread = 1 sequence = 56 recid= 16 stamp= 750094799
input archive log thread = 1 sequence = 57 recid= 17 stamp= 750095198
input archive log thread = 1 sequence = 58 recid= 18 stamp= 750099671
input archive log thread = 1 sequence = 59 recid= 19 stamp= 750099848
input archive log thread = 1 sequence = 60 recid= 20 stamp= 750099945
input archive log thread = 1 sequence = 61 recid= 21 stamp= 750103678
channel ORA_DISK_1: starting piece 1 at 02 -MAY- 11
channel ORA_DISK_1: finished piece 1 at 02 -MAY- 11
piece handle=/u01/app/oracle/flash_recovery_area/ODBP/backupset/ 2011 _05_02/ -- 归档 日志放在了 闪 回 区
o1_mf_annnn_TAG20110502T180758_6vx0mzl2_.bkp tag=TAG20110502T180758 comment = NONE
channel ORA_DISK_1: backup set complete , elapsed time : 00 : 00 : 02
Finished backup at 02 -MAY- 11
Starting backup at 02 -MAY- 11
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile (s) in backupset
input datafile fno= 00001 name =/u01/app/oracle/oradata/odbp/system01.dbf
input datafile fno= 00002 name =/u01/app/oracle/oradata/odbp/undotbs01.dbf
input datafile fno= 00003 name =/u01/app/oracle/oradata/odbp/sysaux01.dbf
input datafile fno= 00004 name =/u01/app/oracle/oradata/odbp/users01.dbf
channel ORA_DISK_1: starting piece 1 at 02 -MAY- 11
channel ORA_DISK_1: finished piece 1 at 02 -MAY- 11
piece handle=/u01/bk/bk_db_1dmbbb40_1_1 tag=TAG20110502T180800 comment = NONE -- 数 据文件存放在了指定的路 径
channel ORA_DISK_1: backup set complete , elapsed time : 00 : 00 : 45
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile (s) in backupset
input datafile fno= 00001 name =/u01/app/oracle/oradata/odbp/system01.dbf
input datafile fno= 00002 name =/u01/app/oracle/oradata/odbp/undotbs01.dbf
input datafile fno= 00003 name =/u01/app/oracle/oradata/odbp/sysaux01.dbf
input datafile fno= 00004 name =/u01/app/oracle/oradata/odbp/users01.dbf
channel ORA_DISK_1: starting piece 1 at 02 -MAY- 11
channel ORA_DISK_1: finished piece 1 at 02 -MAY- 11
piece handle=/u01/app/oracle/flash_recovery_area/ODBP/backupset/ 2011 _05_02/ -- 数 据文件同 时 也存放在了 闪 回 区
o1_mf_nnndf_TAG20110502T180800_6vx0og2z_.bkp tag=TAG20110502T180800 comment = NONE
channel ORA_DISK_1: backup set complete , elapsed time : 00 : 00 : 45
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile (s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 02 -MAY- 11
channel ORA_DISK_1: finished piece 1 at 02 -MAY- 11
piece handle=/u01/bk/bk_db_1fmbbb6r_1_1 tag=TAG20110502T180800 comment = NONE -- 控制文件和 spfile 存放到了指定路 径
channel ORA_DISK_1: backup set complete , elapsed time : 00 : 00 : 02
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile (s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 02 -MAY- 11
channel ORA_DISK_1: finished piece 1 at 02 -MAY- 11
piece handle=/u01/app/oracle/flash_recovery_area/ODBP/backupset/ 2011 _05_02/ -- 控制文件和 spfile 同 时 也保存到了 闪 回 区
o1_mf_ncsnf_TAG20110502T180800_6vx0pycl_.bkp tag=TAG20110502T180800 comment = NONE
channel ORA_DISK_1: backup set complete , elapsed time : 00 : 00 : 01
Finished backup at 02 -MAY- 11
Starting backup at 02 -MAY- 11
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archive log backupset
channel ORA_DISK_1: specifying archive log (s) in backup set
input archive log thread = 1 sequence = 62 recid= 22 stamp= 750103776
channel ORA_DISK_1: starting piece 1 at 02 -MAY- 11
channel ORA_DISK_1: finished piece 1 at 02 -MAY- 11
piece handle=/u01/app/oracle/flash_recovery_area/ODBP/backupset/ 2011 _05_02/ -- 归档 日志放在了 闪 回 区
o1_mf_annnn_TAG20110502T180936_6vx0q1dg_.bkp tag=TAG20110502T180936 comment = NONE
channel ORA_DISK_1: backup set complete , elapsed time : 00 : 00 : 02
Finished backup at 02 -MAY- 11
-- 查 看 备份 的 数 据文件、控制文件等信息
[oracle@odbp 2011 _05_02]$ ls -hltr
total 703 M
-rw-r ----- 1 oracle oinstall 4.5M May 2 18:08 o1_mf_annnn_TAG20110502T180758_6vx0mzl2_.bkp
-rw-r ----- 1 oracle oinstall 691M May 2 18:09 o1_mf_nnndf_TAG20110502T180800_6vx0og2z_.bkp
-rw-r ----- 1 oracle oinstall 6.9M May 2 18:09 o1_mf_ncsnf_TAG20110502T180800_6vx0pycl_.bkp
-rw-r ----- 1 oracle oinstall 15K May 2 18:09 o1_mf_annnn_TAG20110502T180936_6vx0q1dg_.bkp
[oracle@odbp 2011 _05_02]$ ls -hltr /u01/bk
total 698 M
-rw-r ----- 1 oracle oinstall 691M May 2 18:08 bk_db_1dmbbb40_1_1
-rw-r ----- 1 oracle oinstall 6.9M May 2 18:09 bk_db_1fmbbb6r_1_1
从 上面的情 况来 看,
1 . 当 指定了 db_recovery_file_dest 参数为 /u01/app/oracle/flash_recovery_area 时 , 则归档 日志被 备份 到此目 录 。
2 . 在 参数 db_recovery_file_dest 参数为闪 回 区时 , 则数 据文件 与 控制文件及 spfile 被使用了 双 重 备份 。
--RMAN 配置信息 为 缺省,未做任何 调 整
RMAN> show all ;
RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1 ; # default
CONFIGURE BACKUP OPTIMIZATION OFF ; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK ; # default
CONFIGURE CONTROLFILE AUTOBACKUP OFF ; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F' ; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1 ; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1 ; # default
CONFIGURE MAXSETSIZE TO UNLIMITED ; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF ; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128' ; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE ; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/10g/dbs/snapcf_odbp.f' ; # default
-- 将 db_recovery_file_dest 参数 置空
SQL > alter system set db_recovery_file_dest= '' ;
System altered.
二、再次使用 RMAN 进 行 备份
RMAN> backup database format '/u01/bk/bk_db_%U' plus archivelog ;
Starting backup at 02 -MAY- 11
current log archived
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid = 138 devtype= DISK
channel ORA_DISK_1: starting archive log backupset
channel ORA_DISK_1: specifying archive log (s) in backup set
input archive log thread = 1 sequence = 50 recid= 10 stamp= 750091269
input archive log thread = 1 sequence = 51 recid= 11 stamp= 750091281
input archive log thread = 1 sequence = 52 recid= 12 stamp= 750091286
input archive log thread = 1 sequence = 53 recid= 13 stamp= 750092325
input archive log thread = 1 sequence = 54 recid= 14 stamp= 750092487
input archive log thread = 1 sequence = 55 recid= 15 stamp= 750093621
input archive log thread = 1 sequence = 56 recid= 16 stamp= 750094799
input archive log thread = 1 sequence = 57 recid= 17 stamp= 750095198
input archive log thread = 1 sequence = 58 recid= 18 stamp= 750099671
input archive log thread = 1 sequence = 59 recid= 19 stamp= 750099848
input archive log thread = 1 sequence = 60 recid= 20 stamp= 750099945
input archive log thread = 1 sequence = 61 recid= 21 stamp= 750103678
input archive log thread = 1 sequence = 62 recid= 22 stamp= 750103776
input archive log thread = 1 sequence = 63 recid= 23 stamp= 750104981
channel ORA_DISK_1: starting piece 1 at 02 -MAY- 11
channel ORA_DISK_1: finished piece 1 at 02 -MAY- 11
piece handle=/u01/app/oracle/ 10 g/dbs/ 1 imbbccm_1_1 tag=TAG20110502T182942 comment = NONE -- 归档 日志 备份 位于 $ORACLE_HOME/dbs 路 径 下
channel ORA_DISK_1: backup set complete , elapsed time : 00 : 00 : 02
Finished backup at 02 -MAY- 11
Starting backup at 02 -MAY- 11
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile (s) in backupset
input datafile fno= 00001 name =/u01/app/oracle/oradata/odbp/system01.dbf
input datafile fno= 00002 name =/u01/app/oracle/oradata/odbp/undotbs01.dbf
input datafile fno= 00003 name =/u01/app/oracle/oradata/odbp/sysaux01.dbf
input datafile fno= 00004 name =/u01/app/oracle/oradata/odbp/users01.dbf
channel ORA_DISK_1: starting piece 1 at 02 -MAY- 11
channel ORA_DISK_1: finished piece 1 at 02 -MAY- 11
piece handle=/u01/bk/bk_db_1jmbbcco_1_1 tag=TAG20110502T182944 comment = NONE -- 数 据文件存放在了指定的路 径
channel ORA_DISK_1: backup set complete , elapsed time : 00 : 00 : 55
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile (s) in backupset
input datafile fno= 00001 name =/u01/app/oracle/oradata/odbp/system01.dbf
input datafile fno= 00002 name =/u01/app/oracle/oradata/odbp/undotbs01.dbf
input datafile fno= 00003 name =/u01/app/oracle/oradata/odbp/sysaux01.dbf
input datafile fno= 00004 name =/u01/app/oracle/oradata/odbp/users01.dbf
channel ORA_DISK_1: starting piece 1 at 02 -MAY- 11
channel ORA_DISK_1: finished piece 1 at 02 -MAY- 11
piece handle=/u01/app/oracle/ 10 g/dbs/ 1 kmbbceg_1_1 tag=TAG20110502T182944 comment = NONE -- 数 据文件同 时 也存放在 $ORACLE_HOME/dbs 路 径 下
channel ORA_DISK_1: backup set complete , elapsed time : 00 : 00 : 55
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile (s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 02 -MAY- 11
channel ORA_DISK_1: finished piece 1 at 02 -MAY- 11
piece handle=/u01/bk/bk_db_1lmbbcg7_1_1 tag=TAG20110502T182944 comment = NONE -- 控制文件及 spfile 备份 位于指定路 径 下
channel ORA_DISK_1: backup set complete , elapsed time : 00 : 00 : 05
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile (s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 02 -MAY- 11
channel ORA_DISK_1: finished piece 1 at 02 -MAY- 11
piece handle=/u01/app/oracle/ 10 g/dbs/ 1 mmbbcgc_1_1 tag=TAG20110502T182944 comment = NONE -- 归档 日志文件 备份 位于 $ORACLE_HOME/dbs 路 径 下
channel ORA_DISK_1: backup set complete , elapsed time : 00 : 00 : 01
Finished backup at 02 -MAY- 11
Starting backup at 02 -MAY- 11
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archive log backupset
channel ORA_DISK_1: specifying archive log (s) in backup set
input archive log thread = 1 sequence = 64 recid= 24 stamp= 750105102
channel ORA_DISK_1: starting piece 1 at 02 -MAY- 11
channel ORA_DISK_1: finished piece 1 at 02 -MAY- 11 -- 控制文件及 spfile 备 同 时 也存放在 $ORACLE_HOME/dbs 路 径 下
piece handle=/u01/app/oracle/ 10 g/dbs/ 1 nmbbcge_1_1 tag=TAG20110502T183142 comment = NONE
channel ORA_DISK_1: backup set complete , elapsed time : 00 : 00 : 02
Finished backup at 02 -MAY- 11
从 上面的 情 况来 看,
1 . 当 db_recovery_file_dest 参数为 空 值时 , 则归档 日志,控制文件及 spfile 被 备份 到 $ORACLE_HOME/dbs 路 径 下
2 . 数 据文件及控制文件同 样实现 了 双 重 备份 ,一 份 位于 $ORACLE_HOME/dbs 路 径 下,一 份 位于用 户 指定路 径 下
三、如何 将归档 日志文件,控制文件, spfile 文件以及 数 据文件 备份 到同一路 径 下,
RMAN> run{
2 > allocate channel ch1 device type disk ;
3 > allocate channel ch2 device type disk ;
4 > backup database format '/u01/bk/bk_db_%U'
5 > plus archivelog format '/u01/bk/bk_lg_%U' ;
6 > release channel ch1;
7 > release channel ch2;}
using target database control file instead of recovery catalog
allocated channel: ch1
channel ch1: sid = 141 devtype= DISK
allocated channel: ch2
channel ch2: sid = 148 devtype= DISK
Starting backup at 02 -MAY- 11
current log archived
channel ch1: starting archive log backupset
channel ch1: specifying archive log (s) in backup set
input archive log thread = 1 sequence = 59 recid= 19 stamp= 750099848
input archive log thread = 1 sequence = 60 recid= 20 stamp= 750099945
input archive log thread = 1 sequence = 61 recid= 21 stamp= 750103678
input archive log thread = 1 sequence = 62 recid= 22 stamp= 750103776
input archive log thread = 1 sequence = 63 recid= 23 stamp= 750104981
input archive log thread = 1 sequence = 64 recid= 24 stamp= 750105102
input archive log thread = 1 sequence = 65 recid= 25 stamp= 750767326
input archive log thread = 1 sequence = 66 recid= 26 stamp= 750769794
channel ch1: starting piece 1 at 02 -MAY- 11
channel ch2: starting archive log backupset
channel ch2: specifying archive log (s) in backup set
input archive log thread = 1 sequence = 50 recid= 10 stamp= 750091269
input archive log thread = 1 sequence = 51 recid= 11 stamp= 750091281
input archive log thread = 1 sequence = 52 recid= 12 stamp= 750091286
input archive log thread = 1 sequence = 53 recid= 13 stamp= 750092325
input archive log thread = 1 sequence = 54 recid= 14 stamp= 750092487
input archive log thread = 1 sequence = 55 recid= 15 stamp= 750093621
input archive log thread = 1 sequence = 56 recid= 16 stamp= 750094799
input archive log thread = 1 sequence = 57 recid= 17 stamp= 750095198
input archive log thread = 1 sequence = 58 recid= 18 stamp= 750099671
channel ch2: starting piece 1 at 02 -MAY- 11
channel ch1: finished piece 1 at 02 -MAY- 11
piece handle=/u01/bk/bk_lg_1ombvlk3_1_1 tag=TAG20110510T110954 comment = NONE -- 归档 日志存放到指定路 径
channel ch1: backup set complete , elapsed time : 00 : 00 : 03
channel ch2: finished piece 1 at 02 -MAY- 11
piece handle=/u01/bk/bk_lg_1pmbvlk3_1_1 tag=TAG20110510T110954 comment = NONE -- 归档 日志存放到指定路 径
channel ch2: backup set complete , elapsed time : 00 : 00 : 03
Finished backup at 02 -MAY- 11
Starting backup at 02 -MAY- 11
channel ch1: starting full datafile backupset
channel ch1: specifying datafile (s) in backupset
input datafile fno= 00001 name =/u01/app/oracle/oradata/odbp/system01.dbf
input datafile fno= 00003 name =/u01/app/oracle/oradata/odbp/sysaux01.dbf
channel ch1: starting piece 1 at 02 -MAY- 11
channel ch2: starting full datafile backupset
channel ch2: specifying datafile (s) in backupset
input datafile fno= 00002 name =/u01/app/oracle/oradata/odbp/undotbs01.dbf
input datafile fno= 00004 name =/u01/app/oracle/oradata/odbp/users01.dbf
channel ch2: starting piece 1 at 02 -MAY- 11
channel ch2: finished piece 1 at 02 -MAY- 11
piece handle=/u01/bk/bk_db_1rmbvlk7_1_1 tag=TAG20110510T110958 comment = NONE -- 数 据文 件存放到指定路 径
channel ch2: backup set complete , elapsed time : 00 : 01 : 09
channel ch2: starting full datafile backupset
channel ch2: specifying datafile (s) in backupset
including current control file in backupset
channel ch2: starting piece 1 at 02 -MAY- 11
channel ch2: finished piece 1 at 02 -MAY- 11
piece handle=/u01/bk/bk_db_1smbvlmd_1_1 tag=TAG20110510T110958 comment = NONE -- 数 据文件存放到指定路 径
channel ch2: backup set complete , elapsed time : 00 : 00 : 07
channel ch2: starting full datafile backupset
channel ch2: specifying datafile (s) in backupset
including current SPFILE in backupset
channel ch2: starting piece 1 at 02 -MAY- 11
channel ch2: finished piece 1 at 02 -MAY- 11
piece handle=/u01/bk/bk_db_1tmbvlml_1_1 tag=TAG20110510T110958 comment = NONE -- 控制文件, spfile 文件存放到指定路 径
channel ch2: backup set complete , elapsed time : 00 : 00 : 08
channel ch1: finished piece 1 at 02 -MAY- 11
piece handle=/u01/bk/bk_db_1qmbvlk7_1_1 tag=TAG20110510T110958 comment = NONE
channel ch1: backup set complete , elapsed time : 00 : 01 : 31
Finished backup at 02 -MAY- 11
Starting backup at 02 -MAY- 11
current log archived
channel ch1: starting archive log backupset
channel ch1: specifying archive log (s) in backup set
input archive log thread = 1 sequence = 67 recid= 27 stamp= 750769890
channel ch1: starting piece 1 at 02 -MAY- 11
channel ch1: finished piece 1 at 02 -MAY- 11
piece handle=/u01/bk/bk_lg_1umbvln2_1_1 tag=TAG20110510T111130 comment = NONE
channel ch1: backup set complete , elapsed time : 00 : 00 : 02
Finished backup at 02 -MAY- 11
released channel: ch1
released channel: ch2
四、 总结 ( RMAN 备份 路 径 )
1 . 在未通 过 configure 命令 设 定 RMAN 备份 文件路 径 以及未修改 db_recovery_file_dest ,且指定了 format 参数 , 则备份 的 数 据文件, 参数 文件,
控制文件,采用了 双 重保 护 方式,一 份 位于指定路 径 ,一 份 位于缺省的 闪 回 区 。同 时归档 日志保存在 闪 回 区 。
2 . 一旦修改了 db_recovery_file_dest 至特定路 径 , 则 同上述功能一 样 ,所不同的是存放到非缺省的 闪 回 区 。
3 . 当 db_recovery_file_dest 为 空 值时 ,同 样 使用 双 重保 护 ,但 这 些文件被放置到了 $ORACLE_HOME/dbs 路 径 下。
4 . 当 使用了 configure channel device type disk format = '/u01/bk/db_%U' 配置 RMAN , 则对 于 badkup database plus archivelog 同 样会 出 现 上
述的情 况 。
5 . 如果指定了 configure channel device type disk format = '/u01/bk/db_%U' , 则单独备份数 据文件和日志文件不存在 问题 ,都 会 存放在指定路 径 。
6 . 在同一 条 命令 来 完成 (badkup database plus archivelog ) 则 需要 单独 指定 数 据文件和日志文件的位置,如下方式:
backup database format '/u01/bk/bk_db_%U'
plus archivelog format '/u01/bk/bk_lg_%U'
五、更多参考
有关性能优化请参考
共享池的 调 整 与优 化(Shared pool Tuning)
Oracle 表 缓 存(caching table) 的使用
有关闪回特性请参考
Oracle 闪 回特性(FLASHBACK DATABASE)
Oracle 闪 回特性(FLASHBACK DROP & RECYCLEBIN)
Oracle 闪 回特性(Flashback Query 、Flashback Table)
Oracle 闪 回特性(Flashback Version 、Flashback Transaction)
有关基于用户管理的备份和备份恢复的概念请参考
Oracle 基于用 户 管理恢 复 的 处 理 ( 详细描述了介质恢复及其处理 )
有关 RMAN 的恢复与管理请参考