斷電引起ora-01200的資料庫恢復

StudyCow發表於2009-06-18

一個10g的庫斷電後,開啟時出現ora-01200的錯誤:
SQL> connect / as sysdba;
已連線到空閒例程。
SQL> startup;
ORACLE 例程已經啟動。

Total System Global Area 612368384 bytes
Fixed Size 1250428 bytes
Variable Size 155192196 bytes
Database Buffers 448790528 bytes
Redo Buffers 7135232 bytes
資料庫裝載完畢。
ORA-01122: 資料庫檔案 17 驗證失敗
ORA-01110: 資料檔案 17: 'D:ORACLEPRODUCT10.2.0ORADATAORCLZL9EPRDAT.DBF'
ORA-01200: 255360 的實際檔案大小小於 264960 塊的正確大小

ORA-01200錯誤的官方解釋如下:

ORA-01200 actual file size of string is smaller than correct size of string blocks

Cause: The size of the file as returned by the operating system is smaller than the size of the file as indicated in the file header and the control file. Somehow the file has been truncated. Maybe it is the

result of a half completed copy.

Action: Restore a good copy of the datafile and do recovery as needed.

意思是說只有找備份進行恢復.看來問題比較嚴重, 這個檔案中儲存中ZLHIS的病歷資料,丟失了對客戶的損失太大. 作業系統的檔案大小小於資料檔案頭記錄的大小,我們可否在資料檔案末尾"增加"一段空的位元組呢?在linux下可以使用dd命令產生這種檔案,再附加到資料檔案末尾.windows下也提供了一個fsutil命令,可以用來產生指定位元組數的空檔案.

--1.首先需要計算,空檔案的位元組數:
(264960-255360) * 8192 = 78643200
--2.產生一個指定位元組數的空檔案.
C:Documents and SettingsAdministrator>fsutil file createnew c:append.dbf 78643200
已建立檔案 c:append.dbf
--3.附加到資料檔案末尾
C:Documents and SettingsAdministrator>type c:append.dbf >>D:ORACLEPRODUCT
10.2.0ORADATAORCLZL9EPRDAT.DBF

經過這麼處理後,資料庫已經可以mount起來了:

SQL> startup;
ORACLE 例程已經啟動。

Total System Global Area 612368384 bytes
Fixed Size 1250428 bytes
Variable Size 155192196 bytes
Database Buffers 448790528 bytes
Redo Buffers 7135232 bytes
資料庫裝載完畢。
ORA-01172: 執行緒 1 的恢復停止在塊 259285 (在檔案 17 中)
ORA-01151: 如果需要, 請使用介質恢復以恢復塊和還原備份

在開啟資料庫時候,發覺無法做例項恢復,提示恢復的檔案就是剛才損壞的資料檔案:


SQL> select name from v$datafile where file#=17;

NAME
--------------------------------------------------------------------------------
D:ORACLEPRODUCT10.2.0ORADATAORCLZL9EPRDAT.DBF


嘗試介質恢復, 出現了討厭的ORA-00600錯誤:

SQL> recover database;
ORA-00283: 恢復會話因錯誤而取消
ORA-12801: 並行查詢伺服器 P000 中發出錯誤訊號
ORA-10562: Error occurred while applying redo to data block (file# 17, block#
258754)
ORA-10564: tablespace ZL9EPRDAT
ORA-01110: data file 17: 'D:ORACLEPRODUCT10.2.0ORADATAORCLZL9EPRDAT.DBF'
ORA-10560: block type '0'
ORA-00600: internal error code, arguments: [4552], [1], [0], [], [], []

某些資料檔案塊已經損壞,無法應用redo中的日誌,這部分資料可能已經損壞,決定捨棄這部分資料.使用_allow_resetlogs_corruption引數跳過redo日誌檔案


SQL> alter system set "_allow_resetlogs_corruption"=true scope=spfile;

系統已更改。

SQL> shutdown immediate;
ORA-01109: 資料庫未開啟


已經解除安裝資料庫。
ORACLE 例程已經關閉。
SQL> startup mount;
ORACLE 例程已經啟動。

Total System Global Area 612368384 bytes
Fixed Size 1250428 bytes
Variable Size 155192196 bytes
Database Buffers 448790528 bytes
Redo Buffers 7135232 bytes
資料庫裝載完畢。


