一、DBV 說明
DBV是一個常用的工具,OracleMOS上有一篇文章介紹DBV:[ID 35512.1]。
dbverify工具的主要目的是為了檢查資料檔案的物理結構,包括資料檔案是否損壞,是否存在邏輯壞塊,以及資料檔案中包含何種類型的資料。
DBV checks Oracledatafiles to ensure that:
(1)The datafile has a valid header
(2)Each datablock in the file has aspecial "wrapper" which identifies the block - this"wrapper" is checked for correctness
(3)DATA (TABLE) and INDEX blocks areinternally consistent
(4)From 8.1.6 onwards: That variousother block types are internally consistent (such as rollback segmentblocks)
The tool can be used to give some degree of confidence that a datafile is free fromcorruption. It opens files in a read only mode and so cannot change thecontents of the file being checked.
DBVERIFY工具可以驗證ONLINE或OFFLINE的資料檔案。不管資料庫是否開啟,都可以訪問資料檔案。
注意:
(1)對於DBVERIFY工具,高版本可以自動識別低版本資料庫,比如11g的dbv訪問9i的資料庫,但是低版本的dbv訪問高版本會報如下之類的錯誤:
DBVERIFY-驗證正在開始: FILE =e:/oracle/oradata/Dave/test01.dbf
匯入的頁1 -可能是介質損壞
更多精彩內容:http://www.bianceng.cn/database/Oracle/
(2)查看資料壞塊所在資料檔案號及塊號可以對錶進行一次全表掃描,如:
select count(*) from tablename;
如果有壞塊, 在掃描的時候就會報錯。
二、DBV 的命令參數
C: />dbv help=y
DBVERIFY: Release 11.1.0.7.0 - Productionon 星期二 12月 15 23:35:24 2009
Copyright (c) 1982, 2007, Oracle. Allrights reserved.
關鍵字 說明 (預設值)
----------------------------------------------------
FILE 要驗證的檔案 (無)
START 起始塊 (檔案的第一個塊)
END 結束塊 (檔案的最後一個塊)
BLOCKSIZE 邏輯塊大小 (8192)
LOGFILE 輸出日誌 (無)
FEEDBACK 顯示進度 (0)
PARFILE 參數檔案 (無)
USERID 使用者名稱/口令 (無)
SEGMENT_ID 段 ID (tsn.relfile.block) (無)
HIGH_SCN 要驗證的最高塊 SCN (無)
(scn_wrap.scn_base 或 scn)
(1)FILE(File to Verify):This is the name of the file to verify. See"Limitations" below if your datafile name has no suffix.
(2)START(Start Block):This is the first datablock to check in the file.This defaults to the first block in the file and need only be specifiedif you want to check just a portion of a given file.
(3)END(End Block):This is the last datablock to check in the file. Thisdefaults to the last block of the filebut may need specifying for RAW devices(See "Limitations" below) BLOCKSIZE Logical Block Size This is the database blocksize of the datafile you wish to scan. The value defaults to "2048". Thisparameter must be set to the DB_BLOCK_SIZE of the datafile to be scanned.
(4)LOGFILE(Output Log):This is the name of file to outputthe results to. The default is "NONE" and output is sent to terminal.
(5)FEEDBACK( Display Progress): If set to a value above 0 (the default) then DBVoutputs a "." for every N pages of the datafile checked. This isuseful to see that DBV is working through the ile.
(6)PARFILE(Parameter file):Parameters can be specified in a parameterfile and PARFILE used to cause the filecontents to be used as input parameters. The PARFILE can contain any of theabove options.
(7)HIGH_SCN(Scn):Highest Block SCN To Verify (scn_wrap.scn_base OR scn) Find theblocks exceeding the SCN. Available in version 9.2.0.6 and above.
(8)USERID (Username/Password):If the file you are verifying isan Automatic Storage Management (ASM) file, you must supply a USERID. This isbecause DBVERIFY needs to connect to an Oracle instance to access ASM files.
(9)SEGMENT_ID (TS#.FILE#.BLOCK#):Specifies the segment that youwant to verify. For more info, review Note:139962.1
三、DBV 限制
3.1 As DBV performs checks at a block levelit cannot detect problems such as INDEX versus TABLE mismatches which can bedetected by the 'ANALYZE TABLE VALIDATE STRUCTURE CASCADE' command.
3.2 This utility can ONLY be used against DATAfiles. It CANNOT be used to verify redolog files or control files.
3.3 You can use DBV to verify an AutomaticStorage Management (ASM) file.
However, the database must be opened and the option USERID has to beused
Example : dbv file=+DG1/ORCL/datafile/system01.dbf userid=system/sys
DBV checks the userid/password for ASM managed files, which is notpossible when database is not open.
3.4 On most releases on Unix DBV expects afilename extension.
This means that DBV cannot be used against datafiles with no filenamesuffix, or against RAW devices. --DBV 要求datafile 必須有副檔名
The workaround is to create a symbolic link to the raw device where thelink name MUST have an extension.
Eg: ln -s /dev/rdsk/mydevice /tmp/mydevice.dbf
Now use DBV against /tmp/mydevice.dbf
--如果裸裝置沒有副檔名,可以建立一個link,然後在進行dbv 檢查。
3.5 For RAW devices you should use the ENDparameter to avoid running off the end of the Oracle file space.