RMAN的备份保留策略

网友投稿 869 2022-10-04

本站部分文章、图片属于网络上可搜索到的公开信息,均用于学习和交流用途,不能代表睿象云的观点、立场或意见。我们接受网民的监督,如发现任何违法内容或侵犯了您的权益,请第一时间联系小编邮箱jiasou666@gmail.com 处理。

RMAN的备份保留策略

使用RMAN可以对备份集进行管理,其中的一个重要特性是备份保留策略的设置,备份保留策略是为满足备份需求而设置的备份保留原则。备份保留策略可以基于冗余(Redundancy)或者基于恢复窗口(Recovery Window)。对于基于冗余的策略,可以定义一个数字n用于标示RMAN为每个文件保留至少n个不同的备份;在基于恢复窗口的保留策略中,需要定义一个时间长度(例如,一周或一个月),RMAN会保留足够的备份,以便在定义的时间长度内可以进行基于任何时间点的恢复。当备份不再需要时会被标记为废弃(obsolete),但是废弃的备份不会自动删除,只是在RMAN目录中标记为丢弃,其状态依旧为available,要查看标记为丢弃的备份可以使用report obsolete命令,只有使用delete obsolete才会真正删除丢弃的备份。通过在RMAN中执行show all命令可以看到很多参数配置,其中第一项就是冗余策略设置:

RMAN> show all;RMAN 配置参数为:CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # defaultCONFIGURE BACKUP OPTIMIZATION OFF; # defaultCONFIGURE DEFAULT DEVICE TYPE TO DISK; # defaultCONFIGURE CONTROLFILE AUTOBACKUP ON;………缺省的冗余个数设置为1,以下输出标识了一个全备份和归档备份为废弃:RMAN> report obsolete;RMAN 保留策略将应用于该命令将 RMAN 保留策略设置为冗余 1已废弃的备份和副本报表类型 关键字 完成时间 文件名/句柄-------------------- ------ ------------------ --------------------备份集 15 02-3月 -07备份段 15 02-3月 -07 D:\BACKUP\EYGLEARCH_EYGLE_20070302_17备份集 17 02-3月 -07备份段 17 02-3月 -07 D:\BACKUP\EYGLEFULL_EYGLE_20070302_19

如果REDUNDANCY设置为2,则这两个备份集都将被保留:

RMAN> CONFIGURE RETENTION POLICY TO REDUNDANCY 2;新的 RMAN 配置参数:CONFIGURE RETENTION POLICY TO REDUNDANCY 2;已成功存储新的 RMAN 配置参数RMAN> report obsolete;RMAN 保留策略将应用于该命令将 RMAN 保留策略设置为冗余 2未找到已废弃的备份

要删除过期备份可以使用delete obsolete命令(nopromt指定无需确认立即删除):

RMAN> delete noprompt obsolete;RMAN 保留策略将应用于该命令将 RMAN 保留策略设置为冗余 1使用通道 ORA_DISK_1删除以下已废弃的备份和副本:类型 关键字 完成时间 文件名/句柄-------------------- ------ ------------------ --------------------备份集 15 02-3月 -07备份段 15 02-3月 -07 D:\BACKUP\EYGLEARCH_EYGLE_20070302_17备份集 17 02-3月 -07备份段 17 02-3月 -07 D:\BACKUP\EYGLEFULL_EYGLE_20070302_19已删除备份段备份段 handle=D:\BACKUP\EYGLEARCH_EYGLE_20070302_17 recid=15 stamp=616160448已删除备份段备份段 handle=D:\BACKUP\EYGLEFULL_EYGLE_20070302_19 recid=17 stamp=6161605362 对象已删除

如果要长期保留备份集,使之不受保留策略影响,则可以使用RMAN的backup … keep选项,keep until time可以指定备份集保留的时间,keep forever可以指定永远保留备份集。以下命令用于备份指定的表空间,保留时间为365天,注意备份时会提示备份集的过期时间,在备份完成之后,相关的归档日志、控制文件、参数文件会同时备份下来:

