測試目的:檢測windows下oracle熱備檔案含spfile,控制檔案,資料檔案,歸檔日誌,非rman方式)異機恢複,非原路徑下的恢複可用性。
測試環境:windows 2003 R2,ORACLE 11G R2
測試步驟:
1,將原執行個體的熱備檔案拷貝到待測試環境中
650) this.width=650;" style="border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="image" border="0" alt="image" src="http://www.bkjia.com/uploads/allimg/131229/221F23Q5-0.png" width="298" height="300" />
2,將spfile備份檔案拷貝到$ORACLE_HOME/dbs/中,通過該參數檔案在sqlplus下建立一份靜態參數檔案:
650) this.width=650;" style="border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="image" border="0" alt="image" src="http://www.bkjia.com/uploads/allimg/131229/221F21551-1.png" width="832" height="225" />
3,編輯產生的靜態參數檔案,採用測試平台適用的參數,並刪除spfile檔案已讓執行個體從靜態參數檔案啟動),這裡主要修改了一些路經參數:
650) this.width=650;" style="border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="image" border="0" alt="image" src="http://www.bkjia.com/uploads/allimg/131229/221F2JI-2.png" width="484" height="386" />
4,將資料庫啟動的mount狀態,已讀取來源資料庫中資料檔案的儲存資訊,並修改成測試平台資料檔案的儲存資訊,通過以下語句產生批量修改sql:
select 'alter database rename file '''||name||''' to ''E:\hot_backup_2013-12-06\'||substr(name,36)||''' ;' from v$datafile;
650) this.width=650;" style="border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="image" border="0" alt="image" src="http://img1.51cto.com/attachment/201312/9/663185_1386554582DlL5.png" width="712" height="201" />
5,複製產生的sql語句並執行,檢查是否修改成功:
select name from v$datafile;
6,由於重做記錄檔無法在這種情況下修改路徑,所以必須通過備份控制檔案到trace中,然後手動修改重做記錄檔地址的方式實現重新命名重做記錄檔:
alter database backup controlfile to trace;
查看警示日誌,定位到trace檔案名稱:
alter database backup controlfile to trace
Backup controlfile written to trace file e:\app\administrator\log\diagnostic_dest\diag\rdbms\zstoa\zstoa\trace\zstoa_ora_3520.trc
Completed: alter database backup controlfile to trace
複製trace中的建立controlfile代碼將"NORESETLOGS”修改為"RESETLOGS"),修改其中的重做日誌資訊,一定要注意的是編輯格式,多一個空格或單引號寫錯都會造成建立失敗:
1:CREATE CONTROLFILE REUSE DATABASE "ZSTOA" RESETLOGS FORCE LOGGING ARCHIVELOG
2: MAXLOGFILES 16
3: MAXLOGMEMBERS 3
4: MAXDATAFILES 100
5: MAXINSTANCES 8
6: MAXLOGHISTORY 292
7: LOGFILE
8:GROUP 4 (
9:'E:\ZSTOA\REDO04_01.LOG',
10:'E:\ZSTOA\REDO04_02.LOG'
11: ) SIZE 200M BLOCKSIZE 512,
12:GROUP 5 (
13:'E:\ZSTOA\REDO05_01.LOG',
14:'E:\ZSTOA\REDO05_02.LOG'
15: ) SIZE 200M BLOCKSIZE 512,
16:GROUP 6 (
17:'E:\ZSTOA\REDO06_01.LOG',
18:'E:\ZSTOA\REDO06_02.LOG'
19: ) SIZE 200M BLOCKSIZE 512
20: DATAFILE
21:'E:\ZSTOA\SYSTEM01.DBF',
22:'E:\ZSTOA\SYSAUX01.DBF',
23:'E:\ZSTOA\UNDOTBS01.DBF',
24:'E:\ZSTOA\USERS01.DBF',
25:'E:\ZSTOA\TBS_V3XSPACE_01.DBF',
26:'E:\ZSTOA\TBS_V3XSPACE_02.DBF',
27:'E:\ZSTOA\TBS_V3XSPACE_03.DBF',
28:'E:\ZSTOA\UNDOTBS_FILE2'
29:CHARACTERSET AL32UTF8
7,關閉資料庫,啟動到nomount模式,刪除或重新命名之前用的控制檔案,執行上面代碼建立控制檔案:
650) this.width=650;" style="border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="image" border="0" alt="image" src="http://www.bkjia.com/uploads/allimg/131229/221F25O5-4.png" width="625" height="591" />
8,將資料庫啟動到mount模式
alter database mount;
9,通過歸檔日誌還原資料庫,恢複過程中指定歸檔檔案路徑
recover database using backup controlfile until cancel
650) this.width=650;" style="border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="image" border="0" alt="image" src="http://www.bkjia.com/uploads/allimg/131229/221F23H6-5.png" width="609" height="254" />
10,恢複完成後,通過resetlogs模式啟動資料庫:
alter database open resetlogs;
650) this.width=650;" style="border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="image" border="0" alt="image" src="http://www.bkjia.com/uploads/allimg/131229/221F25535-6.png" width="339" height="71" />
我的部落格:www.fanmeng.net.cn