DBV(DBVERIFY)是Oracle提供的一个命令行工具,它可以对数据文件物理和逻辑两种一致性检查。但是这个工具不会检查索引记录和数据记录的匹配关系,这种检查必须使用analyze validate structure命令。
为长泰等地区用户提供了全套网页设计制作服务,及长泰网站建设行业解决方案。主营业务为网站设计制作、成都网站制作、长泰网站设计,以传统方式定制建设网站,并提供域名空间备案等一条龙服务,秉承以专业、用心的态度为用户提供真诚的服务。我们深信只要达到每一位用户的要求,就会得到认可,从而选择与我们长期合作。这样,我们也可以走得更远!
这个工具有如下特点:
参数 含义 缺省值
FILE 要检查的数据文件名 没有缺省值
START 检查起始数据块号 数据文件的***个数据块
END 检查的***一个数据块号 数据文件的***一个数据块
BLOCKSIZE 数据块大小,这个值要和数据库的DB_BLOCK_SIZE参数值一致 缺省值8192
LOGFILE 检查结果日志文件 没有缺省值
FEEDBAK 显示进度 0
PARFILE 参数文件名 没有缺省值
USERID 用户名、密码 没有缺省值
SEGMENT_ID 段ID,参数格式
使用示例:
- [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属性:
- 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命令行工具用法详解
分享路径:http://www.shufengxianlan.com/qtweb/news22/554822.html
网站建设、网络推广公司-创新互联,是专注品牌与效果的网站制作,网络营销seo公司;服务项目有等
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联