oracle 主库数据文件被物理删除后可以拿dg库的数据文件去做恢复.以下是模拟试验.
一.保护现有环境:
RMAN> run {
2> allocate channel ch1 type disk format '/data/backupset/primary_%U';
3> backup database;
4> }
二.在备库上做备份:
RMAN> run {
2> allocate channel c1 device type disk format '/data/backupstd/stdbackup_%U';
3> backup database;
4> }
三.在主库模拟user表空间的数据文件损坏。
rm /u01/app/oracle/oradataorcl/orcl/users01.dbf
SQL> conn scott/tiger
SQL> select * from emp;
select * from emp
*
ERROR at line 1:
ORA-01116: error in opening database file 4
ORA-01110: data file 4: '/u01/app/oracle/oradataorcl/orcl/users01.dbf'
ORA-27041: unable to open file
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
说明故障已发生;
四.关闭实例,做介质恢复。
shutdown abort;
ORACLE instance shut down.
传递备库的备份至主库
scp /data/backupstd/* 10.10.10.222:/tmp/rmanbackup
[email protected]'s password:
stdbackup_09os7mlt_1_1 100% 1148MB 10.7MB/s 01:47
stdbackup_0aos7mn0_1_1 100% 9632KB 9.4MB/s 00:01
改变之前的备库目录使rman 不能用之前的备份区恢复
mv backupset/ backupset1
rman target /
restore tablespace users;
.............
RMAN-06026: some targets not found - aborting restore
RMAN-06023: no backup or copy of datafile 4 found to restore
说明没有可用的备份;
使用备库的备份文件去恢复;
五.恢复数据文件使用备库的备份;
注册之前传过来的备份片;
RMAN> catalog start with '/tmp/rmanbackup'
RMAN> restore tablespace users;
........
channel ORA_DISK_1: piece handle=/tmp/rmanbackup/stdbackup_09os7mlt_1_1 tag=TAG20131223T095821
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 23-DEC-13
RMAN> recover tablespace users;
Starting recover at 23-DEC-13
using channel ORA_DISK_1
starting media recovery
archived log for thread 1 with sequence 40 is already on disk as file /data/logarchive01/1_40_834606638.arc
media recovery complete, elapsed time: 00:00:01
Finished recover at 23-DEC-13
打开数据库
RMAN> sql 'alter database open';
sql statement: alter database open
此时数据库已恢复;
SQL> select * from emp;
EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7369 SMITH CLERK 7902 17-DEC-80 800
业务也已恢复。