本实验对数据文件丢失,控制文件丢失,但是RMAN的备份信息和备份日志存在的时候使用。
控制文件的丢失恢复参看http://luoping.blog.51cto.com/534596/294164。
下面是数据文件的丢失的恢复。
下面是RMAN的备份脚本。
[oracle@huang ~]$ cat /tmp/11.sql
run
{
allocate channel c1 type disk;
backup database include current controlfile;
}
下面是执行RMAN备份整个数据库。
下面是查看RMAN备份的日志。
[oracle@huang ~]$ vim /tmp/111.txt
Starting backup at 12-APR-10
channel c1: starting full datafile backupset
channel c1: specifying datafile(s) in backupset
input datafile fno=00001 name=/opt/oracle/oradata/orcl/system01.dbf
input datafile fno=00003 name=/opt/oracle/oradata/orcl/sysaux01.dbf
input datafile fno=00002 name=/opt/oracle/oradata/orcl/undotbs01.dbf
input datafile fno=00004 name=/opt/oracle/oradata/orcl/users01.dbf
channel c1: starting piece 1 at 12-APR-10
channel c1: finished piece 1 at 12-APR-10
piece handle=/opt/oracle/flash_recovery_area/ORCL/backupset/2010_04_12/o1_mf_nnndf_TAG20100412T225557_5w6f3xjm_.bkp tag=TAG20100412T225557 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:55
channel c1: starting full datafile backupset
channel c1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel c1: starting piece 1 at 12-APR-10
channel c1: finished piece 1 at 12-APR-10
piece handle=/opt/oracle/flash_recovery_area/ORCL/backupset/2010_04_12/o1_mf_ncsnf_TAG20100412T225557_5w6f5pyl_.bkp tag=TAG20100412T225557 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:05
Finished backup at 12-APR-10
released channel: c1
Recovery Manager complete.
根据上面的日志来下面这个脚本。前提是要RMAN备份的日志存在或你记得自己的数据文件和编号。
[oracle@huang ~]$ cat /tmp/data.sql
DECLARE
devtype varchar2(256);
done boolean;
BEGIN
devtype:=sys.dbms_backup_restore.deviceAllocate (type=>'',ident=>'t2');
sys.dbms_backup_restore.restoreSetDatafile;
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>01,toname=>'/opt/oracle/system01.dbf');
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>02,toname=>'/opt/oracle/sysaux01.dbf');
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>03,toname=>'/opt/oracle/undotbs01.dbf');
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>04,toname=>'/opt/oracle/users01.dbf');
sys.dbms_backup_restore.restoreBackupPiece(done=>done,handle=>'/opt/oracle/flash_recovery_area/ORCL/backupset/2010_04_12/o1_mf_nnndf_TAG20100412T225557_5w6f3xjm_.bkp', params=>null);
sys.dbms_backup_restore.deviceDeallocate;
END;
SQL> get /tmp/data.sql