官方文档 恢复备份指南五 Configuring the RMAN Environment

本章内容:
  • Configuring the Environment for RMAN Backups    配置RMAN环境
  • Configuring RMAN to Make Backups to a Media Manager 备份到介质管理器
  • Configuring the Fast Recovery Area    配置快速恢复区
  • Configuring the Backup Retention Policy    配置备份保留策略
  • Backup Optimization and the CONFIGURE command    备份优化
  • Configuring an Archived Redo Log Deletion Policy    配置归档日志删除策略
  • Configuring RMAN in a Data Guard Environment    在DG下配置RMAN

1.Configuring the Environment for RMAN Backups 
    本节内容:
  • Showing and Clearing Persistent RMAN Configurations    查看和清除RMAN配置
  • Configuring the Default Device for Backups: Disk or SBT    配置默认备份设备:磁盘或SBT
  • Configuring the Default Type for Backups: Backup Sets or Copies    设置备份类型:备份集或镜像
  • Configuring Channels    配置通道
  • Configuring Control File and Server Parameter File Autobackups    配置文件和控制文件自动备份

    1)Showing and Clearing Persistent RMAN Configurations    查看和清除RMAN配置
    用show all显示所有的配置
RMAN>show all
使用目标数据库控制文件替代恢复目录
db_unique_name 为 ORCL11G 的数据库的 RMAN 配置参数为:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
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 COMPRESSION ALGORITHM 'BZIP2'; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO 'D:APPWJPRODUCT11.1.0DB_1DATABASESNCFORCL11G.ORA'; # default
    显示某个配置
RMAN> show retention policy;

db_unique_name 为 ORCL11G 的数据库的 RMAN 配置参数为:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
    清除配置 CONFIGURE XX CLEAR,清除配置后,变成默认值
CONFIGURE BACKUP OPTIMIZATION CLEAR;
CONFIGURE RETENTION POLICY CLEAR;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK CLEAR;


    2)Configuring the Default Device for Backups: Disk or SBT  设备备份设备磁盘或磁带
    没有指定备份到磁盘或磁带时会使用默认的设置.
    
CommandExplanation

CONFIGURE DEFAULT DEVICE TYPE TO DISK  备份到磁盘

Specifies that backups should go to disk by default.  配置后默认备份到磁盘

If a recovery area is enabled, then the backup location defaults to the fast recovery area. Otherwise, the backup location defaults to an operating system-specific directory on disk.

When backing up to disk, the logical block size of the database file must be an even multiple of the physical block size of the destination device. For example, a device of type DISK with a block size of 2 kilobytes can only be used as a destination for backups of database files with logical block sizes of 2 KB, 4 KB, 6 KB, and so on. Most disk drives have physical block sizes of 512 bytes, so this limitation rarely affects backup to disk drives. Nevertheless, you can encounter this limitation when backing up to a writable DVD or a device that has a larger physical block size.

如果配置了FRA,不指定路径时就备份到FRA.当备份到磁盘时,逻辑块的大小必须是物理块大小的数据倍.

CONFIGURE DEFAULT DEVICE TYPE TO sbt 备份到磁带

Specifies that backups should go to tape by default.

"Configuring RMAN to Make Backups to a Media Manager" explains how to set up RMAN for use with a media manager. After RMAN can communicate with the media manager, you can configure RMAN to make backups to tape and specify SBT as the default device type.

配置后默认备份到磁带.
在备份时可以指定备份
BACKUP DEVICE TYPE sbt DATABASE;
BACKUP DEVICE TYPE DISK DATABASE;


3)Configuring the Default Type for Backups: Backup Sets or Copies 备份成备份集还是镜像
备份集可以写在磁盘和磁带上,而镜像只能写在磁盘上.
设置备份类型
CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COPY; # image copies
CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO BACKUPSET; # uncompressed
设备备份类型并启用压缩备份
CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COMPRESSED BACKUPSET;
CONFIGURE DEVICE TYPE sbt BACKUP TYPE TO COMPRESSED BACKUPSET;


