您好,登錄后才能下訂單哦!
這期內容當中小編將會給大家帶來有關Oracle中DBV命令行工具如何使用,文章內容豐富且以專業的角度為大家分析和敘述,閱讀完這篇文章希望大家可以有所收獲。
特點:
以只讀的方式打開數據文件,在檢查過程中不會修改數據文件的內容。
可以在線檢查數據文件,而不需要關閉數據庫。
不能檢查控制文件和日志文件,只能檢查數據文件。
這個工具可以檢查ASM文件,但數據庫必須Open狀態,并且需要通過USERID指定用戶,比如:dbv file=+DG1/ORCL/datafile/system01.dbf userid=system/sys
在許多UNIX平臺下,DBV要求數據文件有擴展名,如果沒有可以通過建立鏈接的方法,然后對鏈接的方法,然后對鏈接文件進行操作,比如:ls -n /dev/rdsk/mydevice /tmp/mydevice.dbf
某些平臺,DBV工具不能檢查超過2GB的文件,如果碰到DBV-100錯誤,請先檢查文件大小,MOS Bug 710888對這個問題有描述。
DBV只會檢查數據塊的正確性,但不會關系數據塊是否屬于哪個對象。
對于祼設備建議指定END參數,避免超出數據文件范圍。比如:dbv FILE=/dev/rdsk/r1.dbf END=<last_block_number>。可以在v$datafile視圖中用bytes字段除以塊大小來獲得END值。
參數 含義 缺省值
FILE 要檢查的數據文件名 沒有缺省值
START 檢查起始數據塊號 數據文件的***個數據塊
END 檢查的***一個數據塊號 數據文件的***一個數據塊
BLOCKSIZE 數據塊大小,這個值要和數據庫的DB_BLOCK_SIZE參數值一致 缺省值8192
LOGFILE 檢查結果日志文件 沒有缺省值
FEEDBAK 顯示進度 0
PARFILE 參數文件名 沒有缺省值
USERID 用戶名、密碼 沒有缺省值
SEGMENT_ID 段ID,參數格式<tsn.segfile.segblock> 沒有缺省值
使用示例:
[oracle@rhel6 ~]$ dbv file=/u01/app/oracle/oradata/test/users01.dbf DBVERIFY: Release 11.2.0.1.0 - Production on Mon May 22 16:42:26 2017 Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved. DBVERIFY - Verification starting : FILE = /u01/app/oracle/oradata/test/users01.dbf DBVERIFY - Verification complete Total Pages Examined : 155520 Total Pages Processed (Data) : 144530 Total Pages Failing (Data) : 0 Total Pages Processed (Index): 52 Total Pages Failing (Index): 0 Total Pages Processed (Other): 1248 Total Pages Processed (Seg) : 0 Total Pages Failing (Seg) : 0 Total Pages Empty : 9690 Total Pages Marked Corrupt : 0 Total Pages Influx : 0 Total Pages Encrypted : 0 Highest block SCN : 3559792 (0.3559792)
這個工具報告使用的是page作為單位,含義和data block相同。從上面的檢查結果Total Pages Marked Corrupt : 0可以看出文件沒有壞塊。
除了檢查數據文件,這個工具還允許檢查單獨的Segment,這時參數值的格式為<tsn.segfile.segblock>
查看對象的tsn,segfile,segblock屬性:
zx@TEST>select t.ts#,s.header_file,s.header_block 2 from v$tablespace t,dba_segments s 3 where s.segment_name='T' 4 and t.name=s.tablespace_name; TS# HEADER_FILE HEADER_BLOCK ---------- ----------- ------------ 4 4 45834
從上面的查詢結果可行參數值為4.4.45834。檢查Segment:
[oracle@rhel6 ~]$ dbv userid=system/123456 segment_id=4.4.45834 DBVERIFY: Release 11.2.0.1.0 - Production on Mon May 22 20:58:33 2017 Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved. DBVERIFY - Verification starting : SEGMENT_ID = 4.4.45834 DBVERIFY - Verification complete Total Pages Examined : 8 Total Pages Processed (Data) : 5 Total Pages Failing (Data) : 0 Total Pages Processed (Index): 0 Total Pages Failing (Index): 0 Total Pages Processed (Other): 2 Total Pages Processed (Seg) : 1 Total Pages Failing (Seg) : 0 Total Pages Empty : 0 Total Pages Marked Corrupt : 0 Total Pages Influx : 0 Total Pages Encrypted : 0 Highest block SCN : 3518579 (0.3518579)
下面人為創造一個壞塊,用dbv來檢查。
創建一個測試表
zx@TEST>create table bbed (id number,name varchar2(20)) tablespace users; Table created. zx@TEST>insert into bbed values(1,'zhaoxu'); 1 row created. zx@TEST>commit; Commit complete.
當前數據文件沒有壞塊
[oracle@rhel6 ~]$ dbv file=/u01/app/oracle/oradata/test/users01.dbf DBVERIFY: Release 11.2.0.1.0 - Production on Mon May 22 21:03:40 2017 Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved. DBVERIFY - Verification starting : FILE = /u01/app/oracle/oradata/test/users01.dbf DBVERIFY - Verification complete Total Pages Examined : 155520 Total Pages Processed (Data) : 66397 Total Pages Failing (Data) : 0 Total Pages Processed (Index): 52 Total Pages Failing (Index): 0 Total Pages Processed (Other): 88898 Total Pages Processed (Seg) : 0 Total Pages Failing (Seg) : 0 Total Pages Empty : 173 Total Pages Marked Corrupt : 0 Total Pages Influx : 0 Total Pages Encrypted : 0 Highest block SCN : 3764775 (0.3764775)
獲取表在文件中的存儲信息
zx@TEST>set serveroutput on zx@TEST>declare rfno number; 2 rtype number; 3 ono number; 4 blkno number; 5 rowno number; 6 rid varchar2(30); 7 begin 8 select rowid into rid from bbed; 9 dbms_rowid.rowid_info(ROWID_IN=>rid,RELATIVE_FNO=>rfno,BLOCK_NUMBER=>blkno,ROW_NUMBER=>rowno,ROWID_TYPE=>rtype,OBJECT_NUMBER=>ono); 10 dbms_output.put_line(rfno||','||blkno||','||rowno); 11 end; 12 / 4,45844,0 PL/SQL procedure successfully completed.
使用bbed修改塊信息
[oracle@rhel6 bbed]$ bbed parfile=bbed.par Password: BBED: Release 2.0.0.0.0 - Limited Production on Mon May 22 21:17:18 2017 Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved. ************* !!! For Oracle Internal Use only !!! *************** BBED> set dba 4,45844 DBA 0x0100b314 (16823060 4,45844) BBED> find /c zhaoxu File: /u01/app/oracle/oradata/test/users01.dbf (4) Block: 45844 Offsets: 8182 to 8191 Dba:0x0100b314 ------------------------------------------------------------------------ 7a68616f 78750106 5873 <32 bytes per line> BBED> dump /v dba 4,45844 offset 8182 count 32 File: /u01/app/oracle/oradata/test/users01.dbf (4) Block: 45844 Offsets: 8182 to 8191 Dba:0x0100b314 ------------------------------------------------------- 7a68616f 78750106 5873 l zhaoxu..Xs <16 bytes per line> BBED> modify 100 dba 4,45844 Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y File: /u01/app/oracle/oradata/test/users01.dbf (4) Block: 45844 Offsets: 8182 to 8191 Dba:0x0100b314 ------------------------------------------------------------------------ 6468616f 78750106 5873 <32 bytes per line> BBED> dump /v dba 4,45844 offset 8182 count 32 File: /u01/app/oracle/oradata/test/users01.dbf (4) Block: 45844 Offsets: 8182 to 8191 Dba:0x0100b314 ------------------------------------------------------- 6468616f 78750106 5873 l dhaoxu..Xs <16 bytes per line> BBED> exit
再次使用dbv檢查文件
[oracle@rhel6 bbed]$ dbv file=/u01/app/oracle/oradata/test/users01.dbf DBVERIFY: Release 11.2.0.1.0 - Production on Mon May 22 21:18:46 2017 Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved. DBVERIFY - Verification starting : FILE = /u01/app/oracle/oradata/test/users01.dbf Page 45844 is marked corrupt Corrupt block relative dba: 0x0100b314 (file 4, block 45844) Bad check value found during dbv: Data in bad block: type: 6 format: 2 rdba: 0x0100b314 last change scn: 0x0000.00397358 seq: 0x1 flg: 0x04 spare1: 0x0 spare2: 0x0 spare3: 0x0 consistency value in tail: 0x73580601 check value in block header: 0x7c2d computed block checksum: 0x1e DBVERIFY - Verification complete Total Pages Examined : 155520 Total Pages Processed (Data) : 66396 Total Pages Failing (Data) : 0 Total Pages Processed (Index): 52 Total Pages Failing (Index): 0 Total Pages Processed (Other): 88898 Total Pages Processed (Seg) : 0 Total Pages Failing (Seg) : 0 Total Pages Empty : 173 Total Pages Marked Corrupt : 1 Total Pages Influx : 0 Total Pages Encrypted : 0 Highest block SCN : 3764775 (0.3764775)
報告一個壞塊,Total Pages Marked Corrupt : 1
再次查詢測試表:
sys@TEST>select * from zx.bbed; ID NAME ---------- ------------------------------------------------------------ 1 zhaoxu
查詢正常,因為在buffer_cache中緩存了塊,而修改的是文件中的塊。兩個塊現在不一致,清空buffer cache后再次查詢測試表。
zx@TEST>alter system flush buffer_cache; System altered. zx@TEST>select * from bbed; select * from bbed * ERROR at line 1: ORA-01578: ORACLE data block corrupted (file # 4, block # 45844) ORA-01110: data file 4: '/u01/app/oracle/oradata/test/users01.dbf'
查詢報出錯誤ORA-01578。
使用dbv檢查ASM文件中的數據文件,需要指定userid參數
[oracle@rac1 ~]$ dbv file=+DATA/orcl/datafile/users.259.925306091 userid=sys/123456 DBVERIFY: Release 11.2.0.4.0 - Production on Mon May 22 16:48:22 2017 Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved. DBVERIFY - Verification starting : FILE = +DATA/orcl/datafile/users.259.925306091 DBVERIFY - Verification complete Total Pages Examined : 640 Total Pages Processed (Data) : 16 Total Pages Failing (Data) : 0 Total Pages Processed (Index): 2 Total Pages Failing (Index): 0 Total Pages Processed (Other): 593 Total Pages Processed (Seg) : 0 Total Pages Failing (Seg) : 0 Total Pages Empty : 29 Total Pages Marked Corrupt : 0 Total Pages Influx : 0 Total Pages Encrypted : 0 Highest block SCN : 0 (0.0)
上述就是小編為大家分享的Oracle中DBV命令行工具如何使用了,如果剛好有類似的疑惑,不妨參照上述分析進行理解。如果想知道更多相關知識,歡迎關注億速云行業資訊頻道。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。