恢復測試:擁有當時的全部歸檔,控制檔案,恢復丟失的資料檔案。

oracle_ace發表於2007-12-27

測試如下:

SQL> archive log list
資料庫日誌模式            存檔模式
自動存檔             啟用
存檔終點            D:\oracle\archived_dest
最早的概要日誌序列     0
下一個存檔日誌序列   1
當前日誌序列           1

SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
D:\ORACLE\ORADATA\ICMNLSDB\SYSTEM01.DBF
D:\ORACLE\ORADATA\ICMNLSDB\UNDOTBS01.DBF
D:\ORACLE\ORADATA\ICMNLSDB\INDX01.DBF
D:\ORACLE\ORADATA\ICMNLSDB\TOOLS01.DBF
D:\ORACLE\ORADATA\ICMNLSDB\USERS01.DBF
D:\ORACLE\ORADATA\ICMNLSDB\ALAN01.DBF
D:\ORACLE\ORADATA\ICMNLSDB\MY_BLOCK.DBF
D:\ORACLE\ORADATA\ICMNLSDB\MY_BLOCK02.DBF

已選擇8行。

SQL> create tablespace mytest datafile 'D:\ORACLE\ORADATA\ICMNLSDB\test01.dbf' size 5m;

表空間已建立。

SQL> alter system switch logfile;

系統已更改。

SQL> create table my_t tablespace mytest as select * from dba_users;

表已建立。

SQL> alter system switch logfile;

系統已更改。

SQL> shutdown abort;
ORACLE 例程已經關閉。
SQL> exit

---將我們新建立的TEST01.DBF檔案改名,來模擬檔案丟失

之後........
D:\oracle\oradata\icmnlsdb>sqlplus /nolog

SQL*Plus: Release 9.2.0.8.0 - Production on 星期四 12月 27 13:33:35 2007

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.

SQL> conn / as sysdba;
已連線到空閒例程。
SQL> startup
ORACLE 例程已經啟動。

Total System Global Area  118562308 bytes
Fixed Size                   454148 bytes
Variable Size              75497472 bytes
Database Buffers           41943040 bytes
Redo Buffers                 667648 bytes
資料庫裝載完畢。
ORA-01157: 無法標識/鎖定資料檔案 9 - 請參閱 DBWR 跟蹤檔案
ORA-01110: 資料檔案 9: 'D:\ORACLE\ORADATA\ICMNLSDB\TEST01.DBF'

SQL> select name from v$datafile;

NAME
--------------------------------------------
D:\ORACLE\ORADATA\ICMNLSDB\SYSTEM01.DBF
D:\ORACLE\ORADATA\ICMNLSDB\UNDOTBS01.DBF
D:\ORACLE\ORADATA\ICMNLSDB\INDX01.DBF
D:\ORACLE\ORADATA\ICMNLSDB\TOOLS01.DBF
D:\ORACLE\ORADATA\ICMNLSDB\USERS01.DBF
D:\ORACLE\ORADATA\ICMNLSDB\ALAN01.DBF
D:\ORACLE\ORADATA\ICMNLSDB\MY_BLOCK.DBF
D:\ORACLE\ORADATA\ICMNLSDB\MY_BLOCK02.DBF
D:\ORACLE\ORADATA\ICMNLSDB\TEST01.DBF

已選擇9行。

SQL> alter database create datafile 'D:\ORACLE\ORADATA\ICMNLSDB\TEST01.DBF';

資料庫已更改。

SQL> select status from v$instance;

STATUS
------------
MOUNTED

SQL> recover datafile 'D:\ORACLE\ORADATA\ICMNLSDB\TEST01.DBF';
完成介質恢復。

SQL> alter database open;

資料庫已更改。

分析:
此次測試的過程,因為有當前的控制檔案,而且控制檔案中包含了所丟失的額外資料檔案資訊test01.dbf,所以可以通過alter database create datafile ''PATH" 方式重新建立資料檔案,同時我們還可以通過控制檔案中記錄的資料檔案資訊、SCN、checkpoint檢查點等資訊,應用歸檔日誌進行恢復,因此可以全部完成完全恢復.

擷取四段的file hdrs的資訊,供參考(大家可以注意一下標記的字型資訊):