4)Configuring Channels  配置通道
两种方式配置通道:configure channel或者allocate channel,allocate只在本次备份时有用,是临时的配置
注意:configure channel会覆盖上次configure channel的配置,如
CONFIGURE CHANNEL DEVICE TYPE DISK MAXPIECESIZE 2G;
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT /tmp/%U;
在执行第二个命令后,第 一个命令的 MAXPIECESIZE 2G 将会设置为默认值

<1>Configuring Channels for Disk配置磁盘通道
默认情况下,rman会配置一个通道执行所有操作,可以修改默认通道的选项,如设置备份位置;
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/disk1/ora_df%t_s%s_s%p';
%t表示备份的时间,%s表示备份集的序号,%p表示备份片的序号
注意:如果指定了format选项,则rman不会将备份保存到FRA中.

配置备份集到ASM
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '+dgroup1';


<2>Configuring Parallel Channels for Disk and SBT Devices 配置并行度
通道的个数决定了备份时的并行度.一般规则是,通道的个数与备份设备的个数相匹配,如一个通道对应一个磁带驱动器,一个通道对应一个磁盘驱动器.错误的不配置不利于备份的I/O性能
在配置sbt时,可以设置并行度
RMAN> CONFIGURE DEVICE TYPE sbt PARALLELISM 2;
 
old RMAN configuration parameters:
CONFIGURE DEVICE TYPE 'SBT_TAPE' BACKUP TYPE TO COMPRESSED BACKUPSET PARALLELISM 1;
new RMAN configuration parameters:
CONFIGURE DEVICE TYPE 'SBT_TAPE' PARALLELISM 2 BACKUP TYPE TO COMPRESSED BACKUPSET;
new RMAN configuration parameters are successfully stored
同时设置并行度和备份类型:
RMAN> CONFIGURE DEVICE TYPE sbt BACKUP TYPE TO BACKUPSET;
 
old RMAN configuration parameters:
CONFIGURE DEVICE TYPE 'SBT_TAPE' PARALLELISM 2 BACKUP TYPE TO COMPRESSED BACKUPSET;
new RMAN configuration parameters:
CONFIGURE DEVICE TYPE 'SBT_TAPE' BACKUP TYPE TO BACKUPSET PARALLELISM 2;
new RMAN configuration parameters are successfully stored
注意:使用configure device type命令时,只进行指定的修改,不会修改以前配置过的. 上面的配置中, COMPRESSED 选项是有效的

5)Manually Overriding Configured Channels手工覆盖默认通道配置
手动分配通道时,会覆盖默认的通道配置
RUN
{
  ALLOCATE CHANNEL c1 DEVICE TYPE DISK;
  BACKUP TABLESPACE users;
}

这时只会使用手动分配的通道c1


6)Configuring Control File and Server Parameter File Autobackups设置控制文件和spfile自动备份
配置控制文件和spfile文件自动备份后,当有新的备份信息时就会自动备份控制文件,在数据库结构变化(如新增加数据文件)时,也会备份控制文件.使用控制文件和参数文件自动备份后,即使当前的控制文件参数文件和catalog丢失,也能恢复.
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP OFF;

7)Configuring the Control File Autobackup Format 设置控制文件自动备份格式
自动备份的控制文件和spfile以%F做为格式,F%表示c-IIIIIIIIII-YYYYMMDD-QQ   IIIIIIIIII表示DBID YYYYMMDD表示日期 QQ 是16进制的数字,从00到FF.
还有其它的格式,如D%,使用其它的格式不能一定能使用自动备份的控制文件和spfile
可以改变备份格式:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT
  FOR DEVICE TYPE
deviceSpecifier TO 'string';

deviceSpecifier   表示备份设备disk或type string 表示路径,必须%F,如:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT
  FOR DEVICE TYPE DISK TO '?/oradata/cf_%F';
保存到ASM
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT
  FOR DEVICE TYPE DISK TO '+dgroup1/%F';
清除某种设备的自动备份文件格式:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK CLEAR;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE sbt CLEAR;

8)Overriding the Configured Control File Autobackup Format  覆盖自动备份文件格式
有本种方法
  1. SET CONTROLFILE AUTOBACKUP FORMAT (within a RUN block)     RUN块内
  2. SET CONTROLFILE AUTOBACKUP FORMAT (at RMAN prompt)    提示符下
  3. CONFIGURE CONTROLFILE AUTOBACKUP FORMAT     configure命令
