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

更新时间:2023-06-30 03:20:17 阅读: 评论:0

Oracle--DBV命令⾏⼯具⽤法详解及坏块修复
⼀,介绍
DBV(DBVERIFY)是提供的⼀个命令⾏⼯具,它可以对数据⽂件物理和逻辑两种⼀致性检查。但是这个⼯具不会检查索引记录和数据记录的匹配关系,这种检查必须使⽤analyze validate structure命令。
这个⼯具有如下特点:
以只读的⽅式打开数据⽂件,在检查过程中不会修改数据⽂件的内容。
可以在线检查数据⽂件,⽽不需要关闭数据库。
不能检查控制⽂件和⽇志⽂件,只能检查数据⽂件。
这个⼯具可以检查ASM⽂件,但数据库必须Open状态,并且需要通过USERID指定⽤户,⽐如:dbv
file=+DG1/ORCL/datafile/system01.dbf urid=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.gfile.gblock>没有缺省值
⼆,简单使⽤
[oracle@oracle01 oracle01]$ dbv file=test01.dbf
--最好是绝对路径,这⾥是进⼊到对应⽬录下,所以⽤相对路径
DBVERIFY: Relea 11.2.0.4.0- Production on Mon May 1315:21:422019
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights rerved.
DBVERIFY - Verification starting : FILE=/u01/app/oracle/oradata/oracle01/test01.dbf
DBVERIFY - Verification complete
Total Pages Examined        : 1280 --( 检查总页数)
Total Pages Procesd (Data) : 5    --(处理的总页数(数据))
Total Pages Failing  (Data) : 0 --(总页数失败(数据))
Total Pages Procesd (Index): 0 --(处理的总页数(索引))
Total Pages Failing  (Index): 0 --(总页⾯失败(索引))
Total Pages Procesd (Other): 136 --(处理的总页数(其他))舍不得离开
Total Pages Procesd (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.gfile.gblock>
查看对象的tsn,gfile,gblock属性:
SQL>lect t.ts#,s.header_file,s.header_block
from v$tablespace t,dba_gments s
_name='T'
and t.name=s.tablespace_name;  234
0196544
从上⾯的查询结果可⾏参数值为0.1.96544。检查Segment:
[oracle@oracle01 oracle01]$ dbv urid=system/123456 gment_id=0.1.96544
DBVERIFY: Relea 11.2.0.4.0- Production on Mon May 1315:27:532019
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights rerved.
DBVERIFY - Verification starting : SEGMENT_ID =0.1.96544
DBVERIFY - Verification complete
Total Pages Examined        : 2
Total Pages Procesd (Data) : 1
Total Pages Failing  (Data) : 0
Total Pages Procesd (Index): 0
Total Pages Failing  (Index): 0
Total Pages Procesd (Other): 0
Total Pages Procesd (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>inrt into bbed values(1,'zhaoxu');
1 row created.
SQL>commit;
Commit complete.
SQL>inrt into bbed values(1,'kingle');
1 row created.
[oracle@oracle01 oracle01]$ dbv file=test01.dbf
DBVERIFY: Relea 11.2.0.4.0- Production on Mon May 1315:40:142019
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights rerved.
DBVERIFY - Verification starting : FILE=/u01/app/oracle/oradata/oracle01/test01.dbf
DBVERIFY - Verification complete
Total Pages Examined        : 1280
Total Pages Procesd (Data) : 5
Total Pages Failing  (Data) : 0
Total Pages Procesd (Index): 0
Total Pages Failing  (Index): 0
Total Pages Procesd (Other): 136
Total Pages Procesd (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>lect  id,name,wid_relative_fno(rowid)file#,wid_block_number(rowid) block# from bbed;
1 zhaoxu            6157
1 kingle            6157
BBED连接数据库
[oracle@oracle01 BBED]$  bbed password=blockedit parfile=par.bbd BBED: Relea 2.0.0.0.0- Limi
ted Production on Mon May 1315:47:322019 Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights rerved.
************* !!! For Oracle Internal U only !!! ***************
BBED>t 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 (251658256,1)
FILENAME          /u01/app/oracle/oradata/oracle01/test01.dbf
BIFILE            bifile.bbd
LISTFILE         
BLOCKSIZE          8192
MODE              Edit
EDIT              Unrecoverable
IBASE              Dec
OBASE              Dec
WIDTH              80
COUNT512
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>t dba 6,157
DBA                0x0180009d (251659816,157)
BBED> find /c kingle  --这就是我们找到的字符位置
File: /u01/app/oracle/oradata/oracle01/test01.dbf (6)
Block: 157Offts: 8169to8191          Dba:0x0180009d
------------------------------------------------------------------------
6b696e67 6c652c01 0202c102 067a6861 6f787501 06c3cd
<32 bytes per line>
更改数据:
BBED>dump/v dba 6,157 offt 8169count32
File: /u01/app/oracle/oradata/oracle01/test01.dbf (6)
Block: 157Offts: 8169to8191  Dba:0x0180009d
-------------------------------------------------------
6b696e67 6c652c01 0202c102 067a6861 l kingle,... .zha
6f787501 06c3cd                    l oxu..č
<16 bytes per line>
BBED> modify 100 dba 6,157;
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) Y
File: /u01/app/oracle/oradata/oracle01/test01.dbf (6)
Block: 157Offts: 8169to8191          Dba:0x0180009d
-
-----------------------------------------------------------------------
64696e67 6c652c01 0202c102 067a6861 6f787501 06c3cd
<32 bytes per line>
BBED>dump/v dba 6,157 offt 8169count32
File: /u01/app/oracle/oradata/oracle01/test01.dbf (6)
Block: 157Offts: 8169to8191  Dba:0x0180009d
-------------------------------------------------------
64696e67 6c652c01 0202c102 067a6861 l dingle,... .zha
6f787501 06c3cd                    l oxu..č
<16 bytes per line>
BBED>exit
查看数据块:
[oracle@oracle01 oracle01]$ dbv file=test01.dbf
DBVERIFY: Relea 11.2.0.4.0- Production on Mon May 1315:54:142019
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights rerved.
DBVERIFY - Verification starting : FILE=/u01/app/oracle/oradata/oracle01/test01.dbf
Page 157is marked corrupt
Corrupt block relative dba: 0x0180009d (file6, block 157)
Bad check value found during dbv:
Data in bad block:
type: 6 format: 2 rdba: 0x0180009d
last change scn: 0x0000.00b1cdc3 q: 0x1 flg: 0x04
五陵少年spare1: 0x0 spare2: 0x0 spare3: 0x0
consistency value in tail: 0xcdc30601
check value in block header: 0x81c0
computed block checksum: 0xf00
DBVERIFY - Verification complete
Total Pages Examined        : 1280
Total Pages Procesd (Data) : 9
Total Pages Failing  (Data) : 0
Total Pages Procesd (Index): 0
Total Pages Failing  (Index): 0通知是什么意思
Total Pages Procesd (Other): 139
Total Pages Procesd (Seg)  : 0
Total Pages Failing  (Seg)  : 0
Total Pages Empty            : 1131
Total Pages Marked Corrupt  : 1      --  !!!!!!!!!!--表⽰存在坏块
Total Pages Influx          : 0
Total Pages Encrypted        : 0
Highest block SCN            : 11652516 (0.11652516)
[oracle@oracle01 oracle01]$
有问题了已经。
查询数据验证问题:
SQL>lect*from bbed;
1 zhaoxu
1 kingle
--查询正常,因为在buffer_cache中缓存了块,⽽修改的是⽂件中的块。两个块现在不⼀致,清空buffer cache后再次查询测试表。SQL>alter system  flush buffer_cache;
System altered.
SQL>lect*from bbed;
lect*from bbed
*
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 6, block # 157)
ORA-01110: data file6: '/u01/app/oracle/oradata/oracle01/test01.dbf'
校验坏块:
SQL> analyze table bbed validate structure cascade online
2  ;
analyze table bbed validate structure cascade online
*
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 6, block # 157)
ORA-01110: data file6: '/u01/app/oracle/oradata/oracle01/test01.dbf'
rman校验坏块:
[oracle@oracle01 ~]$ rman target /
Recovery Manager: Relea 11.2.0.4.0- Production on Mon May 1316:04:062019 Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights rerved.
connected to target databa: ORACLE01 (DBID=2594375557)
RMAN>backup check logical validate databa;
Starting backup at 13-MAY-19
using target databa control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=27 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=149 device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID=18 device type=DISK
allocated channel: ORA_DISK_4
channel ORA_DISK_4: SID=153 device type=DISK
allocated channel: ORA_DISK_5
channel ORA_DISK_5: SID=30 device type=DISK
allocated channel: ORA_DISK_6
channel ORA_DISK_6: SID=152 device type=DISK
allocated channel: ORA_DISK_7
新年是哪一天channel ORA_DISK_7: SID=20 device type=DISK
allocated channel: ORA_DISK_8
channel ORA_DISK_8: SID=125 device type=DISK
allocated channel: ORA_DISK_9
channel ORA_DISK_9: SID=29 device type=DISK
allocated channel: ORA_DISK_10
channel ORA_DISK_10: SID=146 device type=DISK
allocated channel: ORA_DISK_11
channel ORA_DISK_11: SID=26 device type=DISK
allocated channel: ORA_DISK_12
channel ORA_DISK_12: SID=154 device type=DISK
channel ORA_DISK_1: starting compresd full datafile backup t
channel ORA_DISK_1: specifying datafile(s) in backup t
input datafile file number=00002 name=/u01/app/oracle/oradata/oracle01/sysaux01.dbf channel ORA_DISK_2: starting compresd full datafile backup t
channel ORA_DISK_2: specifying datafile(s) in backup t
input datafile file number=00001 name=/u01/app/oracle/oradata/oracle01/system01.dbf channel ORA_DISK_3: starting compresd full datafile backup t
channel ORA_DISK_3: specifying datafile(s) in backup t
input datafile file number=00005 name=/u01/app/oracle/oradata/oracle01/example01.dbf channel ORA_DISK_4: starting compresd full datafile backup t
channel ORA_DISK_4: specifying datafile(s) in backup t
input datafile file number=00003 name=/u01/app/oracle/oradata/oracle01/undotbs01.dbf channel ORA_DISK_5: starting compresd full datafile backup t
channel ORA_DISK_5: specifying datafile(s) in backup t
including current control file in backup t
channel ORA_DISK_6: starting compresd full datafile backup t
channel ORA_DISK_6: specifying datafile(s) in backup t
input datafile file number=00006 name=/u01/app/oracle/oradata/oracle01/test01.dbf channel ORA_DISK_7: starting compresd full datafile backup t
channel ORA_DISK_7: specifying datafile(s) in backup t
input datafile file number=00007 name=/u01/app/oracle/oradata/oracle01/test101.dbf channel ORA_DISK_8: starting compresd full datafile backup t
channel ORA_DISK_8: specifying datafile(s) in backup t
input datafile file number=00004 name=/u01/app/oracle/oradata/oracle01/urs01.dbf channel ORA_DISK_9: starting compresd full datafile backup t
channel ORA_DISK_9: specifying datafile(s) in backup t
including current SPFILE in backup t
channel ORA_DISK_9: backup t complete, elapd time: 00:00:00
List of Control File and SPFILE
===============================
File Type    Status Blocks Failing Blocks Examined
------------ ------ -------------- ---------------
SPFILE      OK    02
channel ORA_DISK_5: backup t complete, elapd time: 00:00:01
List of Control File and SPFILE
===============================
File Type    Status Blocks Failing Blocks Examined
------------ ------ -------------- ---------------
Control File OK    02166
channel ORA_DISK_7: backup t complete, elapd time: 00:00:03
List of Datafiles
=================
File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
7    OK    01142128010234981
File Name: /u01/app/oracle/oradata/oracle01/test101.dbf

本文发布于:2023-06-30 03:20:17,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/82/1069433.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:数据   检查   页数   坏块   没有   参数   不会   数据库
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图