1、 整個業務資料表空間丟失恢複
注意:以下的所有實驗,都是基於上面的全庫備份來做的恢複。
2.1 刪除wwl資料表空間的所有資料檔案
[root@wwldb ~]# cd /DBData/WWL/
[root@wwldb WWL]# rm -rf wwl*
[root@wwldb WWL]# ll
總計 881068
-rw-r----- 1 Oracle oinstall 31457792 06-22 01:34 redo01.log
-rw-r----- 1 oracle oinstall 31457792 06-22 01:34 redo02.log
-rw-r----- 1 oracle oinstall 31457792 06-22 02:14 redo03.log
-rw-r----- 1 oracle oinstall 27263795206-22 02:08 sysaux01.dbf
-rw-r----- 1 oracle oinstall 50332467206-22 02:09 system01.dbf
-rw-r----- 1 oracle oinstall 20979712 05-29 22:00 temp01.dbf
-rw-r----- 1 oracle oinstall 26222592 06-22 02:08 undotbs01.dbf
-rw-r----- 1 oracle oinstall 5251072 06-22 01:34 users01.dbf
2.2 啟動資料庫,報如下錯誤。
SQL> conn / as sysdba
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 1218968 bytes
Variable Size 100664936 bytes
Database Buffers 176160768 bytes
Redo Buffers 7168000 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 5- see DBWR trace file
ORA-01110: data file 5:'/DBData/WWL/wwl001.dbf'
2.3 檢查追蹤檔案,非常清晰的告訴丟失了有檔案找不到,丟失了。
***SERVICE NAME:() 2012-06-22 09:17:38.573
***SESSION ID:(167.1) 2012-06-22 09:17:38.573
ORA-01157:Message 1157 not found; No message file for product=RDBMS, facility=ORA;arguments: [5]
ORA-01110:Message 1110 not found; No message file for product=RDBMS, facility=ORA;arguments: [5] [/DBData/WWL/wwl001.dbf]
ORA-27037:Message 27037 not found; No message file for product=RDBMS, facility=ORA
LinuxError: 2: No such file or directory
Additionalinformation: 3
ORA-01157:Message 1157 not found; No message file for product=RDBMS, facility=ORA;arguments: [6]
ORA-01110:Message 1110 not found; No message file for product=RDBMS, facility=ORA;arguments: [6] [/DBData/WWL/wwl002.dbf]
ORA-27037:Message 27037 not found; No message file for product=RDBMS, facility=ORA
LinuxError: 2: No such file or directory
Additionalinformation: 3
ORA-01157:Message 1157 not found; No message file for product=RDBMS, facility=ORA;arguments: [7]
ORA-01110:Message 1110 not found; No message file for product=RDBMS, facility=ORA;arguments: [7] [/DBData/WWL/wwl003.dbf]
ORA-27037:Message 27037 not found; No message file for product=RDBMS, facility=ORA
LinuxError: 2: No such file or directory
Additionalinformation: 3
由如上的跟蹤資訊我們得出是由於/DBData/WWL/wwl001.dbf;/DBData/WWL/wwl002.dbf;/DBData/WWL/wwl001.dbf這三個檔案丟失導致資料庫無法起來,並且這三個檔案同時構成了一個WWL資料表空間。在這個資料表空間中儲存了各種各樣重要的資料。同樣我們可以按照之前的方法通過恢複資料檔案的方式來進行資料恢複,介於這次丟失的是所有資料檔案,數量比較多,而且如果對所有資料檔案做恢複,不僅大量的增加的工作量,同時也增加的恢複的風險。所以在這裡我們通過使用RMAN執行資料表空間恢複的方式來進行恢複。當然基於資料表空間的恢複也分兩種,一直是在不影響資料庫其它業務情況下的線上聯機恢複,還有一種是停機停業務的恢複,詳細見如下:
2.4 恢複方法一:零停機,線上恢複
開始執行恢複操作,分為如下七個步驟:
1、查看資料庫狀態是open的,我們剛才的刪除資料檔案沒有對庫照成太大的影響。
SQL>select instance_name,status from v$instance;
INSTANCE_NAME STATUS
----------------------------
WWL OPEN
2、將wwl資料表空間離線
SQL>alter tablespace wwl offline for recover;
Tablespacealtered.