如:
SET CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO 'controlfile_%F';
BACKUP AS COPY DATABASE;
RUN
{
  SET CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/tmp/%F.bck';
  BACKUP AS BACKUPSET
    DEVICE TYPE DISK
    DATABASE;
}



2.Configuring RMAN to Make Backups to a Media Manager  备份到介质管理器
本节讲如何备份到第三方的介质管理器,包含以下内容:
  1. Prerequisites for Using a Media Manager with RMAN     事先准备
  2. Determining the Location of the Media Management Library    介质管理器的库文件位置
  3. Configuring Media Management Software for RMAN Backups    设置介质管理软件
  4. Testing Whether the Media Manager Library Is Integrated Correctly    检查介质管理器库是否完整
  5. Configuring SBT Channels for Use with a Media Manager    配置SBT通道

1)Prerequisites for Using a Media Manager with RMAN 准备
将介质管理器安装到数据库服务器或网络上,以便能连接到RMAN,确保服务器能读写这个设备.然后安装介质管理模块(Then, obtain and install the third-party media management module for integration with the database server),这个模块包含了RMAN可以加载的介质管理库.

2)Determining the Location of the Media Management Library 查找介质管理库的位置
在使用SBT备份时,要指定SBT_LIBRARY参数:
CONFIGURE CHANNEL DEVICE TYPE sbt
  PARMS 'SBT_LIBRARY=pathname';

如果没有指定介质管理库的位置,RMAN会寻找一些默认的位置,在linux和unix上
/opt/oracle/extapi/[32,64]/{SBT}/{VENDOR}/{VERSION}/libobk.so
文件的后缀:
.so, .sl on HP-UX,
.a on AIX,
windows下:
%SYSTEM_DRIVE%oracleextapi[32,64]{SBT}{VENDOR}{VERSION}orasbt.dll
如果以上位置找不到,RMAN会从$PATH和$LIBPATH寻找.如果OS设置不允许查找PATH和$LIBPATH,设置SBT_SECURE=1

3)Configuring Media Management Software for RMAN Backups 配置介质管理软件
根据不同的介质管理软件,可能以设置介质池用户类等.
参数PARMS 向介质管理器发送说明信息.下面展示用Oracle Secure Backup 做介质管理器时设置PARMS 参数备份到叫datafile_mf的磁带组:
CONFIGURE CHANNEL DEVICE TYPE 'SBT_TAPE'
  PARMS 'ENV=(OB_MEDIA_FAMILY=datafile_mf)';

4)Testing Whether the Media Manager Library Is Integrated Correctly 检查介质管理器正确性
测试分配通道:
RUN
{
  ALLOCATE CHANNEL c1 DEVICE TYPE sbt
    PARMS 'SBT_LIBRARY=/mydir/lib/libobk.so,
    ENV=(OB_DEVICE=drive1,OB_MEDIA_FAMILY=datafile_mf)';
}
检查输出,如果没有收到ORA-27211错误,说明介质管理器可用:
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of allocate command on c1 channel at 11/30/2007 13:57:18
ORA-19554: error allocating device, device type: SBT_TAPE, device name:
ORA-27211: Failed to load Media Management Library
Additional information: 25
检查介质管理器安装情况,检查SBT_LIBRARY是否正确.
任何时间,分配通道出错,都会记录在自动诊断库(ADR)中:
SKGFQ OSD: Error in function sbtinit on line 2278
SKGFQ OSD: Look for SBT Trace messages in file /oracle/rdbms/log/sbtio.log
SBT Initialize failed for /oracle/lib/libobk.so
修复问题后,执行一次备份测试;
RUN
{
  ALLOCATE CHANNEL c1 DEVICE TYPE sbt
    PARMS 'SBT_LIBRARY=/mydir/lib/libobk.so,
    ENV=(OB_DEVICE=drive1,OB_MEDIA_FAMILY=datafile_mf)';
  RESTORE SPFILE TO PFILE '/tmp/test_restore.f';
  # If your database does not use a server parameter file, use:
  # RESTORE CURRENT CONTROLFILE TO '/tmp/test_restore.f';
}

