datagurad 使用備庫的備份恢復主庫的數據文件

一.保護現有環境:

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

業務也已恢復。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章