我們大家都知道,數據庫的服務器(本文以Oracle,非歸檔模式,把相關的軟件安裝於本地,把相關的Oracle控制文件放於本地,別的文件在相關的磁盤陣列)我們對其需要重做相關的OS,於是將Oracle相關的文件全部冷備到其他機器。
在拷貝數據文件的時候,system01.dbf出現一些問題,無法拷貝,於是再次打開數據庫(在這之前,控制文件已經)檢查了一下所有文件的狀態,並沒有查到什麼原因導致system01.dbf無法拷貝。
當時的決定是:放棄冷備,OS重裝後直接重裝Oracle,然後導入數據恢復。比較幸運的是,OS重裝後,磁盤陣列的卷信息居然都自動恢復了,將備份好的軟件解tar,將控制文件也拷回,打開數據庫時提示:Oracle控制文件比數據文件舊,無法打開。
恢復過程:
1、嘗試使用舊的Oracle控制文件去恢復數據文件到一個比較舊的狀態:
- SQL> recover database using BACKUP CONTROLFILE;
- ORA-00279: ?? 2734997 (? 03/09/2010 15:53:32 ??) ???? 1 ????
- ORA-00289: ??: /opt/app/Oracle/product/10.2.0/dbs/arch1_6_709571253.dbf
- ORA-00280: ?? 2734997 (???? 1) ??? #6 ?
指定日志: {<RET>=suggested | filename | AUTO | CANCEL}
- cancel
介質恢復已取消。
- SQL> recover database using BACKUP CONTROLFILE;
- ORA-00279: ?? 2734997 (? 03/09/2010 15:53:32 ??) ???? 1 ????
- ORA-00289: ??: /opt/app/Oracle/product/10.2.0/dbs/arch1_6_709571253.dbf
- ORA-00280: ?? 2734997 (???? 1) ??? #6 ?
指定日志: {<RET>=suggested | filename | AUTO | CANCEL}
- cancel
介質恢復已取消。
- SQL> alter database open resetlogs;
- alter database open resetlogs
- *
第 1 行出現錯誤:
- ORA-01113: ?? 1 ??????
- ORA-01110: ???? 1: '/usr3/oradata1/sysdata/system01.dbf'
2、重建控制文件:
- SQL>alter database backup controlfile to trace;
在udump目錄下找到相應的trc文件,先刪除舊的控制文件,然後使用第二段重建Oracle控制文件的語句重建控制文件:
SQL> CREATE CONTROLFILE REUSE DATABASE "CRNOPHQ" RESETLOGS NOARCHIVELOG
2 MAXLOGFILES 16
3 MAXLOGMEMBERS 3
4 MAXDATAFILES 1024
5 MAXINSTANCES 8
6 MAXLOGHISTORY 292
7 LOGFILE
8 GROUP 1 (
9 '/usr3/redo_log/redo01a.log',
10 '/usr3/redo_log/redo01b.log'
11 ) SIZE 1024M,
12 GROUP 2 (
13 '/usr3/redo_log/redo02a.log',
14 '/usr3/redo_log/redo02b.log'
15 ) SIZE 1024M,
16 GROUP 3 (
17 '/usr3/redo_log/redo03a.log',
18 '/usr3/redo_log/redo03b.log'
19 ) SIZE 1024M
20 -- STANDBY LOGFILE
21 DATAFILE
22 '/usr3/oradata1/sysdata/system01.dbf',
23 '/usr3/oradata1/sysdata/undotbs01.dbf',
24 '/usr3/oradata1/sysdata/sysaux01.dbf',
25 '/usr3/oradata1/sysdata/users01.dbf',
26 '/usr3/oradata1/sysdata/sysaux02.dbf',
27 '/usr3/oradata1/sysdata/system02.dbf',
28 '/usr3/oradata1/sysdata/undotbs02.dbf',
29 '/usr3/oradata1/sysdata/undotbs03.dbf',
30 '/usr3/oradata1/sysdata/undotbs04.dbf',
31 '/usr3/oradata1/sysdata/users02.dbf',
32 '/usr3/oradata1/data/dbs_d_crnophq01.dbf',
33 '/usr3/oradata1/data/dbs_i_crnophq01.dbf',
34 '/usr3/oradata3/data/dbs_d_perf01.dbf',
35 '/usr3/oradata3/data/dbs_d_perf02.dbf',
36 '/usr3/oradata3/data/dbs_d_perf03.dbf',
37 '/usr3/oradata3/data/dbs_d_perf04.dbf',
38 '/usr3/oradata3/data/dbs_d_perf05.dbf',
39 '/usr3/oradata2/data/dbs_i_perf01.dbf',
40 '/usr3/oradata2/data/dbs_i_perf02.dbf',
41 '/usr3/oradata2/data/dbs_d_ne01.dbf',
42 '/usr3/oradata2/data/dbs_d_ne02.dbf',
43 '/usr3/oradata2/data/dbs_d_ne03.dbf',
44 '/usr3/oradata2/data/dbs_d_ne04.dbf',
45 '/usr3/oradata2/data/dbs_i_ne01.dbf',
46 '/usr3/oradata2/data/dbs_i_ne02.dbf',
47 '/usr3/oradata1/data/dbs_d_work01.dbf',
48 '/usr3/oradata1/data/dbs_i_work01.dbf',
49 '/usr3/oradata1/data/dbs_d_rnopoa01.dbf',
50 '/usr3/oradata1/data/dbs_i_rnopoa01.dbf',
51 '/usr3/oradata2/data/dbs_d_spatial01.dbf',
52 '/usr3/oradata2/data/dbs_i_spatial01.dbf',
53 '/usr3/oradata2/data/dbs_d_spatialmap01.dbf',
54 '/usr3/oradata2/data/dbs_i_spatialmap01.dbf'
55 CHARACTER SET ZHS16GBK
56 ;
Oracle控制文件已創建。
- SQL> alter database open resetlogs;
數據庫已更改。
- SQL> select status,instance_name from v$instance;
- STATUS INSTANCE_NAME
- ------------ ----------------
- OPEN CRNOPHQ
至此,恢復完成。