数据库
首页 > 数据库> > Oracle--DBV命令行工具用法详解及坏块修复

Oracle--DBV命令行工具用法详解及坏块修复

作者:互联网

一,介绍

DBV(DBVERIFY)是Oracle提供的一个命令行工具,它可以对数据文件物理和逻辑两种一致性检查。但是这个工具不会检查索引记录和数据记录的匹配关系,这种检查必须使用analyze validate structure命令。

这个工具有如下特点:

参数 含义 缺省值
FILE 要检查的数据文件名 没有缺省值
START 检查起始数据块号 数据文件的第一个数据块
END 检查的最后一个数据块号 数据文件的最后一个数据块
BLOCKSIZE 数据块大小,这个值要和数据库的DB_BLOCK_SIZE参数值一致 缺省值8192
LOGFILE 检查结果日志文件 没有缺省值
FEEDBAK 显示进度 0
PARFILE 参数文件名 没有缺省值
USERID 用户名、密码 没有缺省值
SEGMENT_ID 段ID,参数格式<tsn.segfile.segblock> 没有缺省值

二,简单使用

[oracle@oracle01 oracle01]$ dbv file=test01.dbf
--最好是绝对路径,这里是进入到对应目录下,所以用相对路径
DBVERIFY: Release 11.2.0.4.0 - Production on Mon May 13 15:21:42 2019

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

DBVERIFY - Verification starting : FILE = /u01/app/oracle/oradata/oracle01/test01.dbf


DBVERIFY - Verification complete

Total Pages Examined         : 1280 --( 检查总页数)
Total Pages Processed (Data) : 5    --(处理的总页数(数据)) 
Total Pages Failing   (Data) : 0 --(总页数失败(数据))    
Total Pages Processed (Index): 0 --(处理的总页数(索引)) 
Total Pages Failing   (Index): 0 --(总页面失败(索引)) 
Total Pages Processed (Other): 136 --(处理的总页数(其他)) 
Total Pages Processed (Seg)  : 0 --(处理的总页数(Seg)) 
Total Pages Failing   (Seg)  : 0 --(总页数失败(Seg) 
Total Pages Empty            : 1139 --(总页数空) 
Total Pages Marked Corrupt   : 0 --(总页数标记为损坏) 
Total Pages Influx           : 0 --(总页面数量) 
Total Pages Encrypted        : 0 --(加密总页数) 
Highest block SCN            : 11638862 (0.11638862) --(最高块SCN) 

  这个工具报告使用的是page作为单位,含义和data block相同。从上面的检查结果Total Pages Marked Corrupt   : 0可以看出文件没有坏块。

除了检查数据文件,这个工具还允许检查单独的Segment,这时参数值的格式为<tsn.segfile.segblock>

查看对象的tsn,segfile,segblock属性:

SQL> select t.ts#,s.header_file,s.header_block
from v$tablespace t,dba_segments s
where s.segment_name='T'
and t.name=s.tablespace_name;   2    3    4

     0         1          96544

从上面的查询结果可行参数值为0.1.96544。检查Segment:

[oracle@oracle01 oracle01]$ dbv userid=system/123456 segment_id=0.1.96544

DBVERIFY: Release 11.2.0.4.0 - Production on Mon May 13 15:27:53 2019

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

DBVERIFY - Verification starting : SEGMENT_ID = 0.1.96544


DBVERIFY - Verification complete

Total Pages Examined         : 2
Total Pages Processed (Data) : 1
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
Total Pages Encrypted        : 0
Highest block SCN            : 11645088 (0.11645088)

三,创建坏块

  创建数据:

SQL> create table bbed (id number,name varchar2(20)) tablespace TT1;

Table created.

SQL> insert into bbed values(1,'zhaoxu');

1 row created.

SQL> commit;

Commit complete.

SQL> insert into bbed values(1,'kingle');

1 row created.

[oracle@oracle01 oracle01]$ dbv file=test01.dbf

DBVERIFY: Release 11.2.0.4.0 - Production on Mon May 13 15:40:14 2019

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

DBVERIFY - Verification starting : FILE = /u01/app/oracle/oradata/oracle01/test01.dbf


DBVERIFY - Verification complete

Total Pages Examined         : 1280
Total Pages Processed (Data) : 5
Total Pages Failing   (Data) : 0
Total Pages Processed (Index): 0
Total Pages Failing   (Index): 0
Total Pages Processed (Other): 136
Total Pages Processed (Seg)  : 0
Total Pages Failing   (Seg)  : 0
Total Pages Empty            : 1139
Total Pages Marked Corrupt   : 0
Total Pages Influx           : 0
Total Pages Encrypted        : 0
Highest block SCN            : 11638862 (0.11638862)

寻找数据块位置:

  

SQL> select  id,name,dbms_rowid.rowid_relative_fno(rowid)file#,dbms_rowid.rowid_block_number(rowid) block# from bbed;

     1 zhaoxu             6      157
     1 kingle             6      157

BBED连接数据库

[oracle@oracle01 BBED]$  bbed password=blockedit parfile=par.bbd

BBED: Release 2.0.0.0.0 - Limited Production on Mon May 13 15:47:32 2019

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

************* !!! For Oracle Internal Use only !!! ***************

BBED> set filename '/u01/app/oracle/oradata/oracle01/test01.dbf'
    FILENAME           /u01/app/oracle/oradata/oracle01/test01.dbf

BBED> map
 File: /u01/app/oracle/oradata/oracle01/test01.dbf (6)
 Block: 1                                     Dba:0x01800001
------------------------------------------------------------
 Data File Header

 struct kcvfh, 860 bytes                    @0

 ub4 tailchk                                @8188


BBED> show all
    FILE#              6
    BLOCK#             1
    OFFSET             0
    DBA                0x01800001 (25165825 6,1)
    FILENAME           /u01/app/oracle/oradata/oracle01/test01.dbf
    BIFILE             bifile.bbd
    LISTFILE           bbed.txt
    BLOCKSIZE          8192
    MODE               Edit
    EDIT               Unrecoverable
    IBASE              Dec
    OBASE              Dec
    WIDTH              80
    COUNT              512
    LOGFILE            log.bbd
    SPOOL              No

BBED> map
 File: /u01/app/oracle/oradata/oracle01/test01.dbf (6)
 Block: 1                                     Dba:0x01800001
------------------------------------------------------------
 Data File Header

 struct kcvfh, 860 bytes                    @0

 ub4 tailchk                                @8188


BBED> set dba 6,157
    DBA                0x0180009d (25165981 6,157)

BBED> find /c kingle   --这就是我们找到的字符位置
 File: /u01/app/oracle/oradata/oracle01/test01.dbf (6)
 Block: 157              Offsets: 8169 to 8191           Dba:0x0180009d
------------------------------------------------------------------------
 6b696e67 6c652c01 0202c102 067a6861 6f787501 06c3cd

 <32 bytes per line>

更改数据:

BBED> dump /v dba 6,157 offset 8169 count 32 
 File: /u01/app/oracle/oradata/oracle01/test01.dbf (6)
 Block: 157     Offsets: 8169 to 8191  Dba:0x0180009d
-------------------------------------------------------
 6b696e67 6c652c01 0202c102 067a6861 l kingle,...

标签:DBV,Total,oracle01,Oracle,坏块,DISK,Pages,channel,ORA
来源: https://www.cnblogs.com/kingle-study/p/10857467.html