Oracle Rman 資料庫的不完全恢復

feelpurple發表於2016-01-19
前提條件:

1、資料庫執行在歸檔模式;
2、必須有要恢復時間點前的所有資料檔案備份和在恢復時間點和資料檔案備份時刻之間的所有歸檔日誌。

下面的恢復假設如下條件:

1、恢復使用當前的 incarnation;
2、使用當前的控制檔案;
3、使用當前的引數檔案。

--決定恢復的 SCN
選擇恢復到第5個 RECID 的結束 SCN (849702)

SQL> SELECT RECID, STAMP, THREAD#, SEQUENCE#, FIRST_CHANGE#
       FIRST_TIME, NEXT_CHANGE#
FROM   V$ARCHIVED_LOG
WHERE  RESETLOGS_CHANGE# =
       ( SELECT RESETLOGS_CHANGE#
         FROM   V$DATABASE_INCARNATION
         WHERE  STATUS = 'CURRENT');

     RECID      STAMP    THREAD#  SEQUENCE# FIRST_TIME NEXT_CHANGE#
---------- ---------- ---------- ---------- ---------- ------------
         1  901491788          1          5     821736       846174
         2  901492103          1          6     846174       846670
         3  901492215          1          7     846670       846723
         4  901495908          1          8     846723       849501
         5  901495932          1          9     849501       849702
         6  901495947          1         10     849702       850650
         7  901496002          1         11     850650       850945
         8  901496122          1         12     850945       851004

--可以設定 RMAN 的時間格式,也可以將其寫在 .bash_profile 中

[oracle@localhost ~]$ export NLS_DATE_FORMAT="YYYY/MM/DD HH24:MI:SS"

--關閉資料庫,並啟動到 MOUNT 狀態

RMAN> SHUTDOWN IMMEDIATE;

using target database control file instead of recovery catalog
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     318046208 bytes

Fixed Size                     1336260 bytes
Variable Size                125832252 bytes
Database Buffers             184549376 bytes
Redo Buffers                   6328320 bytes

--執行不完全恢復

RMAN> RUN

  SET UNTIL SCN 849702;    
  RESTORE DATABASE;
  RECOVER DATABASE;
}2> 3> 4> 5> 6> 


executing command: SET until clause


Starting restore at 2016/01/19 05:41:16
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=18 device type=DISK

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /ORADATA/neo/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /ORADATA/neo/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /ORADATA/neo/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /ORADATA/neo/users01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /ORADATA/neo/example01.dbf
channel ORA_DISK_1: restoring datafile 00006 to /ORADATA/neo/users02.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/flash_recovery_area/NEO/backupset/2016_01_18/o1_mf_nnndf_TAG20160118T222831_c9sxnl4j_.bkp
channel ORA_DISK_1: piece handle=/u01/app/oracle/flash_recovery_area/NEO/backupset/2016_01_18/o1_mf_nnndf_TAG20160118T222831_c9sxnl4j_.bkp tag=TAG20160118T222831
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:01:25
Finished restore at 2016/01/19 05:42:42

Starting recover at 2016/01/19 05:42:42
using channel ORA_DISK_1

starting media recovery

channel ORA_DISK_1: starting archived log restore to default destination
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=7
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/flash_recovery_area/NEO/backupset/2016_01_18/o1_mf_annnn_TAG20160118T223015_c9sxqq4f_.bkp
channel ORA_DISK_1: piece handle=/u01/app/oracle/flash_recovery_area/NEO/backupset/2016_01_18/o1_mf_annnn_TAG20160118T223015_c9sxqq4f_.bkp tag=TAG20160118T223015
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
archived log file name=/u01/app/oracle/flash_recovery_area/NEO/archivelog/2016_01_19/o1_mf_1_7_c9tq2ocb_.arc thread=1 sequence=7
channel default: deleting archived log(s)
archived log file name=/u01/app/oracle/flash_recovery_area/NEO/archivelog/2016_01_19/o1_mf_1_7_c9tq2ocb_.arc RECID=9 STAMP=901518165
channel ORA_DISK_1: starting archived log restore to default destination
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=8
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=9
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/flash_recovery_area/NEO/backupset/2016_01_18/o1_mf_annnn_TAG20160118T233324_c9t1g580_.bkp
channel ORA_DISK_1: piece handle=/u01/app/oracle/flash_recovery_area/NEO/backupset/2016_01_18/o1_mf_annnn_TAG20160118T233324_c9t1g580_.bkp tag=TAG20160118T233324
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:15
archived log file name=/u01/app/oracle/flash_recovery_area/NEO/archivelog/2016_01_19/o1_mf_1_8_c9tq2pno_.arc thread=1 sequence=8
channel default: deleting archived log(s)
archived log file name=/u01/app/oracle/flash_recovery_area/NEO/archivelog/2016_01_19/o1_mf_1_8_c9tq2pno_.arc RECID=10 STAMP=901518173
archived log file name=/u01/app/oracle/flash_recovery_area/NEO/archivelog/2016_01_19/o1_mf_1_9_c9tq2po8_.arc thread=1 sequence=9
channel default: deleting archived log(s)
archived log file name=/u01/app/oracle/flash_recovery_area/NEO/archivelog/2016_01_19/o1_mf_1_9_c9tq2po8_.arc RECID=11 STAMP=901518173
media recovery complete, elapsed time: 00:00:18
Finished recover at 2016/01/19 05:43:19

--開啟資料庫

RMAN> ALTER DATABASE OPEN RESETLOGS;

database opened

