有整庫備份的情況rman恢復全庫

kngnng發表於2013-03-04

說明

         在利用RMAN備份了整個資料庫後,我們恢復資料庫到備份的狀態,利用之前的全備恢復,需要以下一系列操作。

 

資料庫恢復

1.      備份全庫

RMAN> list backup;

 

using target database control file instead of recovery catalog

 

RMAN> list backup;

 

 

RMAN> backup database;

 

Starting backup at 04-MAR-13

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=529 devtype=DISK

channel ORA_DISK_1: starting full datafile backupset

channel ORA_DISK_1: specifying datafile(s) in backupset

input datafile fno=00001 name=/oracle/u01/app/oracle/oradata/orcl/system01.dbf

input datafile fno=00003 name=/oracle/u01/app/oracle/oradata/orcl/sysaux01.dbf

input datafile fno=00005 name=/oracle/u01/app/oracle/oradata/orcl/admin01.dbf

input datafile fno=00002 name=/oracle/u01/app/oracle/oradata/orcl/undotbs01.dbf

input datafile fno=00004 name=/oracle/u01/app/oracle/oradata/orcl/users01.dbf

input datafile fno=00006 name=/oracle/u01/app/oracle/oradata/orcl/users02.dbf

channel ORA_DISK_1: starting piece 1 at 04-MAR-13

channel ORA_DISK_1: finished piece 1 at 04-MAR-13

piece handle=/oracle/u01/app/oracle/flash_recovery_area/ORCL/backupset/2013_03_04/o1_mf_nnndf_TAG20130304T165311_8m8r7r82_.bkp tag=TAG20130304T165311 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45

Finished backup at 04-MAR-13

 

Starting Control File and SPFILE Autobackup at 04-MAR-13

piece handle=/oracle/u01/app/oracle/backup/c-1324770912-20130304-0d comment=NONE

Finished Control File and SPFILE Autobackup at 04-MAR-13

備份過程如果沒有設定備份路徑會自動備份到rman預設路徑,通過show all,也可以檢查引數更改備份路徑

 

2.      檢查備份

RMAN> list backup;

 

 

List of Backup Sets

===================

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time

------- ---- -- ---------- ----------- ------------ ---------------

140     Full    963.54M    DISK        00:00:42     04-MAR-13     

        BP Key: 144   Status: AVAILABLE  Compressed: NO  Tag: TAG20130304T165311

        Piece Name: /oracle/u01/app/oracle/flash_recovery_area/ORCL/backupset/2013_03_04/o1_mf_nnndf_TAG20130304T165311_8m8r7r82_.bkp

  List of Datafiles in backup set 140

  File LV Type Ckp SCN    Ckp Time  Name

  ---- -- ---- ---------- --------- ----

  1       Full 5925951    04-MAR-13 /oracle/u01/app/oracle/oradata/orcl/system01.dbf

  2       Full 5925951    04-MAR-13 /oracle/u01/app/oracle/oradata/orcl/undotbs01.dbf

  3       Full 5925951    04-MAR-13 /oracle/u01/app/oracle/oradata/orcl/sysaux01.dbf

  4       Full 5925951    04-MAR-13 /oracle/u01/app/oracle/oradata/orcl/users01.dbf

  5       Full 5925951    04-MAR-13 /oracle/u01/app/oracle/oradata/orcl/admin01.dbf

  6       Full 5925951    04-MAR-13 /oracle/u01/app/oracle/oradata/orcl/users02.dbf

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time

------- ---- -- ---------- ----------- ------------ ---------------

141     Full    7.52M      DISK        00:00:00     04-MAR-13     

        BP Key: 145   Status: AVAILABLE  Compressed: NO  Tag: TAG20130304T165357

        Piece Name: /oracle/u01/app/oracle/backup/c-1324770912-20130304-0d

  Control File Included: Ckp SCN: 5925970      Ckp time: 04-MAR-13

  SPFILE Included: Modification time: 04-MAR-13

通過檢查,已經備份成功,備份集號為141

 

3.      停庫

SQL> shutdown abort;

ORACLE instance shut down.

此時不用一致性停庫也行,因為模擬實驗,將要刪除整個資料庫檔案。

 

4.      刪除原庫

