--自动备份控制文件
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP on;
--完全备份,删除过期归档
backup database plus archivelog delete input;
--4个备份集,spfile与控制文件在一个备份集中
list backupset;
[oracle@linuxoracle orcl]$ ls
arc.dbf example01.dbf redo02.log sde.dbf system01.dbf test.txt users01.dbf
control01.ctl redo01.log redo03.log sysaux01.dbf temp01.dbf undotbs01.dbf
[oracle@linuxoracle orcl]$ cp test.txt control01.ctl
--nomount状态
RMAN> startup nomount
Oracle instance started
Total System Global Area 417546240 bytes
Fixed Size 2228944 bytes
Variable Size 318770480 bytes
Database Buffers 88080384 bytes
Redo Buffers 8466432 bytes
--从自动备份中恢复控制文件
RMAN> restore controlfile from autobackup;
Starting restore at 07-NOV-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=134 device type=DISK
recovery area destination: /home/gyh/oracle/fast_recovery_area
database name (or database unique name) used for search: ORCL
channel ORA_DISK_1: AUTOBACKUP /home/gyh/oracle/fast_recovery_area/ORCL/autobackup/2012_11_07/o1_mf_s_798688228_89ncq6xr_.bkp found in the recovery area
AUTOBACKUP search with format "%F" not attempted because DBID was not set
channel ORA_DISK_1: restoring control file from AUTOBACKUP /home/gyh/oracle/fast_recovery_area/ORCL/autobackup/2012_11_07/o1_mf_s_798688228_89ncq6xr_.bkp
channel ORA_DISK_1: control file restore from AUTOBACKUP complete
output file name=/home/gyh/oracle/oradata/orcl/control01.ctl
output file name=/home/gyh/oracle/fast_recovery_area/orcl/control02.ctl
Finished restore at 07-NOV-12
--mount状态
RMAN> startup mount;
database is already started
database mounted
released channel: ORA_DISK_1
--不能打开
RMAN> alter database open;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 11/07/2012 02:01:02
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
--resetlogs模式打开
RMAN> alter database open resetlogs;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 11/07/2012 02:01:12
ORA-01194: file 1 needs more recovery to be consistent
ORA-01110: data file 1: '/home/gyh/oracle/oradata/orcl/system01.dbf'
--还原数据库
RMAN> restore database;
Starting restore at 07-NOV-12
Starting implicit crosscheck backup at 07-NOV-12
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=135 device type=DISK
Crosschecked 3 objects
Finished implicit crosscheck backup at 07-NOV-12
Starting implicit crosscheck copy at 07-NOV-12
using channel ORA_DISK_1
Finished implicit crosscheck copy at 07-NOV-12
searching for all files in the recovery area
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /home/gyh/oracle/fast_recovery_area/ORCL/autobackup/2012_11_07/o1_mf_s_798688228_89ncq6xr_.bkp
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /home/gyh/oracle/oradata/orcl/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /home/gyh/oracle/oradata/orcl/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /home/gyh/oracle/oradata/orcl/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /home/gyh/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /home/gyh/oracle/oradata/orcl/example01.dbf
channel ORA_DISK_1: restoring datafile 00006 to /home/gyh/oracle/oradata/orcl/sde.dbf
channel ORA_DISK_1: restoring datafile 00007 to /home/gyh/oracle/oradata/orcl/arc.dbf
channel ORA_DISK_1: reading from backup piece /home/gyh/oracle/fast_recovery_area/ORCL/backupset/2012_11_07/o1_mf_nnndf_TAG20121107T014751_89ncl7ol_.bkp
channel ORA_DISK_1: piece handle=/home/gyh/oracle/fast_recovery_area/ORCL/backupset/2012_11_07/o1_mf_nnndf_TAG20121107T014751_89ncl7ol_.bkp tag=TAG20121107T014751
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:02:36
Finished restore at 07-NOV-12
--恢复数据库
RMAN> recover database;
Starting recover at 07-NOV-12
using channel ORA_DISK_1
starting media recovery
archived log for thread 1 with sequence 4 is already on disk as file /home/gyh/oracle/oradata/orcl/redo01.log
archived log for thread 1 with sequence 5 is already on disk as file /home/gyh/oracle/oradata/orcl/redo02.log
archived log file name=/home/gyh/oracle/oradata/orcl/redo01.log thread=1 sequence=4
archived log file name=/home/gyh/oracle/oradata/orcl/redo02.log thread=1 sequence=5
media recovery complete, elapsed time: 00:00:03
Finished recover at 07-NOV-12
--resetlogs方式打开
RMAN> alter database open resetlogs;