RMAN完全恢复丢失的数据文件(一)

2014-11-24 17:27:04 · 作者: · 浏览: 0

前提条件:


丢失前做过RMAN备份,全库的


控制文件、归档、联机日志文件完好无损


SYS@PROD>conn amy/amy


Connected.


AMY@PROD>create table t_amy02(b int);



Table created.




AMY@PROD>conn / as sysdba


Connected.


SYS@PROD>conn amy/amy


Connected.



AMY@PROD>insert into t_amy02 values(11);



1 row created.



AMY@PROD>commit;



Commit complete.



AMY@PROD>select * from t_amy02;



B


----------


11



-- 此时做rman的全库备份


-- 下面再继续插入数据



AMY@PROD>insert into t_amy02 values(12);



1 row created.



AMY@PROD>commit;



Commit complete.



AMY@PROD>select * from t_amy02;



B


----------


11


12



AMY@PROD>conn / as sysdba


Connected.


SYS@PROD>alter system switch logfile;



System altered.



SYS@PROD>conn amy/amy


Connected.


AMY@PROD>insert into t_amy02 values(13);



1 row created.



AMY@PROD>commit;



Commit complete.



AMY@PROD>select * from t_amy02;



B


----------


11


12


13



-- 以上三条记录,11在rman备份里,12在归档里,13在联机日志里



AMY@PROD>create table t_amy03(c int);


create table t_amy03(c int)


*


ERROR at line 1:


ORA-01116: error in opening database file 10


ORA-01110: data file 10: '/u01/app/oracle/oradata/PROD/disk1/tbs_amy01.dbf'


ORA-27041: unable to open file


Linux Error: 2: No such file or directory


Additional information: 3



--发现数据文件丢失后,需要做RMAN恢复


--如果不关机直接做restore会失败,报错ORA-19573,需要shutdown immediate然后再做RMAN restore and recover


RMAN> shutdown immediate



database closed


database dismounted


Oracle instance shut down



RMAN> startup mount



connected to target database (not started)


Oracle instance started


database mounted



Total System Global Area 314572800 bytes



Fixed Size 1219184 bytes


Variable Size 79693200 bytes


Database Buffers 230686720 bytes


Redo Buffers 2973696 bytes



RMAN> restore database;



Starting restore at 23-JAN-14


allocated channel: ORA_DISK_1


channel ORA_DISK_1: sid=287 devtype=DISK


allocated channel: ORA_DISK_2


channel ORA_DISK_2: sid=285 devtype=DISK



channel ORA_DISK_1: starting datafile backupset restore


channel ORA_DISK_1: specifying datafile(s) to restore from backup set


restoring datafile 00002 to /u01/app/oracle/oradata/PROD/disk1/undotbs01.dbf


restoring datafile 00004 to /u01/app/oracle/oradata/PROD/disk1/example1.dbf


restoring datafile 00007 to /u01/app/oracle/oradata/PROD/disk1/users1.dbf


restoring datafile 00008 to /u01/app/oracle/oradata/PROD/disk1/oltp1.dbf


restoring datafile 00009 to /u01/app/oracle/oradata/PROD/disk1/tbs_tommie01.dbf


channel ORA_DISK_1: reading from backup piece /home/oracle/backup/PROD_0jouptng_1_1


channel ORA_DISK_2: starting datafile backupset restore


channel ORA_DISK_2: specifying datafile(s) to restore from backup set


restoring datafile 00001 to /u01/app/oracle/oradata/PROD/disk1/system001.dbf


restoring datafile 00003 to /u01/app/oracle/oradata/PROD/disk1/sysaux01.dbf


restoring datafile 00005 to /u01/app/oracle/oradata/PROD/disk1/indx1.dbf


restoring datafile 00006 to /u01/app/oracle/oradata/PROD/disk1/tools1.dbf


restoring datafile 00010 to /u01/app/oracle/oradata/PROD/disk1/tbs_amy01.dbf


channel ORA_DISK_2: reading from backup piece /home/oracle/backup/PROD_0iouptng_1_1


channel ORA_DISK_1: restored backup piece 1


piece handle=/home/oracle/backup/PROD_0jouptng_1_1 tag=TAG20140123T142135


channel ORA_DISK_1: restore complete, elapsed time: 00:00:56


channel ORA_DISK_2: restored backup piece 1


piece handle=/home/oracle/backup/PROD_0iouptng_1_1 t