5)Configuring SBT Channels for Use with a Media Manager 配置SBT通道
介质管理器上备份片的名称
备份片的名称由FORMAT控制,介质管理器将备份片当作一个文件,所以每个文件都要不同名.一般情况下命名格式可以使用%U,如果不指定备份片文件名格式,RMAN自动按照U%来设置.同时注意介质管理器支持的文件名格式.
配置默认的备份设备并配置SBT通道
CONFIGURE DEFAULT DEVICE TYPE TO sbt;
CONFIGURE CHANNEL DEVICE TYPE sbt
  PARMS 'ENV=(OB_RESOURCE_WAIT_TIME=1minute,OB_DEVICE=tape1)';
如果有多个磁带驱动器,设置并行度:
CONFIGURE DEVICE TYPE sbt PARALLELISM 2;
检查通道选项:
SHOW CHANNEL FOR DEVICE TYPE sbt
执行备份:
backup database;


3.Configuring the Fast Recovery Area 配置快速恢复区
FRA是存放备份相关文件磁盘空间,ORACLE建议使用FRA,本节主讲:
  1. Overview of the Fast Recovery Area FRA概述                    
  2. Enabling the Fast Recovery Area    开启FRA
  3. Disabling the Fast Recovery Area 关闭FRA
  4. Configuring Locations for Control Files and Redo Logs 设置控制文件和日志文件位置
  5. Configuring RMAN File Creation in the Fast Recovery Area    配置备份到FRA

1)Overview of the Fast Recovery Area FRA概述   
FRA包含控制文件日志文件归档日志文件数据文件备份文件,其它数据库使用的文件永久放在FRA中,备份文件和归档日志暂时放在FRA中,在备份文件过期后,RMAN可以删除过期文件.FRA是ORACLE管理(OMF)的空间,ORACLE可以控制FRA的大小和文件的命名.
FRA的文件如下:
FilesTypeDatabase Behavior When Fast Recovery Area Is Inaccessible

Multiplexed copies of the current control file

Permanent

The instance fails if the database cannot write to a multiplexed copy of the control file stored in the fast recovery area. Failure occurs even if accessible multiplexed copies are located outside the recovery area.如果控制文件不可读,则实例崩溃

See Also: "Configuring Control File Locations" to learn how to configure control files in the recovery area

Online redo log files

Permanent

Instance availability is not affected if a mirrored copy of the online redo log exists in an accessible location outside the fast recovery area. Otherwise, the instance fails.

如果一个日志组中的所有日志不可读写,则实例崩溃,只要有一个可读写,实例就可以运行.

See Also: "Configuring Online Redo Log Locations" to learn how to configure online redo logs in the recovery area

Archived redo log files

Transient

Instance availability is not affected if the log is archived to an accessible location outside the fast recovery area. Otherwise, the database eventually halts because it cannot archive the online redo logs.

See Also: "Configuring Archived Redo Log Locations" to learn how to configure archived redo logs in the recovery area

Foreign archived redo log files

Transient

Instance availability is not affected.

Note: Foreign archived redo logs are received by a logical standby database for a LogMiner session. Unlike a normal archived log, a foreign archived redo log is associated with a different DBID. For this reason, it cannot be backed up or restored on a logical standby database.

Image copies of data files and control files

Transient

Instance availability is not affected.

Backup pieces

Transient

Instance availability is not affected.

Flashback logs

Transient

Instance availability is not affected if guaranteed restore points are not defined. In this case, the database automatically disables Flashback Database, writes a message to the alert log, and continues with database processing. If guaranteed restore points are configured, the instance fails because of interdependencies on the flashback logs.

The Oracle Flashback Database feature, which provides a convenient alternative to database point-in-time recovery (DBPITR), generates flashback logs. These logs are transient files and must be stored in the fast recovery area. Unlike other transient files, flashback logs cannot be backed up to other media. If the fast recovery area has insufficient space to store flashback logs and meet other backup retention requirements, then the recovery area may delete flashback logs.

See Also: "Enabling Flashback Database" to learn how to enable flashback logging