直接做不完全恢復,會提示歸檔日誌找不到,不用理會,嘗試用resetlogs開啟資料庫,還是失敗!! fuck!!


SQL> recover database until cancel;
ORA-00279: 更改 181426480 (在 06/11/2009 18:15:23 生成) 對於執行緒 1 是必需的
ORA-00289: 建議:
E:ORACLEPRODUCT10.2.0FLASH_RECOVERY_AREAORCLARCHIVELOG2009_06_11O1_MF_1_
8980_%U_.ARC
ORA-00280: 更改 181426480 (用於執行緒 1) 在序列 #8980 中


指定日誌: {=suggested | filename | AUTO | CANCEL}
auto
ORA-00308: 無法開啟歸檔日誌
'E:ORACLEPRODUCT10.2.0FLASH_RECOVERY_AREAORCLARCHIVELOG2009_06_11O1_MF_1
_8980_%U_.ARC'
ORA-27041: 無法開啟檔案
OSD-04002: 無法開啟檔案
O/S-Error: (OS 2) 系統找不到指定的檔案。


ORA-00308: 無法開啟歸檔日誌
'E:ORACLEPRODUCT10.2.0FLASH_RECOVERY_AREAORCLARCHIVELOG2009_06_11O1_MF_1
_8980_%U_.ARC'
ORA-27041: 無法開啟檔案
OSD-04002: 無法開啟檔案
O/S-Error: (OS 2) 系統找不到指定的檔案。


ORA-01547: 警告: RECOVER 成功但 OPEN RESETLOGS 將出現如下錯誤
ORA-01194: 檔案 1 需要更多的恢復來保持一致性
ORA-01110: 資料檔案 1: 'D:ORACLEPRODUCT10.2.0ORADATAORCLSYSTEM01.DBF'


SQL> alter database open resetlogs;
alter database open resetlogs
*
第 1 行出現錯誤:
ORA-03113: 通訊通道的檔案結束


這時候,檢視後臺的alertORCL.log檔案,有如下錯誤:
Thu Jun 11 22:59:58 2009
Errors in file e:oracleproduct10.2.0adminorclbdumporcl_smon_2064.trc:
ORA-00600: internal error code, arguments: [4193], [34756], [34760], [], [], [], [], []

查詢metalink得到上述錯誤主要是跟undo有關:
PURPOSE:
This article discusses the internal error "ORA-600 [4193]", what
it means and possible actions. The information here is only applicable
to the versions listed and is provided only for guidance.

ERROR:
ORA-600 [4193] [a] [b]

VERSIONS:
versions 6.0 to 10.1

DESCRIPTION:

A mismatch has been detected between Redo records and Rollback (Undo)
records.

We are validating the Undo block sequence number in the undo block against
the Redo block sequence number relating to the change being applied.

This error is reported when this validation fails.

ARGUMENTS:
Arg [a] Undo record seq number
Arg [b] Redo record seq number

FUNCTIONALITY:
KERNEL TRANSACTION UNDO

IMPACT:
PROCESS FAILURE
POSSIBLE ROLLBACK SEGMENT CORRUPTION

設定undo表空間為手動管理,再打資料庫成功!!!

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

Total System Global Area 612368384 bytes
Fixed Size 1250428 bytes
Variable Size 155192196 bytes
Database Buffers 448790528 bytes
Redo Buffers 7135232 bytes
資料庫裝載完畢。
SQL> show parameter undo;

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
undo_management string AUTO
undo_retention integer 900
undo_tablespace string UNDOTBS1

SQL> alter system set undo_management=manual scope=spfile;

系統已更改。

SQL> shutdown immediate;
ORA-01109: 資料庫未開啟


已經解除安裝資料庫。
ORACLE 例程已經關閉。
SQL> startup mount;
ORACLE 例程已經啟動。

Total System Global Area 612368384 bytes
Fixed Size 1250428 bytes
Variable Size 155192196 bytes
Database Buffers 448790528 bytes
Redo Buffers 7135232 bytes
資料庫裝載完畢。
SQL> alter database open;

資料庫已更改。

SQL> alter user system identified by his;

使用者已更改。

最後就是export資料,重建資料庫.

[@more@]

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

相關文章