【dbv】使用dbv工具檢驗資料檔案是否有壞塊

swq618發表於2016-06-13
dbv工具可以用來驗證資料檔案的有效性,在資料庫恢復之前可以使用該命令對備份檔案進行有效性檢查,防止因備份檔案本身的問題導致資料庫無法恢復。
當然,dbv命令也可以對線上的資料檔案進行檢查。

注意,dbv工具只可以對資料檔案進行檢查,無法使用它完成控制檔案和日誌檔案的檢查。

1.dbv命令語法
dbverify ::=

  dbv [ USERID=username/password ]
    FILE = filename
  | { START = block_address | END = block_address }
  | BLOCKSIZE = integer
  | HIGH_SCN = integer
  | LOGFILE = filename
  | FEEDBACK = integer
  | HELP  = { Y | N }
  | PARFILE = filename

End of description.

參考自Oracle官方文件

2.檢視幫助文件
從語法定義中我們看到“HELP  = { Y | N }”選項,我們可以使用它檢視dbv的幫助資訊。
secooler@secDB /home/oracle$ dbv help=y

DBVERIFY: Release 11.2.0.1.0 - Production on Wed Mar 31 19:47:36 2010

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

Keyword     Description                    (Default)
----------------------------------------------------
FILE        File to Verify                 (NONE)
START       Start Block                    (First Block of File)
END         End Block                      (Last Block of File)
BLOCKSIZE   Logical Block Size             (8192)
LOGFILE     Output Log                     (NONE)
FEEDBACK    Display Progress               (0)
PARFILE     Parameter File                 (NONE)
USERID      Username/Password              (NONE)
SEGMENT_ID  Segment ID (tsn.relfile.block) (NONE)
HIGH_SCN    Highest Block SCN To Verify    (NONE)
            (scn_wrap.scn_base OR scn)

幫助資訊中描述了dbv命令的使用方法,不贅述。

3.體驗dbv工具的效果
1)檢視系統中的資料檔名稱
sys@secooler> col name for a60
sys@secooler> select name from v$datafile;

NAME
------------------------------------------------------------
/oracle/ora11gR2/oradata/secooler/system01.dbf
/oracle/ora11gR2/oradata/secooler/sysaux01.dbf
/oracle/ora11gR2/oradata/secooler/undotbs01.dbf
/oracle/ora11gR2/oradata/secooler/users01.dbf

2)使用dbv工具對users01.dbf進行檢查
(1)使用最簡單的引數
sys@secooler> !dbv file=/oracle/ora11gR2/oradata/secooler/users01.dbf

DBVERIFY: Release 11.2.0.1.0 - Production on Wed Mar 31 19:50:59 2010

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

DBVERIFY - Verification starting : FILE = /oracle/ora11gR2/oradata/secooler/users01.dbf


DBVERIFY - Verification complete

Total Pages Examined         : 35520
Total Pages Processed (Data) : 33029
Total Pages Failing   (Data) : 0
Total Pages Processed (Index): 20
Total Pages Failing   (Index): 0
Total Pages Processed (Other): 402
Total Pages Processed (Seg)  : 0
Total Pages Failing   (Seg)  : 0
Total Pages Empty            : 2069
Total Pages Marked Corrupt   : 0
Total Pages Influx           : 0
Total Pages Encrypted        : 0
Highest block SCN            : 9291961 (0.9291961)

在實際使用中重點關注以下資訊:
Total Pages Failing   (Data) : 0
Total Pages Failing   (Index): 0
Total Pages Failing   (Seg)  : 0
Total Pages Marked Corrupt   : 0

如果以上資訊返回結果不為0,需要重點關注!及時排查原因。

(2)如果指定logfile引數,檢查結果將只記錄在日誌檔案中,螢幕上不顯示
sys@secooler> !dbv file=/oracle/ora11gR2/oradata/secooler/users01.dbf logfile=dbv_users01.log

DBVERIFY: Release 11.2.0.1.0 - Production on Wed Mar 31 19:52:20 2010

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

此時可以使用SQL*Plus的edit命令檢視生成的日誌檔案內容。
sys@secooler> ed dbv_users01.log

4.小結
dbv是備份有效性驗證的好幫手,善用之。

Good luck.

secooler
10.03.31

-- The End --

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

相關文章