众所周知,Oracle Rman的retention policy 在任意一个时刻:只能有一个生效。也就是说,两个retention policy 之间是or的关系。
如下使用catalog数据库完成,因为backup 命令的keep forever关键字只支持catalog
[oracle@vm21 ~]$ rman target / catalog rc/rc@rc
Recovery Manager: Release 10.2.0.1.0 - Production on Mon Dec 15 21:18:06 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: PROD (DBID=275920358)
connected to recovery catalog database
RMAN> backup database format '/home/oracle/keep_test_%U' keep forever nologs;
Starting backup at 15-DEC-14
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=272 devtype=DISK
backup will never be obsolete
archived logs required to recover from this backup will not be kept
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of backup command at 12/15/2014 21:20:13
RMAN-06533: KEEP ... NOLOGS option cannot be used when datafiles are fuzzy
--->该语法是不行的:fuzzy状态是 database open时,datafile的状态(该状态可以从v$datafile_header中获得)
RMAN>backup database format '/home/oracle/keep_test_%U' keep forever logs;
Starting backup at 15-DEC-14
using channel ORA_DISK_1
backup will never be obsolete
archived logs required to recover from this backup will expire when this backup expires
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00004 name=/u01/app/oracle/oradata/PROD/disk1/example_1.dbf
input datafile fno=00001 name=/u01/app/oracle/oradata/PROD/disk1/system01.dbf
input datafile fno=00003 name=/u01/app/oracle/oradata/PROD/disk1/sysaux01.dbf
input datafile fno=00002 name=/u01/app/oracle/oradata/PROD/disk1/undotbs01.dbf
input datafile fno=00009 name=/u01/app/oracle/oradata/PROD/disk1/r_1.dbf
input datafile fno=00007 name=/u01/app/oracle/oradata/PROD/disk1/users_1.dbf
input datafile fno=00008 name=/u01/app/oracle/oradata/PROD/disk1/oltp_1.dbf
input datafile fno=00005 name=/u01/app/oracle/oradata/PROD/disk1/indx_1.dbf
input datafile fno=00006 name=/u01/app/oracle/oradata/PROD/disk1/tools_1.dbf
channel ORA_DISK_1: starting piece 1 at 15-DEC-14
piece handle=/home/oracle/keep_test_0spq8ni4_1_1 tag=TAG20141215T212732 comment=NONE -->备份的开始时间是:20141215T212732
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:55
Finished backup at 15-DEC-14
Starting Control File and SPFILE Autobackup at 15-DEC-14
piece handle=/home/oracle/backup/control/c-275920358-20141215-00 comment=NONE
Finished Control File and SPFILE Autobackup at 15-DEC-14
RMAN>
[oracle@vm21 ~]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Mon Dec 15 21:29:56 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /home/oracle/arch
Oldest online log sequence 20
Next log sequence to archive 23
Current log sequence 23 ------------------------>此时的日志序列号是23
SQL> alter system switch logfile;
System altered.
SQL> /
System altered.
以下略去归档的切换过程