[oracle@dev206 oracle]$ rm -rf /oracle/u01/app/oracle/oradata/orcl/*

 

5.      測試啟動

SQL> startup

ORA-32004: obsolete and/or deprecated parameter(s) specified

ORACLE instance started.

 

Total System Global Area 1224736768 bytes

Fixed Size                  2020384 bytes

Variable Size             352324576 bytes

Database Buffers          855638016 bytes

Redo Buffers               14753792 bytes

ORA-00205: error in identifying control file, check alert log for more info

此時資料庫已經不能啟動,在啟動到nomount過程中報205錯誤,找不到控制檔案。

 

6.      進入RMAN恢復控制檔案

[oracle@dev206 ~]$ rman target /

RMAN> restore controlfile from '/oracle/u01/app/oracle/backup/c-1324770912-20130304-0d';

 

Starting restore at 04-MAR-13

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=540 devtype=DISK

 

channel ORA_DISK_1: restoring control file

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

output filename=/oracle/u01/app/oracle/oradata/orcl/control01.ctl

output filename=/oracle/u01/app/oracle/oradata/orcl/control02.ctl

output filename=/oracle/u01/app/oracle/oradata/orcl/control03.ctl

Finished restore at 04-MAR-13

檢驗/oracle/u01/app/oracle/oradata/orcl路徑下已經恢復控制檔案。

 

7.      此時資料庫可以mount

RMAN> alter database mount;

 

database mounted

released channel: ORA_DISK_1

 

8.      恢復資料檔案

RMAN> restore database;

 

Starting restore at 04-MAR-13

Starting implicit crosscheck backup at 04-MAR-13

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=540 devtype=DISK

Crosschecked 1 objects

Finished implicit crosscheck backup at 04-MAR-13

 

Starting implicit crosscheck copy at 04-MAR-13

using channel ORA_DISK_1

Crosschecked 4 objects

Finished implicit crosscheck copy at 04-MAR-13

 

searching for all files in the recovery area

cataloging files...

cataloging done

 

List of Cataloged Files

=======================

File Name: /oracle/u01/app/oracle/flash_recovery_area/ORCL/backupset/2013_03_04/o1_mf_ncnnf_TAG20130304T143106_8m8hxc3s_.bkp

 

using channel ORA_DISK_1

 

channel ORA_DISK_1: starting datafile backupset restore

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

restoring datafile 00001 to /oracle/u01/app/oracle/oradata/orcl/system01.dbf

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

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

restoring datafile 00004 to /oracle/u01/app/oracle/oradata/orcl/users01.dbf

restoring datafile 00005 to /oracle/u01/app/oracle/oradata/orcl/admin01.dbf

restoring datafile 00006 to /oracle/u01/app/oracle/oradata/orcl/users02.dbf

channel ORA_DISK_1: reading from backup piece /oracle/u01/app/oracle/flash_recovery_area/ORCL/backupset/2013_03_04/o1_mf_nnndf_TAG20130304T165311_8m8r7r82_.bkp

channel ORA_DISK_1: restored backup piece 1

piece handle=/oracle/u01/app/oracle/flash_recovery_area/ORCL/backupset/2013_03_04/o1_mf_nnndf_TAG20130304T165311_8m8r7r82_.bkp tag=TAG20130304T165311

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

Finished restore at 04-MAR-13

檢驗/oracle/u01/app/oracle/oradata/orcl路徑下已經恢復資料檔案。

 

9.      開啟資料庫

RMAN> alter database open resetlogs;

 

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03002: failure of alter db command at 03/04/2013 17:05:30

ORA-01152: file 1 was not restored from a sufficiently old backup

ORA-01110: data file 1: '/oracle/u01/app/oracle/oradata/orcl/system01.dbf'

因為我們只是在物理層恢復了資料檔案,還需要在邏輯上恢復資料庫。

 

 

10.              恢復資料庫

RMAN> recover database;

 

Starting recover at 04-MAR-13

using channel ORA_DISK_1

 

starting media recovery

 

unable to find archive log

archive log thread=1 sequence=3

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03002: failure of recover command at 03/04/2013 17:06:34

RMAN-06054: media recovery requesting unknown log: thread 1 seq 3 lowscn 5925

報錯是因為找不到到日誌檔案,繼續下一步。

 

11.              重做日誌檔案開啟資料庫

RMAN> alter database open resetlogs;

 

database opened

檢驗/oracle/u01/app/oracle/oradata/orcl路徑下已經恢復了日誌檔案

此時資料庫已經啟動完成。

 

12.              重啟資料庫

SQL>startup force

 

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26252014/viewspace-755277/,如需轉載,請註明出處,否則將追究法律責任。

相關文章