Oracle Managed Files and Automatic Storage Management   OMF 和ASM:
FRA可以放在ASM中,是可以被OMF管理的空间是.不设置FRA同样可以使用OMF来管理ASM,但是不能管理备份相关的文件(这里指空间控制等).ORACLE建议将FRA设置在ASM中以便使用OMF来管理
ORACLE如何管理FRA中的空间:
ORACLE不会删除有效的文件,如数据文件日志文件控制文件SPFILE等,在FRA空间不足时,会删除闪回日志.PS:如果没有设置备份保留策略的话,ORACLE不会自动删除FRA中的归档日志和过期的备份.所以不要将归档日志放在FRA中,一旦FRA空间满了,无法归档,数据库会停止.

2)Enabling the Fast Recovery Area 开启FRA
开启FRA需要设置两个参数:
DB_RECOVERY_FILE_DEST_SIZE  FRA大小
DB_RECOVERY_FILE_DEST   FRA路径

DB_RECOVERY_FILE_DEST_SIZE

Yes

Specifies the disk quota, which is maximum storage in bytes of data to be used by the recovery area for this database. You must set this parameter beforeDB_RECOVERY_FILE_DEST.

The DB_RECOVERY_FILE_DEST_SIZE setting does not include the following kinds of disk overhead:

  • Block 0 or the operating system block header of each Oracle Database file is not included.

    Allow an extra 10% for this data when computing the actual disk usage required for the fast recovery area.

  • DB_RECOVERY_FILE_DEST_SIZE does not indicate the real size occupied on disk when the underlying file system is mirrored, compressed, or affected by overhead not known to Oracle Database.

    For example, if the recovery area is on a two-way mirrored ASM disk group, each file of x bytes occupies 2x bytes on the ASM disk group. In this case, setDB_RECOVERY_FILE_DEST_SIZE to no more than half the size of the disks for the ASM disk group. Likewise, when using a three-way mirrored ASM disk group,DB_RECOVERY_FILE_DEST_SIZE must be no greater than one third the size of the disks in the disk group, and so on.

DB_RECOVERY_FILE_DEST

Yes

Specifies the recovery area location, which can be a file system directory or ASM disk group, but not a raw disk. The location must be large enough for the disk quota.可以磁盘或ASM上,但是不能在RAW设备上

DB_FLASHBACK_RETENTION_TARGET

No

Specifies the upper limit (in minutes) on how far back in time the database may be flashed back. This parameter is required only for Flashback Database.

设置闪回日志保存时间,不一定能保证.比如设置为1440分钟,表示最大可保存1440分钟,也可能只能保存10分钟,具体看闪回空间的大小,也可能保存的比1440分钟大.其实没有啥意义的参数.

This parameter indirectly determines how much flashback log data is kept in the recovery area. The size of flashback logs generated by the database can vary considerably depending on the database workload. If more blocks are affected by database updates during a given interval, then more disk space is used by the flashback log data generated for that interval.


如果要设置FRA,请与数据文件日志文件控制文件归档日志文件等分开,放在不同的磁盘上.

3)Disabling the Fast Recovery Area 关闭FRA
三步:
A ALTER DATABASE FLASHBACK OFF;
B 如果使用使用FRA保存归档日志,把 归档日志放在其它地方:
ALTER SYSTEM SET LOG_ARCHIVE_DEST_1='LOCATION=/ORACLE/DBS/';

ALTER SYSTEM SET DB_RECOVERY_FILE_DEST=''; 



4)Configuring Locations for Control Files and Redo Logs 设置控制文件和归档日志文件路径
redo log位置由三个参数控制:
DB_CREATE_ONLINE_LOG_DEST_n 
DB_RECOVERY_FILE_DEST 
DB_CREATE_FILE_DEST 
优先级:
DB_CREATE_ONLINE_LOG_DEST_n---> DB_CREATE_FILE_DEST ----> DB_RECOVERY_FILE_DEST

控制位置由四个参数决定
CONTROL_FILES
DB_CREATE_ONLINE_LOG_DEST_n
DB_RECOVERY_FILE_DEST
DB_CREATE_FILE_DEST 
优先级: CONTROL_FILES---> DB_CREATE_ONLINE_LOG_DEST_n---> DB_CREATE_FILE_DEST----> DB_RECOVERY_FILE_DEST


