通過dbv和rman blockrecover對Oracle資料庫壞塊進行修複。
(1)rman備份時alert.log報如下錯誤:
Fri Jul 2 12:41:36 2010
Hex dump of (file 12, block 2718618) in trace file /u01/app/oracle/admin/bi/udump/bi_ora_31213.trc
Corrupt block relative dba: 0x03297b9a (file 12, block 2718618)
Fractured block found during backing up datafile
Data in bad block:
type: 6 format: 2 rdba: 0x03297b9a
last change scn: 0x0002.482fc15b seq: 0x1 flg: 0x06
spare1: 0x0 spare2: 0x0 spare3: 0x0
consistency value in tail: 0x77b20601
check value in block header: 0x253
computed block checksum: 0xb6e9
Reread of blocknum=2718618, file=/u01/oradata/BI/estaging_user01.712.714072365. found same corrupt data
Reread of blocknum=2718618, file=/u01/oradata/BI/estaging_user01.712.714072365. found same corrupt data
Reread of blocknum=2718618, file=/u01/oradata/BI/estaging_user01.712.714072365. found same corrupt data
Reread of blocknum=2718618, file=/u01/oradata/BI/estaging_user01.712.714072365. found same corrupt data
Reread of blocknum=2718618, file=/u01/oradata/BI/estaging_user01.712.714072365. found same corrupt data
(2)查詢資料庫,可知含有壞塊的對象:
SQL> col SEGMENT_NAME format a20
col PARTITION_NAME format a10
select owner,segment_name,partition_name from dba_extents where file_id = 12 and 2718618 between block_id and block_id + blocks-1;
OWNER SEGMENT_NAME PARTITION_
-------------------- -------------------- ----------
ESTAGING LOG_RECORD_DETAIL_4 P20100630
(3)但全表掃描卻沒有任何問題:
SQL> select count(*) from ESTAGING.LOG_RECORD_DETAIL_4 partition (P20100630);
COUNT(*)
----------
449937
SQL> select count(*) from ESTAGING.LOG_RECORD_DETAIL_4;
COUNT(*)
----------
42049608
(4)使用dbv檢查發現有一個壞塊(耗時較長):
$ dbv file=/u01/oradata/BI/estaging_user01.712.714072365 BLOCKSIZE=8192
DBVERIFY: Release 10.2.0.4.0 - Production on Fri Jul 2 14:15:49 2010
Copyright (c) 1982, 2007, Oracle. All rights reserved.
DBVERIFY - Verification starting : FILE = /u01/oradata/BI/estaging_user01.712.714072365
Page 2718618 is influx - most likely media corrupt
Corrupt block relative dba: 0x03297b9a (file 12, block 2718618)
Fractured block found during dbv:
Data in bad block:
type: 6 format: 2 rdba: 0x03297b9a
last change scn: 0x0002.482fc15b seq: 0x1 flg: 0x06
spare1: 0x0 spare2: 0x0 spare3: 0x0
consistency value in tail: 0x77b20601
check value in block header: 0x253
computed block checksum: 0xb6e9
DBVERIFY - Verification complete
Total Pages Examined : 2748160
Total Pages Processed (Data) : 2462446
Total Pages Failing (Data) : 0
Total Pages Processed (Index): 235234
Total Pages Failing (Index): 0
Total Pages Processed (Other): 24969
Total Pages Processed (Seg) : 0
Total Pages Failing (Seg) : 0
Total Pages Empty : 25510
Total Pages Marked Corrupt : 1
Total Pages Influx : 1
Highest block SCN : 1229607770 (2.1229607770)
(5)使用rman檢查含有壞塊的資料檔案(耗時較長), 期間觀察alert.log會發現同樣的提示:
RMAN> backup validate datafile 12;
這個時候訪問v$database_block_corruption可以看到詳細的壞塊的資訊:
SQL> select * from v$database_block_corruption;
FILE# BLOCK# BLOCKS CORRUPTION_CHANGE# CORRUPTIO
---------- ---------- ---------- ------------------ ---------
12 2718618 1 0 FRACTURED
(6)使用rman進行塊恢複:
RMAN> blockrecover datafile 12 block 2718618 from backupset;
(7)塊恢複後,執行BLOCKRECOVER CORRUPTION LIST,會自動按照V$DATABASE_BLOCK_CORRUPTION進行修複(耗時較長):
RMAN> BLOCKRECOVER CORRUPTION LIST;
(8)這個時候再訪問v$database_block_corruption就看不到詳細的壞塊資訊了:
SQL> select * from v$database_block_corruption;
no rows selected
(9)再使用dbv檢查發現沒有壞塊了(耗時較長):
$ dbv file=/u01/oradata/BI/estaging_user01.712.714072365 BLOCKSIZE=8192
DBVERIFY: Release 10.2.0.4.0 - Production on Fri Jul 2 15:38:15 2010
Copyright (c) 1982, 2007, Oracle. All rights reserved.
DBVERIFY - Verification starting : FILE = /u01/oradata/BI/estaging_user01.712.714072365
DBVERIFY - Verification complete
Total Pages Examined : 2749440
Total Pages Processed (Data) : 2463763
Total Pages Failing (Data) : 0
Total Pages Processed (Index): 235250
Total Pages Failing (Index): 0
Total Pages Processed (Other): 24981
Total Pages Processed (Seg) : 0
Total Pages Failing (Seg) : 0
Total Pages Empty : 25446
Total Pages Marked Corrupt : 0
Total Pages Influx : 0
Highest block SCN : 1230819157 (2.1230819157)
--End--