關於資料庫丟失控制檔案的測試

charsi發表於2012-03-02

資料庫丟失控制檔案的情況有幾種:
1.刪除
2.重新命名
3.清空
4.控制檔案所在的磁碟損壞.
另外,資料庫的控制檔案可能會有兩個、三個或多個的情況.


下面是我的測試結果
1.刪除
如果是刪除的話,如果刪除掉一個或者都刪掉,資料庫不會宕,依舊會正常執行,一直到下次重啟的時候,資料庫在檢查丟失控制檔案會報錯然後無法啟動,需要恢復;因此,刪除控制檔案不會對當前的資料庫執行產生影響,但是需要注意下次重啟的時候會報錯並無法啟動。

2.重新命名
重新命名也不會影響當前資料庫的正常執行,並且資料庫會依舊更新重新命名後的那個檔案,這個應該是由於系統的inode沒有改變的緣故。
同樣的現象trace檔案也同樣出現,如果跟蹤了一個sid的trace,生成的trace檔案我們將其移到另一個目錄或者重新命名成另外一個檔案,只要跟蹤的那個sid不退出,資料庫依舊會寫重新命名後的那個trace檔案.

3.清空
清空控制檔案,無論是清空一個,還是清空所有的控制檔案,清空完成之後再執行一次alter system checkpoint;之後,資料庫就會宕掉,報如下的錯誤:
Sat Jan 7 18:31:59 2012
Hex dump of (file 0, block 1) in trace file /home/oracle/admin/TESTDB/bdump/testdb_ckpt_10207.trc
Corrupt block relative dba: 0x00000001 (file 0, block 1)
Completely zero block found during control file header read
Sat Jan 7 18:31:59 2012
Errors in file /home/oracle/admin/TESTDB/bdump/testdb_ckpt_10207.trc:
ORA-00202: control file: '/u01/oracle/TESTDB/cfile/ora_control1.ctl'
Sat Jan 7 18:31:59 2012
Errors in file /home/oracle/admin/TESTDB/bdump/testdb_ckpt_10207.trc:
ORA-00227: corrupt block detected in control file: (block 1, # blocks 1)
ORA-00202: control file: '/u01/oracle/TESTDB/cfile/ora_control1.ctl'
CKPT: terminating instance due to error 227
Instance terminated by CKPT, pid = 10207

4.控制檔案所在的磁碟損壞
無論有幾個控制檔案,兩個或者三個;在損壞的磁碟上的控制檔案有一個或者全部都在損壞的磁碟上,都會導致資料庫馬上宕掉。
同時在alert日誌中報如下的錯誤:
ORA-00206: error in writing (block 3, # blocks 1) of control file
ORA-00202: control file: '/u01/oracle/TESTDB/cfile/ora_control2.ctl'
ORA-27072: File I/O error
Linux Error: 5: Input/output error
Additional information: 4
Additional information: 3
Additional information: -1
ORA-00206: error in writing (block 3, # blocks 1) of control file
ORA-00202: control file: '/u01/oracle/TESTDB/cfile/ora_control1.ctl'
ORA-27072: File I/O error
Linux Error: 5: Input/output error
Additional information: 4
Additional information: 3
Additional information: -1
Sat Jan 7 15:22:55 2012
CKPT: terminating instance due to error 221
Instance terminated by CKPT, pid = 8601

在ckpt生成的trace檔案中生成下面的錯誤:
Dump file /home/oracle/admin/TESTDB/bdump/testdb_ckpt_10054.trc
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
ORACLE_HOME = /home/oracle/oracle/product/10.2.0/db_1
System name: Linux
Node name: localhost.localdomain
Release: 2.6.9-89.0.0.0.1.ELhugemem
Version: #1 SMP Tue May 19 04:38:38 EDT 2009
Machine: i686
Instance name: TESTDB
Redo thread mounted by this instance: 1
Oracle process number: 7
Unix process pid: 10054, image: oracle@localhost.localdomain (CKPT)

*** 2012-01-07 18:03:28.521
*** SERVICE NAME:(SYS$BACKGROUND) 2012-01-07 18:03:28.518
*** SESSION ID:(165.1) 2012-01-07 18:03:28.517
ORA-00206: error in writing (block 3, # blocks 1) of control file
ORA-00202: control file: '/u01/oracle/TESTDB/cfile/ora_control1.ctl'
ORA-27072: File I/O error
Linux Error: 5: Input/output error
Additional information: 4
Additional information: 3
Additional information: -1
error 221 detected in background process
ORA-00221: error on write to control file
ORA-00206: error in writing (block 3, # blocks 1) of control file
ORA-00202: control file: '/u01/oracle/TESTDB/cfile/ora_control1.ctl'
ORA-27072: File I/O error
Linux Error: 5: Input/output error
Additional information: 4
Additional information: 3
Additional information: -1

關於磁碟損壞的測試是在vmware虛擬機器上進行,測試方法如下:
1.用虛擬機器單獨給linux系統新增一塊磁碟;
2.將磁碟mount到某一個檔案系統上,如/u01;
3.將控制檔案放在這個檔案系統/u01上;
4.啟動資料庫,之後進行模擬磁碟故障;
5.在虛擬機器上刪除硬碟。然後在linux系統中df -m雖然還能看到檔案系統線上,但其實已經相當於是磁碟損壞了.在刪除磁碟的同時,資料庫丟擲錯誤並abort.
6.模擬測試結束.

[@more@]

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

相關文章