1.首先全库备份
RMAN> startup mount
connected to target database (not started)
Oracle instance started
database mounted
Total System Global Area 1653518336 bytes
Fixed Size 2253784 bytes
Variable Size 1006636072 bytes
Database Buffers 637534208 bytes
Redo Buffers 7094272 bytes
RMAN> backup database plus archivelog;
Starting backup at 15-MAR-16
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=18 device type=DISK
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=24 RECID=1 STAMP=906583293
input archived log thread=1 sequence=25 RECID=2 STAMP=906583374
input archived log thread=1 sequence=26 RECID=3 STAMP=906587333
input archived log thread=1 sequence=27 RECID=4 STAMP=906587432
channel ORA_DISK_1: starting piece 1 at 15-MAR-16
channel ORA_DISK_1: finished piece 1 at 15-MAR-16
piece handle=/u01/app/oracle/fast_recovery_area/ORCL/backupset/2016_03_15/o1_mf_annnn_TAG20160315T215123_cgj4tvdj_.bkp tag=TAG20160315T215123 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 15-MAR-16
Starting backup at 15-MAR-16
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/orcl/system01.dbf
input datafile file number=00002 name=/u01/app/oracle/oradata/orcl/sysaux01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/orcl/example01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/orcl/undotbs01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: starting piece 1 at 15-MAR-16
channel ORA_DISK_1: finished piece 1 at 15-MAR-16
piece handle=/u01/app/oracle/fast_recovery_area/ORCL/backupset/2016_03_15/o1_mf_nnndf_TAG20160315T215124_cgj4twt1_.bkp tag=TAG20160315T215124 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:26
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 15-MAR-16
channel ORA_DISK_1: finished piece 1 at 15-MAR-16
piece handle=/u01/app/oracle/fast_recovery_area/ORCL/backupset/2016_03_15/o1_mf_ncsnf_TAG20160315T215124_cgj4xonx_.bkp tag=TAG20160315T215124 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 15-MAR-16
Starting backup at 15-MAR-16
using channel ORA_DISK_1
specification does not match any archived log in the repository
backup cancelled because there are no files to backup
Finished backup at 15-MAR-16
RMAN> shutdown immediate
database dismounted
Oracle instance shut down
2.删除控制文件
[oracle@BD02 ~]$ cd /u01/app/oracle/fast_recovery_area/
[oracle@BD02 fast_recovery_area]$ ll
total 8
drwxr-x---. 2 oracle oinstall 4096 Mar 15 21:06 orcl
drwxr-x---. 5 oracle oinstall 4096 Mar 15 21:06 ORCL
[oracle@BD02 fast_recovery_area]$ cd orcl
[oracle@BD02 orcl]$ ls
control02.ctl
[oracle@BD02 orcl]$ mv control02.ctl control02.ctl.bak
[oracle@BD02 orcl]$ cd /u01/app/oracle/oradata/orcl/
[oracle@BD02 orcl]$ mv control01.ctl control01.ctl.bak
3.恢复控制文件
RMAN> restore controlfile from '/u01/app/oracle/fast_recovery_area/ORCL/backupset/2016_03_15/o1_mf_ncsnf_TAG20160315T215124_cgj4xonx_.bkp';
Starting restore at 15-MAR-16
using channel ORA_DISK_1
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/app/oracle/oradata/orcl/control01.ctl
output file name=/u01/app/oracle/fast_recovery_area/orcl/control02.ctl
Finished restore at 15-MAR-16
4.恢复数据库
RMAN> recover database;
Starting recover at 15-MAR-16
Starting implicit crosscheck backup at 15-MAR-16
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK
Crosschecked 2 objects
Finished implicit crosscheck backup at 15-MAR-16
Starting implicit crosscheck copy at 15-MAR-16
using channel ORA_DISK_1
Finished implicit crosscheck copy at 15-MAR-16
searching for all files in the recovery area
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /u01/app/oracle/fast_recovery_area/ORCL/backupset/2016_03_15/c-1434005102-20160315-01
using channel ORA_DISK_1
starting media recovery
archived log for thread 1 with sequence 1 is already on disk as file /u01/app/oracle/oradata/orcl/redo01.log
archived log file name=/u01/app/oracle/oradata/orcl/redo01.log thread=1 sequence=1
media recovery complete, elapsed time: 00:00:00
Finished recover at 15-MAR-16
5.打开数据库
这里得用resetlogs打开,不过通过重建控制文件就可以不用resetlogs了。
RMAN> alter database open resetlogs;
database opened