查看时候启动了control file autobackup:
RMAN> show all ;
RMAN configuration parameters for database with db_unique_name ORCL are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/backup/%F';
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1;
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1;
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/opt/oracle/product/OraHome/dbs/snapcf_orcl.f'; # default
启动数据库到nomount模式并备份数据库:
SYS@orcl>startup nomount;
ORACLE instance started.
Total System Global Area 413372416 bytes
Fixed Size 2253784 bytes
Variable Size 327158824 bytes
Database Buffers 79691776 bytes
Redo Buffers 4268032 bytes
SYS@orcl>alter database noarchivelog;
RMAN> backup database;
Starting backup at 25-JUL-14
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 device type=DISK
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=/opt/oracle/oradata/orcl/system01.dbf
input datafile file number=00002 name=/opt/oracle/oradata/orcl/sysaux01.dbf
input datafile file number=00003 name=/opt/oracle/oradata/orcl/undotbs01.dbf
input datafile file number=00005 name=/opt/oracle/oradata/orcl/storedata_01.dbf
input datafile file number=00006 name=/opt/oracle/oradata/orcl/storedata_02.dbf
input datafile file number=00007 name=/opt/oracle/oradata/orcl/users02.dbf
input datafile file number=00004 name=/opt/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: starting piece 1 at 25-JUL-14
channel ORA_DISK_1: finished piece 1 at 25-JUL-14
piece handle=/opt/flashback/ORCL/backupset/2014_07_25/o1_mf_nnndf_TAG20140725T141535_9x3xj7kj_.bkp tag=TAG20140725T141535 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:15
Finished backup at 25-JUL-14
Starting Control File and SPFILE Autobackup at 25-JUL-14
piece handle=/backup/c-1375895844-20140725-01 comment=NONE
Finished Control File and SPFILE Autobackup at 25-JUL-14
关闭数据库并删除控制文件,联机重做日志文件,数据文件(模拟删除将所有文件移动到/home/123)
SYS@orcl>shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
[root@Lee 2014_07_25]# cd /opt/oracle/oradata/orcl/
[root@Lee orcl]# ls
archive1 control02.ctl redo03.log sysaux01.dbf undotbs01.dbf
archive2 redo01.log storedata_01.dbf system01.dbf users01.dbf
control01.ctl redo02.log storedata_02.dbf temp01.dbf users02.dbf
[root@Lee orcl]# mv *.* /home/123/
将数据库启动到nomount状态恢复控制文件
SYS@orcl>startup nomount;
ORACLE instance started.
Total System Global Area 413372416 bytes
Fixed Size 2253784 bytes
Variable Size 327158824 bytes
Database Buffers 79691776 bytes
Redo Buffers 4268032 bytes
RMAN> restore controlfile from '/backup/c-1375895844-20140725-01'; (这个就是我们上边存放控制文件自动备份的位置)
Starting restore at 25-JUL-14
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=/opt/oracle/oradata/orcl/control01.ctl
output file name=/opt/oracle/oradata/orcl/control02.ctl
Finished restore at 25-JUL-14
控制文件还原回来
[root@Lee backup]# cd /opt/oracle/oradata/orcl/
[root@Lee orcl]# ls
archive1 archive2 control01.ctl control02.ctl
将数据库启动到mount状态还原数据文件:
SYS@orcl>alter database mount;
Database altered.
RMAN> restore database;
Starting restore at 25-JUL-14
released channel: ORA_DISK_1
Starting implicit crosscheck backup at 25-JUL-14
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 device type=DISK
Crosschecked 4 objects
Finished implicit crosscheck backup at 25-JUL-14
Starting implicit crosscheck copy at 25-JUL-14
using channel ORA_DISK_1
Crosschecked 4 objects
Finished implicit crosscheck copy at 25-JUL-14
searching for all files in the recovery area
cataloging files...
no files cataloged
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 /opt/oracle/oradata/orcl/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /opt/oracle/oradata/orcl/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /opt/oracle/oradata/orcl/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /opt/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /opt/oracle/oradata/orcl/storedata_01.dbf
channel ORA_DISK_1: restoring datafile 00006 to /opt/oracle/oradata/orcl/storedata_02.dbf
channel ORA_DISK_1: restoring datafile 00007 to /opt/oracle/oradata/orcl/users02.dbf
channel ORA_DISK_1: reading from backup piece /opt/flashback/ORCL/backupset/2014_07_25/o1_mf_nnndf_TAG20140725T141535_9x3xj7kj_.bkp
channel ORA_DISK_1: piece handle=/opt/flashback/ORCL/backupset/2014_07_25/o1_mf_nnndf_TAG20140725T141535_9x3xj7kj_.bkp tag=TAG20140725T141535
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:55
Finished restore at 25-JUL-14
恢复数据库并打开:
RMAN> recover database;
Starting recover at 25-JUL-14
using channel ORA_DISK_1
starting media recovery
RMAN-08187: WARNING: media recovery until SCN 2218664 complete
Finished recover at 25-JUL-14
RMAN> sql 'alter database open resetlogs';
sql statement: alter database open resetlogs