归档日志的位置由三个参数控制DB_RECOVERY_FILE_DEST  LOG_ARCHIVE_DEST_n  LOG_ARCHIVE_DEST 
如果归档日志放在FRA中,归档日志将由ORACLE自动命名,此时设置LOG_ARCHIVE_FORMAT参数是无效的.
如果设置了参数DB_RECOVERY_FILE_DEST (FRA),则并且LOG_ARCHIVE_DEST_n 没有设置,则LOG_ARCHIVE_DEST_10 是自动设置为FRA路径,并且归档将会保存在FRA,如果不想使用FRA,则将LOG_ARCHIVE_DEST_10 设置为其它值.设置了DB_RECOVERY_FILE_DEST 同样可以设置LOG_ARCHIVE_DEST_n .
注意: LOG_ARCHIVE_DEST_n  和LOG_ARCHIVE_DEST 是冲突的,不能同时设置这两个参数,只能二选一



4.Configuring the Backup Retention Policy   设置RMAN保留策略
有两种保留策略:
基于冗余的保留策略
基于保留期的策略
CONFIGURE RETENTION POLICY 命令设置保留策略

1)Configuring a Redundancy-Based Retention Policy  基于冗余的保留策略
REDUNDANCY :冗余的个数.一个备份可以有几个冗余,超过冗余的备份视为过期的
举例说明:
CONFIGURE RETENTION POLICY TO REDUNDANCY 3;
表示数据文件超过三个备份后过期较早的备份过期.比如周一至周三都备份一次,周四备份后,则周一的备份是过期.RMAN为未过期的备份保留归档日志和增量备份
默认的冗余策略是1
注意:当REDUNDANCY 为1时,如周一 0级备份,周二1级累积备份,周三 1级累积备份,周四增量完全备份,则在周三时,周一周二的备份不过期,因为周二的备份根据保留策略要保留一天,不过期,而周一的备份会被周三使用,也不过期.同样,如果周4执行1级累积备份,则周二的备份过期,周一周三的不过期.因为周二的备份已经超过两天,而且不会被周四使用,周三的备份根据保留策略也要保留一天不过期,而周一的备份被周四使用也不过期.如果周一到周四都执行差异1级备份,周周一周二周三的备份都不过期,因为都会被周四使用.
因为周三的周一周二的备份则是周三的备份不是过期,因为周三的0级备份被周4的增量备份使用.
CONFIGURE RETENTION POLICY TO REDUNDANCY 3;

2)Configuring a Recovery Window-Based Retention Policy 基于窗口的的策略
基于保留期的策略:保证数据库可以还原到该保留期的任意一个时间点.如:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
则可以使数据库恢复到最近7天之内的任意时间点的所需要的任何0级1级备份和归档日志都会被保留.也可能保留7天这前的备份,如上次的完全备份是7天以前的,最近7天只做了增量备份,则这个完全备份也会保留.

综合以上两条,当前正在使用的备份不受保留期影响

3)取消保留策略
CONFIGURE RETENTION POLICY TO NONE;
则RMAN不认为任何备份会过期
在使用FRA时,不要取消保留策略,这样就不会自动删除过期的备份和归档了.


5.Backup Optimization and the CONFIGURE command  备份优化
可以启用备份优化使RMAN不备份某些已经备份过的文件从而加快备份速度
以下情况使用备份优化:
Type of FileCriteria to Determine an Identical File

Data file

The data file must have the same DBIDcheckpoint SCN, creation SCN, and RESETLOGS SCN and time as a data file in a backup. The data file must be offline-normal, read-only, or closed normally.

数据文件有相同的DBID CHECKPOINT SCN 日志序列,已经备份过并且当前是正常脱机或read-only状态

Archived log

Same DBID, thread, sequence number, and RESETLOGS SCN and time

已经备份过的归档日志

Backup set

Same DBID, backup set record ID, and stamp


只有满足以下条件,才会启用备份优化
A CONFIGURE BACKUP OPTIMIZATION ON   OPTIMIZATION 参数为on
B  执行的BACKUP DATABASE或BACKUP ARCHIVELOG命令中带有ALL或LIKE参数。
C 分配的通道仅使用了一种设备类型,不能同时使用DISK和SBT