E:\>rman target /Recovery Manager: Release 11.2.0.2.0 - Production on Mon Jan 31 16:05:11 2011Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.connected to target database: EYGLEE (DBID=3941320050)RMAN> backup tablespace users format 'E:\backup\users%U.bk'2> keep until time 'sysdate + 365';Starting backup at 31-JAN-11current log archivedusing channel ORA_DISK_1backup will be obsolete on date 31-JAN-12archived logs required to recover from this backup will be backed upchannel ORA_DISK_1: starting full datafile backup setchannel ORA_DISK_1: specifying datafile(s) in backup setinput datafile file number=00004 name=E:\ORADATA\EYGLEE\O1_MF_USERS_6BD0BQBH_.DBFchannel ORA_DISK_1: starting piece 1 at 31-JAN-11channel ORA_DISK_1: finished piece 1 at 31-JAN-11piece handle=E:\BACKUP\USERS0IM3GKGQ_1_1.BK tag=TAG20110131T160857 comment=NONEchannel ORA_DISK_1: backup set complete, elapsed time: 00:00:15using channel ORA_DISK_1backup will be obsolete on date 31-JAN-12archived logs required to recover from this backup will be backed upchannel ORA_DISK_1: starting full datafile backup setchannel ORA_DISK_1: specifying datafile(s) in backup setincluding current SPFILE in backup setchannel ORA_DISK_1: starting piece 1 at 31-JAN-11channel ORA_DISK_1: finished piece 1 at 31-JAN-11piece handle=E:\BACKUP\USERS0JM3GKHA_1_1.BK tag=TAG20110131T160857 comment=NONEchannel ORA_DISK_1: backup set complete, elapsed time: 00:00:01current log archivedusing channel ORA_DISK_1backup will be obsolete on date 31-JAN-12archived logs required to recover from this backup will be backed upchannel ORA_DISK_1: starting archived log backup setchannel ORA_DISK_1: specifying archived log(s) in backup setinput archived log thread=1 sequence=357 RECID=151 STAMP=741888557channel ORA_DISK_1: starting piece 1 at 31-JAN-11channel ORA_DISK_1: finished piece 1 at 31-JAN-11piece handle=E:\BACKUP\USERS0KM3GKHE_1_1.BK tag=TAG20110131T160857 comment=NONEchannel ORA_DISK_1: backup set complete, elapsed time: 00:00:01using channel ORA_DISK_1backup will be obsolete on date 31-JAN-12archived logs required to recover from this backup will be backed upchannel ORA_DISK_1: starting full datafile backup setchannel ORA_DISK_1: specifying datafile(s) in backup setincluding current control file in backup setchannel ORA_DISK_1: starting piece 1 at 31-JAN-11channel ORA_DISK_1: finished piece 1 at 31-JAN-11piece handle=E:\BACKUP\USERS0LM3GKHG_1_1.BK tag=TAG20110131T160857 comment=NONEchannel ORA_DISK_1: backup set complete, elapsed time: 00:00:01Finished backup at 31-JAN-11

注意,使用keep forever命令需要存在恢复目录:

RMAN> backup tablespace system format 'E:\backup\system%U.bk'2> keep forever;Starting backup at 31-JAN-11current log archivedusing channel ORA_DISK_1RMAN-00571: ===========================================================RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============RMAN-00571: ===========================================================RMAN-03002: failure of backup command at 01/31/2011 16:13:52RMAN-06522: KEEP FOREVER option is not supported without the recovery catalog

上一篇:早报│腾讯云成国内最大Serverless开发平台;苹果在线运动课程Fitness+即将上线;哈啰预计明年初推出智能电动车;百度网盘用户规模破 7 亿;Facebook数字货币Libra最快明年推出……
下一篇:Oracle 使用数据泵进行数据卸载
相关文章

 发表评论

暂时没有评论,来抢沙发吧~