Oracle DBV 工具 說明

來源:互聯網
上載者:User

 

 

一. 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 -可能是介質損壞

       (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.

   eg: "dbv FILE=/dev/rdsk/r1.dbf END=<last_block_number>"

    Ifyou get the END value too high DBV can report the last page/s of the file ascorrupt as these are beyond the end of the Oracle portion of the raw device.

 

   You can find value for END from the V$DATAFILE view by dividing the BYTESvalue by the database block size.

 

   Eg: To find out the END value to use for file#=5:                          

       SVRMGRL> show parameter db_block_size

        NAME                   TYPE   VALUE

        ----------------------------------- ------- ------

        db_block_size              integer 2048

 

       SVRMGRL> select BYTES/2048 from v$datafile where FILE#=5;

        BYTES/2048

        ----------

               5120

                                                          

So the command would be:

       dbvfile=/dev/rdsk/r1.dbf blocksize=2048 END=5120

--SVRMGRL 命令在oracle 10g已經取消,並且db_block_size 預設值也變成了8k。

 

3.6 DBV may not be able to scan datafileslarger than 2Gb and may report "DBV-100". This is reported in
Bug:710888for Unix and
Bug:1372172for 8.1.6 on NT. This problem is platform and release specific so if you getDBV-100 errors check the filesize first.

 

3.7 DBV from 8.1.6 onwards may reportspurious errors for rollback segment     blocks if the database has been migratedfrom Oracle7. See
Bug:1359160and
Note:118008.1.

 

3.8 DBV only checks a block in isolation -it does not know if the block is part of an existing object or not.

 

3.9 DBV is broken on SCO Unix - see
Bug:814249

 

3.10 DBV of a lower version should not beused against a higher DB version.

 

 

四. DBV 樣本

 

4.1 驗證ASM 上的檔案

SYS@anqing2(rac2)> select file_name fromdba_data_Files;

FILE_NAME

--------------------------------------------------------------------------------

+DATA/anqing/datafile/users.273.751548233

+DATA/anqing/datafile/sysaux01.dbf

+DATA/anqing/datafile/undotbs01.dbf

+DATA/anqing/datafile/system01.dbf

+DATA/anqing/datafile/system02.dbf

+DATA/anqing/datafile/undotbs02.dbf

+DATA/anqing/datafile/dave01.dbf

+DATA/anqing/datafile/test01.dbf

 

--dbv check ASM 上的檔案,注意添加userid參數

[oracle@rac2 ~]$ dbvfile='+DATA/anqing/datafile/undotbs02.dbf' userid=sys/oracle     

 

DBVERIFY: Release 10.2.0.4.0 - Productionon Tue Aug 9 21:44:36 2011

 

Copyright (c) 1982, 2007, Oracle.  All rights reserved.

 

DBVERIFY - Verification starting : FILE =+DATA/anqing/datafile/undotbs02.dbf

 

DBVERIFY - Verification complete

 

Total Pages Examined         : 64000

Total Pages Processed (Data) : 0

Total Pages Failing   (Data) : 0

Total Pages Processed (Index): 0

Total Pages Failing   (Index): 0

Total Pages Processed (Other): 32748

Total Pages Processed (Seg)  : 0

Total Pages Failing   (Seg) : 0

Total Pages Empty            : 31252

Total Pages Marked Corrupt   : 0

Total Pages Influx           : 0

Highest block SCN            : 0 (0.0)

 

4.2 驗證普通datafile

--執行個體沒有啟動的情況下進行datafile 驗證

D:\app\Administrator\oradata\newccs>dbvfile=undotbs01.dbf

 

DBVERIFY: Release 11.2.0.1.0 - Productionon Tue Aug 9 21:52:41 2011

 

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

 

DBVERIFY - Verification starting : FILE =D:\APP\ADMINISTRATOR\ORADATA\NEWCCS\UNDOTBS01.DBF

 

DBVERIFY - Verification complete

 

Total Pages Examined         : 64000

Total Pages Processed (Data) : 0

Total Pages Failing   (Data) : 0

Total Pages Processed (Index): 0

Total Pages Failing   (Index): 0

Total Pages Processed (Other): 35199

Total Pages Processed (Seg)  : 10

Total Pages Failing   (Seg) : 0

Total Pages Empty            : 28801

Total Pages Marked Corrupt   : 0

Total Pages Influx           : 0

Total Pages Encrypted        : 0

Highest block SCN            : 1315907818 (0.1315907818)

 

--這種情況下,db沒有啟動,要進入資料檔案的存放目錄後在運行該命令,不然會報找不到資料檔案。

 

4.3 DB open 狀態,驗證指定段

命令格式如下:

dbv USERID=username/passwordSEGMENT_ID=tsn.relfile.block

 

可以通過sys_dba_segs表擷取tablespace_id,header_file, header_block三個欄位,他們分別對應tsn,relfile,block.

 

SYS@anqing2(rac2)> select tablespace_id,header_file, header_block from sys_dba_segs where segment_name = 'TA';

 

TABLESPACE_ID HEADER_FILE HEADER_BLOCK

------------- ----------- ------------

           0           1        71513

 

[oracle@rac2 ~]$ dbv segment_id=0.1.71513 userid=sys/oracle

 

DBVERIFY: Release 10.2.0.4.0 - Productionon Tue Aug 9 21:59:32 2011

 

Copyright (c) 1982, 2007, Oracle.  All rights reserved.

 

 

DBV-00111: OCI failure(1913) (ORA-28009: connection as SYS should be as SYSDBA or SYSOPER

)

[oracle@rac2 ~]$ dbvsegment_id=0.1.71513 userid=system/oracle

 

DBVERIFY: Release 10.2.0.4.0 - Productionon Tue Aug 9 21:59:46 2011

 

Copyright (c) 1982, 2007, Oracle.  All rights reserved.

 

DBVERIFY - Verification starting :SEGMENT_ID = 0.1.71513

 

 

DBVERIFY - Verification complete

 

Total Pages Examined         : 2281

Total Pages Processed (Data) : 2280

Total Pages Failing   (Data) : 0

Total Pages Processed (Index): 0

Total Pages Failing   (Index): 0

Total Pages Processed (Other): 0

Total Pages Processed (Seg)  : 1

Total Pages Failing   (Seg) : 0

Total Pages Empty            : 0

Total Pages Marked Corrupt   : 0

Total Pages Influx           : 0

Highest block SCN            : 0 (0.0)

[oracle@rac2 ~]$

 

註:這種方式要求資料庫處於開啟的狀態。

 

4.4 驗證資料拷貝

由於dbv可以在執行個體關閉情況下驗證資料檔案,因此dbv也可以驗證資料檔案的拷貝。這個拷貝指的是通過RMAN的COPY命令或者作業系統命令cp拷貝的資料檔案,而不是RMAN產生的備份組格式。

 

如:

E:/app/Administrator/oradata/orcl>dbvfile= USERS01bak.DBF blocksize=8192

DBVERIFY: Release 11.1.0.7.0 - Productionon 星期三 12月 16 00:30:17 2009

Copyright (c) 1982, 2007, Oracle. Allrights reserved.

DBVERIFY - 開始驗證: FILE = E:/app/Administrator/oradata/orcl/USERS01bak.DBF

DBVERIFY - 驗證完成

檢查的頁總數: 640

處理的頁總數 (資料): 91

失敗的頁總數 (資料): 0

處理的頁總數 (索引): 33

失敗的頁總數 (索引): 0

處理的頁總數 (其它): 496

處理的總頁數 (段) : 0

失敗的總頁數 (段) : 0

空的頁總數: 20

標記為損壞的總頁數: 0

流入的頁總數: 0

加密的總頁數 : 0

最高塊 SCN :904088 (0.904088)

 

通過比較2個dbv 的結果來比較datafile 的copy

 

 

 

 

-------------------------------------------------------------------------------------------------------

Blog: http://blog.csdn.net/tianlesoftware

Weibo: http://weibo.com/tianlesoftware

Email: dvd.dba@gmail.com

DBA1 群:62697716(滿);   DBA2 群:62697977(滿)  DBA3 群:62697850(滿)  

DBA 超級群:63306533(滿);  DBA4 群: 83829929(滿) DBA5群: 142216823(滿) 

DBA6 群:158654907(滿)  聊天 群:40132017(滿)   聊天2群:69087192(滿)

--加群需要在備忘說明Oracle資料表空間和資料檔案的關係,否則拒絕申請

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.