当然,可以不使用优化器,设置OPTIMIZATION 为OFF或者使用force命令
BACKUP DATABASE FORCE;
BACKUP ARCHIVELOG ALL FORCE;


SBT上基于窗口的备份优化
基于窗口的备份优化开启,在SBT上,RMAN会备份窗口之前的备份.如:
Today is February 21.   今天二月21号
The recovery window is 7 days. 窗口为7天
The most recent backup of tablespace tools to tape is January 3. 表空间tools上次备份在一月3号
Tablespace tools is read-only.   表空间tools只读
二月21号执行备份将表空间tools备份到磁带,RMAN依然会备份tools表空间虽然从一月3号开始表空间tools没有改变.原因:根据保留策略表空间7天内没有备份.
这种特性是为了让介质管理器让旧的备份过期.否则介质管理器会无限期的保留tools表空间的上个备份.

SBT上基于冗余和备份优化
与磁盘上的保留策略一样.
CONFIGURE DEFAULT DEVICE TYPE TO sbt;
CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE RETENTION POLICY TO REDUNDANCY 2;
DayActionResultRedundant Backup

Monday

Take users offline normal.

  

Tuesday

BACKUP DATABASE

The users tablespace is backed up.

 

Wednesday

BACKUP DATABASE

The users tablespace is backed up.

 

Thursday

BACKUP DATABASE

The users tablespace is backed up.

Tuesday backup

Friday

BACKUP DATABASE

The users tablespace is not backed up.

Tuesday backup

Saturday

BACKUP DATABASE

The users tablespace is not backed up.

Tuesday backup

Sunday

DELETE OBSOLETE

The Tuesday backup is deleted.

 

Monday

BACKUP DATABASE

The users tablespace is backed up.

Wednesday backup




6.Configuring an Archived Redo Log Deletion Policy  归档日志的保留策略
命令:CONFIGURE ARCHIVELOG DELETION POLICY BACKED UP integer TIMES TO disksbt.对所有归档日志路径都有效
数据库可以自动删除归档日志,用户可以通过RMAN命令删除归档日志.注意:只有FRA中的归档日志可以自动删除.FRA中的归档日志会被尽可能久的保留.使用BACKUP ... DELETE INPUT 或者 DELETE ARCHIVELOG 命令可以删除任何地方的归档日志.
默认情况下,归档日志保留策略是关闭的(因此FRA中的归档日志不会自动删除).归档日志在没有保留策略的条件下,当归档日志不被备份或者数据库闪回使用并且已经备份过一次的情况下,归档日志是过期状态,是可以删除的.
命令CONFIGURE ARCHIVELOG DELETION POLICY BACKED UP integer TIMES TO disksbt可以设置归档日志的保留策略.当归档日志已经备份过,并且备份超过保留策略时,归档日志是过期状态.(以上两条可以看出,归档日志过期的前提条件之一是必须备份过一次).
当设置了BACKED UP integer TIMES TO DEVICE TYPE后,归档日志备份过integer次数据之前, BACKUP ARCHIVELOG命令都会备份归档日志.可以指定force命令强制备份归档日志.



7.Configuring RMAN in a Data Guard Environment  DG环境下配置RMAN
DG下,可以用configure命令来注册和配置物理数据库.RMAN使用DB_UNIQUE_NAME 来区分DG中的各个数据库,因此要维护好这个参数.DG下必须使用catalog.此时,如果指定DBID,不连接到目标主机也可以配置物理备库的备份信息,甚至还可以配置一台根本不存在的物理备库.
配置方法:
CONFIGURE DB_UNIQUE_NAME命令定义了哪个数据库连接到catalog.当RMAN同时连接CATALOG和TARGET备库时,如果target数据库没有注册,会自动注册到CATALOG.
CONFIGURE FOR DB_UNIQUE_NAME 命令配置指定的数据库,如ALL FOR DB_UNIQUE_NAME
注:对DG环境不熟悉,第7条姑且看看,请自行研究











原文地址:https://www.cnblogs.com/skyrim/p/3821316.html