檔案改名前的狀態資訊
-----------------------------
DATA FILE #9:
  (name #13) D:\ORACLE\ORADATA\ICMNLSDB\TEST01.DBF
creation size=640 block size=8192 status=0xe head=13 tail=13 dup=1
 tablespace 8, index=9 krfil=9 prev_file=0
 unrecoverable scn: 0x0000.00000000 01/01/1988 00:00:00
 Checkpoint cnt:5 scn: 0x0000.000299f7 12/27/2007 13:56:32
 Stop scn: 0xffff.ffffffff 12/27/2007 13:54:53
 Creation Checkpointed at scn:  0x0000.00024ba6 12/27/2007 13:54:24
 thread:1 rba:(0x1.3d5.10)
 enabled  threads:  01000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000
 Offline scn: 0x0000.00000000 prev_range: 0
 Online Checkpointed at scn:  0x0000.00000000
 thread:0 rba:(0x0.0.0)
 enabled  threads:  00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000
 Hot Backup end marker scn: 0x0000.00000000
 aux_file is NOT DEFINED
 FILE HEADER:
 Software vsn=153092096=0x9200000, Compatibility Vsn=134217728=0x8000000
 Db ID=862305779=0x3365bdf3, Db Name='ICMNLSDB'
 Activation ID=0=0x0
 Control Seq=229=0xe5, File size=640=0x280
 File Number=9, Blksiz=8192, File Type=3 DATA
Tablespace #8 - TEST  rel_fn:9
Creation   at   scn: 0x0000.00024ba6 12/27/2007 13:54:24
Backup taken at scn: 0x0000.00000000 01/01/1988 00:00:00 thread:0
 reset logs count:0x2649a79a scn: 0x0000.0001edd2 recovered at 12/27/2007 13:56:29
 status:0x4 root dba:0x00000000 chkpt cnt: 5 ctl cnt:4
begin-hot-backup file size: 0
Checkpointed at scn:  0x0000.000299f7 12/27/2007 13:56:32
 thread:1 rba:(0x4.2.10)
 enabled  threads:  01000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000
Backup Checkpointed at scn:  0x0000.00000000
 thread:0 rba:(0x0.0.0)
 enabled  threads:  00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000
External cache id: 0x0 0x0 0x0 0x0
Absolute fuzzy scn: 0x0000.00000000
Recovery fuzzy scn: 0x0000.00000000 01/01/1988 00:00:00
Terminal Recovery Stamp scn: 0x0000.00000000 01/01/1988 00:00:00
DUMP OF TEMP FILES: 1 files in database

檔案改名後,資料處於mounted狀態的資訊
---------------------------------------------------------
DATA FILE #9:
  (name #13) D:\ORACLE\ORADATA\ICMNLSDB\TEST01.DBF
creation size=640 block size=8192 status=0xe head=13 tail=13 dup=1
 tablespace 8, index=9 krfil=9 prev_file=0
 unrecoverable scn: 0x0000.00000000 01/01/1988 00:00:00
 Checkpoint cnt:6 scn: 0x0000.00029a91 12/27/2007 13:58:03
 Stop scn: 0x0000.00029a91 12/27/2007 13:58:03
 Creation Checkpointed at scn:  0x0000.00024ba6 12/27/2007 13:54:24
 thread:1 rba:(0x1.3d5.10)
 enabled  threads:  01000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000
 Offline scn: 0x0000.00000000 prev_range: 0
 Online Checkpointed at scn:  0x0000.00000000
 thread:0 rba:(0x0.0.0)
 enabled  threads:  00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000
 Hot Backup end marker scn: 0x0000.00000000
 aux_file is NOT DEFINED
ORA-01157: 無法標識/鎖定資料檔案 9 - 請參閱 DBWR 跟蹤檔案
ORA-01110: 資料檔案 9: 'D:\ORACLE\ORADATA\ICMNLSDB\TEST01.DBF'
*** Error 1157 in open/read file # 9 ***
DUMP OF TEMP FILES: 1 files in database

檔案重新通過create datafile重建過後的資訊
----------------------------------------------------------
DATA FILE #9:
  (name #13) D:\ORACLE\ORADATA\ICMNLSDB\TEST01.DBF
creation size=640 block size=8192 status=0xe head=13 tail=13 dup=1
 tablespace 8, index=9 krfil=9 prev_file=0
 unrecoverable scn: 0x0000.00000000 01/01/1988 00:00:00
 Checkpoint cnt:6 scn: 0x0000.00029a91 12/27/2007 13:58:03
 Stop scn: 0x0000.00029a91 12/27/2007 13:58:03
 Creation Checkpointed at scn:  0x0000.00024ba6 12/27/2007 13:54:24
 thread:1 rba:(0x1.3d5.10)
 enabled  threads:  01000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000
 Offline scn: 0x0000.00000000 prev_range: 0
 Online Checkpointed at scn:  0x0000.00000000
 thread:0 rba:(0x0.0.0)
 enabled  threads:  00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000
 Hot Backup end marker scn: 0x0000.00000000
 aux_file is NOT DEFINED
 FILE HEADER:
 Software vsn=153092096=0x9200000, Compatibility Vsn=134217728=0x8000000
 Db ID=862305779=0x3365bdf3, Db Name='ICMNLSDB'
 Activation ID=0=0x0
 Control Seq=233=0xe9, File size=640=0x280
 File Number=9, Blksiz=8192, File Type=3 DATA
Tablespace #8 - TEST  rel_fn:9
Creation   at   scn: 0x0000.00024ba6 12/27/2007 13:54:24
Backup taken at scn: 0x0000.00000000 01/01/1988 00:00:00 thread:0
 reset logs count:0x2649a79a scn: 0x0000.0001edd2 recovered at 01/01/1988 00:00:00
 status:0x0 root dba:0x004001a1 chkpt cnt: 1 ctl cnt:1
begin-hot-backup file size: 0
Checkpointed at scn:  0x0000.00024ba6 12/27/2007 13:54:24
 thread:1 rba:(0x1.3d5.10)
 enabled  threads:  01000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000
Backup Checkpointed at scn:  0x0000.00000000
 thread:0 rba:(0x0.0.0)
 enabled  threads:  00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000
External cache id: 0x0 0x0 0x0 0x0
Absolute fuzzy scn: 0x0000.00000000
Recovery fuzzy scn: 0x0000.00000000 01/01/1988 00:00:00
Terminal Recovery Stamp scn: 0x0000.00000000 01/01/1988 00:00:00
DUMP OF TEMP FILES: 1 files in database

完全介質恢復後的資訊
------------------------------
DATA FILE #9:
  (name #13) D:\ORACLE\ORADATA\ICMNLSDB\TEST01.DBF
creation size=640 block size=8192 status=0xe head=13 tail=13 dup=1
 tablespace 8, index=9 krfil=9 prev_file=0
 unrecoverable scn: 0x0000.00000000 01/01/1988 00:00:00
 Checkpoint cnt:8 scn: 0x0000.00029a92 12/27/2007 14:01:09
 Stop scn: 0xffff.ffffffff 12/27/2007 13:58:03
 Creation Checkpointed at scn:  0x0000.00024ba6 12/27/2007 13:54:24
 thread:1 rba:(0x1.3d5.10)
 enabled  threads:  01000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000
 Offline scn: 0x0000.00000000 prev_range: 0
 Online Checkpointed at scn:  0x0000.00000000
 thread:0 rba:(0x0.0.0)
 enabled  threads:  00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000
 Hot Backup end marker scn: 0x0000.00000000
 aux_file is NOT DEFINED
 FILE HEADER:
 Software vsn=153092096=0x9200000, Compatibility Vsn=134217728=0x8000000
 Db ID=862305779=0x3365bdf3, Db Name='ICMNLSDB'
 Activation ID=0=0x0
 Control Seq=238=0xee, File size=640=0x280
 File Number=9, Blksiz=8192, File Type=3 DATA
Tablespace #8 - TEST  rel_fn:9
Creation   at   scn: 0x0000.00024ba6 12/27/2007 13:54:24
Backup taken at scn: 0x0000.00000000 01/01/1988 00:00:00 thread:0
 reset logs count:0x2649a79a scn: 0x0000.0001edd2 recovered at 12/27/2007 14:00:56
 status:0x4 root dba:0x004001a1 chkpt cnt: 8 ctl cnt:7
begin-hot-backup file size: 0
Checkpointed at scn:  0x0000.00029a92 12/27/2007 14:01:09
 thread:1 rba:(0x4.75.10)
 enabled  threads:  01000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000
Backup Checkpointed at scn:  0x0000.00000000
 thread:0 rba:(0x0.0.0)
 enabled  threads:  00000000 00000000 00000000 00000000 00000000 00000000
  00000000 00000000
External cache id: 0x0 0x0 0x0 0x0
Absolute fuzzy scn: 0x0000.00000000
Recovery fuzzy scn: 0x0000.00000000 12/27/2007 13:58:03
Terminal Recovery Stamp scn: 0x0000.00000000 01/01/1988 00:00:00
DUMP OF TEMP FILES: 1 files in database

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

相關文章