RMAN完全恢复丢失的数据文件
前提条件:
丢失前做过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的默认表空间TBS_AMY的数据文件'/u01/app/Oracle/oradata/PROD/disk1/tbs_amy01.dbf'
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_D