分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow
也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴!
Oracle 11g中对于归档日志的删除,除了遵循RMAN保留策略外,也可以通过RMAN来配置归档日志的删除策略,也就是归档日志何时可以被删除。归档日志删除策略适用于所有归档位置(使用快速闪回区FRA/不使用FRA)。本文主要描述归档日志删除策略并给出了具体的演示。
1、关于归档日志删除策略
也就是哪些归档日志符合删除策略能够被删除,如前所述,归档位置适用于所有归档位置(使用快速闪回区FRA/不使用FRA)
当启用该策略后,如归档日志存在于FRA中,则Oracle会尽可能根据保留他们,一旦FRA空间告急,则Oracle会根据归档日志删除策略自动删除
对于不在FRA中的归档日志,需要手动使用delete obsolete或delete archivelog方式来删除日志
无论归档日志存在于FRA内或外,都可以通过BACKUP ... DELETE INPUT or DELETE ARCHIVELOG方式来删除
该策略不适用于使用LogMiner方式从主数据库传送到逻辑standby生成的外部归档日志文件,因为这些日志文件不能够在逻辑standy上备份或恢复
2、配置归档日志删除策略
使用下面的方式来配置归档日志删除策略
configure archivelog deletion policy to backed up 2 times to sbt;
configure archivelog deletion policy to backed up 1 times to device type disk;
configure archivelog deletion policy to applied on standby;
configure archivelog deletion policy to shipped on standby;
configure archivelog deletion policy clear;
对于Oracle 10g没有该特性,但有一个类似的用于配置归档日志被备份次数,如下;
configure archivelog backup copies for device type disk to ${archiveretention};
3、禁用归档日志删除策略
缺省情况下,该策略被设置为none。也就是说根据RMAN备份保留策略,对于FRA中的归档日志,被备份过一次(到磁盘或磁带)即符合条件被删除
如果Oracle不再需要当前的归档日志用于保证数据库时点恢复或数据库闪回,则RMAN备份保留策略认为当前日志为obsolete
在SYSDATE-'DB_FLASHBACK_RETENTION_TARGET'之后创建的归档日志是需要被保留的
4、启用归档日志删除策略
一旦启用该策略,则指定的归档日志被备份数量达到设定值后,这些归档日志能够被删除
BACKUP ARCHIVELOG 会在未超出指定备份数的情况下(比如设置为2)备份归档日志到指定位置,如超出2次,则RMAN会跳过这些备份过2次的归档日志
对于上述的情形,可以为BACKUP ARCHIVELOG适用force选项来强制备份归档日志
如果启用该策略且配置为APPLIED ON STANDBY子句,则所有强制standby位置被apply后,这些归档日志会被RMAN删除
如果启用该策略且配置为SHIPPED ON STANDBY子句,则所有强制standby位置被成功传送后,这些归档日志会被RMAN删除
5、演示归档日志删除策略
[oracle@linux1 ~]$ rman target /Recovery Manager: Release 11.2.0.1.0 - Production on Tue Nov 12 15:10:17 2013--查看当前数据库保留策略RMAN> show retention policy;RMAN configuration parameters for database with db_unique_name USBO are:CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default--查看当前数据库保归档日志留策略RMAN> show archivelog deletion policy;RMAN configuration parameters for database with db_unique_name USBO are:CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default--查看过时的备份RMAN> report obsolete;RMAN retention policy will be applied to the commandRMAN retention policy is set to redundancy 1no obsolete backups found--列出copy副本RMAN> list copy;specification does not match any datafile copy in the repositoryspecification does not match any control file copy in the repositoryList of Archived Log Copies for database with db_unique_name USBO=====================================================================Key Thrd Seq S Low Time ------- ---- ------- - -------------------124 1 121 A 2013/11/12 15:34:15 Name: /u03/database/usbo/fr_area/USBO/archivelog/2013_11_12/o1_mf_1_121_983pm3gp_.arc --当前的归档日志--修改当前的归档日志保留策略为2个备份副本RMAN> configure archivelog deletion policy to backed up 2 times to device type disk;new RMAN configuration parameters:CONFIGURE ARCHIVELOG DELETION POLICY TO BACKED UP 2 TIMES TO DISK;new RMAN configuration parameters are successfully stored--备份归档日志,并删除已经备份的归档日志RMAN> backup archivelog all delete input;Starting backup at 2013/11/12 15:37:25current log archivedusing channel ORA_DISK_1channel ORA_DISK_1: starting archived log backup setchannel ORA_DISK_1: specifying archived log(s) in backup setinput archived log thread=1 sequence=121 RECID=124 STAMP=831310563input archived log thread=1 sequence=122 RECID=125 STAMP=831310645channel ORA_DISK_1: starting piece 1 at 2013/11/12 15:37:26channel ORA_DISK_1: finished piece 1 at 2013/11/12 15:37:27piece handle=/u03/database/usbo/fr_area/USBO/backupset/2013_11_12/o1_mf_annnn_TAG20131112T153726_983pop3p_.bkp tag=TAG20131112T153726 comment=NONEchannel ORA_DISK_1: backup set complete, elapsed time: 00:00:01channel ORA_DISK_1: deleting archived log(s)RMAN-08138: WARNING: archived log not deleted - must create more backups --->出现警告提示,日志当前不能被删除,更多的备份需要创建archived log file name=/u03/database/usbo/fr_area/USBO/archivelog/2013_11_12/o1_mf_1_121_983pm3gp_.arc thread=1 sequence=121RMAN-08138: WARNING: archived log not deleted - must create more backupsarchived log