--下面是後臺告警日誌中的內容

Tue Jan 19 05:41:19 2016
Full restore complete of datafile 6 /ORADATA/neo/users02.dbf.  Elapsed time: 0:00:00 
  checkpoint is 846683
Full restore complete of datafile 4 /ORADATA/neo/users01.dbf.  Elapsed time: 0:00:02 
  checkpoint is 846683
Tue Jan 19 05:41:37 2016
Full restore complete of datafile 5 /ORADATA/neo/example01.dbf.  Elapsed time: 0:00:15 
  checkpoint is 846683
  last deallocation scn is 775082
Full restore complete of datafile 3 /ORADATA/neo/undotbs01.dbf.  Elapsed time: 0:00:20 
  checkpoint is 846683
  last deallocation scn is 789640
Tue Jan 19 05:42:22 2016
Full restore complete of datafile 2 /ORADATA/neo/sysaux01.dbf.  Elapsed time: 0:01:01 
  checkpoint is 846683
  last deallocation scn is 825117
Tue Jan 19 05:42:33 2016
Full restore complete of datafile 1 /ORADATA/neo/system01.dbf.  Elapsed time: 0:01:12 
  checkpoint is 846683
  last deallocation scn is 824418
Tue Jan 19 05:42:43 2016
alter database recover datafile list clear
Completed: alter database recover datafile list clear
alter database recover datafile list
 1 , 2 , 3 , 4 , 5 , 6
Completed: alter database recover datafile list
 1 , 2 , 3 , 4 , 5 , 6
alter database recover if needed
 start until change 849702
Media Recovery Start
Serial Media Recovery started
ORA-279 signalled during: alter database recover if needed
 start until change 849702
...
alter database recover logfile '/u01/app/oracle/flash_recovery_area/NEO/archivelog/2016_01_19/o1_mf_1_7_c9tq2ocb_.arc'
Media Recovery Log /u01/app/oracle/flash_recovery_area/NEO/archivelog/2016_01_19/o1_mf_1_7_c9tq2ocb_.arc
ORA-279 signalled during: alter database recover logfile '/u01/app/oracle/flash_recovery_area/NEO/archivelog/2016_01_19/o1_mf_1_7_c9tq2ocb_.arc'...
Tue Jan 19 05:43:01 2016
alter database recover logfile '/u01/app/oracle/flash_recovery_area/NEO/archivelog/2016_01_19/o1_mf_1_8_c9tq2pno_.arc'
Media Recovery Log /u01/app/oracle/flash_recovery_area/NEO/archivelog/2016_01_19/o1_mf_1_8_c9tq2pno_.arc
Tue Jan 19 05:43:12 2016
ORA-279 signalled during: alter database recover logfile '/u01/app/oracle/flash_recovery_area/NEO/archivelog/2016_01_19/o1_mf_1_8_c9tq2pno_.arc'...
lash_recovery_area/NEO/archivelog/2016_01_19/o1_mf_1_8_c9tq2pno_.arc'...
alter database recover logfile '/u01/app/oracle/flash_recovery_area/NEO/archivelog/2016_01_19/o1_mf_1_9_c9tq2po8_.arc'
Media Recovery Log /u01/app/oracle/flash_recovery_area/NEO/archivelog/2016_01_19/o1_mf_1_9_c9tq2po8_.arc
Incomplete Recovery applied until change 849702 time 01/18/2016 23:32:08
Media Recovery Complete (neo)
Completed: alter database recover logfile '/u01/app/oracle/flash_recovery_area/NEO/archivelog/2016_01_19/o1_mf_1_9_c9tq2po8_.arc'
Tue Jan 19 05:46:14 2016
alter database open resetlogs
Archived Log entry 12 added for thread 1 sequence 13 ID 0x765bad34 dest 1:
RESETLOGS after incomplete recovery UNTIL CHANGE 849702
Resetting resetlogs activation ID 1985719604 (0x765bad34)
Errors in file /u01/app/oracle/diag/rdbms/neo/neo/trace/neo_ora_29148.trc:
ORA-00367: checksum error in log file header
ORA-00322: log 1 of thread 1 is not current copy
ORA-00312: online log 1 thread 1: '/ORADATA/neo/redo01.log'
Tue Jan 19 05:46:18 2016
Errors in file /u01/app/oracle/diag/rdbms/neo/neo/trace/neo_m000_29872.trc:
ORA-00316: log 1 of thread 1, type 0 in header is not log file
ORA-00312: online log 1 thread 1: '/ORADATA/neo/redo01.log'
Errors in file /u01/app/oracle/diag/rdbms/neo/neo/trace/neo_ora_29148.trc:
ORA-00367: checksum error in log file header
ORA-00322: log 2 of thread 1 is not current copy
ORA-00312: online log 2 thread 1: '/ORADATA/neo/redo02.log'
Errors in file /u01/app/oracle/diag/rdbms/neo/neo/trace/neo_ora_29148.trc:
ORA-00367: checksum error in log file header
ORA-00322: log 3 of thread 1 is not current copy
ORA-00312: online log 3 thread 1: '/ORADATA/neo/redo03.log'
Errors in file /u01/app/oracle/diag/rdbms/neo/neo/trace/neo_m000_29872.trc:
ORA-00316: log 2 of thread 1, type 0 in header is not log file
ORA-00312: online log 2 thread 1: '/ORADATA/neo/redo02.log'
Tue Jan 19 05:46:23 2016
Setting recovery target incarnation to 3
Checker run found 4 new persistent data failures


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

相關文章