http://blog.csdn.net/leshami/article/details/6530890
DBVERIFY 工具的使用
Oracle 数据库运行过程中由于硬件故障或操作系统故障导致导致Oracle无法以Oracle格式来识别或所包含的内容即为出现数据块损坏故障,这个坏块可以分为介质损坏以及逻辑损坏 。下面给出了块的检查,以及使用DBVERIFY 工具实施块检查。
一、块检查
1.何时检查块
当一个数据块被读或写的时候,将对块的进行一致性检查,检查的内容包括如下:
块的版本
比较块在cache与block buffer中的数据块地址
根据要求进行校验(checksum)
2.损坏的数据块的错误提示
可以从告警日志文件中找到该错误 提示,以及在会话中发现损坏的数 据块时也会给出类似的提示
ORA-01578: ORACLE data block corrupted (file # 6, block # 11)
ORA-01110: data file 6: '/u01/app/oracle/oradata/orcl/tbs01.dbf'
3.与块损坏的相关特性(几种检查工具)
---------------------------------------------------------------------
特性 坏块侦测类型 能否修复损坏块
----------------------------------------------------------------------
DBVERIFY 物理 否
ANALYZE 逻辑 否
DB_BLOCK_CHECKING 逻辑 否
DB_BLOCK_CHECKSUM 物理 否
exp 物理 否
FlashBack 逻辑 是
DBMS_REPAIR 逻辑 是
Block media recovery 未知 是
bbed(verify命令) 未知 否
二、DBVERIFY工具介绍
特性:
是一个运行于操作系统提示符下的外部程序,用于验证数据文件,检查块的一致性错误
仅仅针对数据文件,能够校验open阶段的数据文件以及shutdown状态下的数据文件
可以验证复制的数据文件,也可以验证备份的镜像副本
不支持联机日志文件,控制文件,归档日志,RMAN备份集验证
被验证的文件可以位于文件系统,ASM磁盘或原始设备
在Unix系统中位于:$ORACLE_HOME/bin/dbv
在Windows系统中位于:%ORACLE_HOME%/bin/dbv.exe
对于DBVERIFY工具,高版本可以自动识别低版本数据库,比如11g的dbv访问9i的数据库,但是低版本的dbv访问高版本会报错
三、DBVERIFY工具用法
1.获取dbv的帮助信息,直接在提示符下输入dbv即可 或者输入dbv help=y
[oracle@oradb orcl]$ dbv
DBVERIFY: Release 10.2.0.4.0 - Production on Tue Oct 26 18:21:09 2010
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Keyword Description (Default)
----------------------------------------------------
FILE File to Verify (NONE)
START Start Block (First Block of File)
END End Block (Last Block of File)
BLOCKSIZE Logical Block Size (8192) --指定数据文件的尺寸,缺省值为8192,对于非8192块将收到DBV-00103错误
LOGFILE Output Log (NONE) --用于显示验证进度
FEEDBACK Display Progress (0)
PARFILE Parameter File (NONE) --可以指定参数文件
USERID Username/Password (NONE) --校验段、ASM文件需要使用
SEGMENT_ID Segment ID (tsn.relfile.block) (NONE) --校验段,需要表空间ID,数据文件ID,段的头部ID
HIGH_SCN Highest Block SCN To Verify (NONE)
(scn_wrap.scn_base OR scn)
2.校验online,offline数据文件,使用下面的方法: dbv file=
[oracle@oradb orcl]$ dbv file=$ORACLE_BASE/oradata/orcl/tbs01.dbf
DBVERIFY: Release 10.2.0.4.0 - Production on Tue Oct 26 18:29:39 2010
Copyright (c) 1982, 2007, Oracle. All rights reserved.
DBVERIFY - Verification starting : FILE = /u01/app/oracle/oradata/orcl/tbs01.dbf
DBVERIFY - Verification complete
Total Pages Examined : 128 --校验的总页面数,一个页面即是一个数据块
Total Pages Processed (Data) : 96 --已处理的数据页面数
Total Pages Failing (Data) : 0 --已处理数据页面的失败数
Total Pages Processed (Index): 1 --已处理的索引页面数
Total Pages Failing (Index): 0 --已处理索引页面失败数
Total Pages Processed (Other): 31 --已处理的其它页面数
Total Pages Processed (Seg) : 0
Total Pages Failing (Seg) : 0
Total Pages Empty : 0
Total Pages Marked Corrupt : 0
Total Pages Influx : 0
Highest block SCN : 1152518 (0.1152518)
注意:如果Total Pages Influx的值大于零,且未存在坏块的情况下,是由于针对open状态的文件运行dbv 程序遇到了一个当前正在被DBWn进程写入的数据块
[oracle@oradb orcl]$ dbv file=$ORACLE_BASE/oradata/orcl/tbs01.dbf feedback=1000
上面这句在执行时每验证1000个块将显示一个"."号
[oracle@wang ~]$ dbv FILE=/u01/app/oracle/oradata/DBdb/users01.dbf FEEDBACK=1000
DBVERIFY: Release 11.2.0.4.0 - Production on Mon Nov 27 18:09:26 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
DBVERIFY - Verification starting : FILE = /u01/app/oracle/oradata/DBdb/users01.dbf
Page 526 is marked corrupt
Corrupt block relative dba: 0x0100020e (file 4, block 526)
Bad check value found during dbv:
Data in bad block:
type: 6 format: 2 rdba: 0x0100020e
last change scn: 0x0000.00396631 seq: 0x1 flg: 0x06
spare1: 0x0 spare2: 0x0 spare3: 0x0
consistency value in tail: 0x66310601
check value in block header: 0xb29f
computed block checksum: 0x3b0c
DBV-00200: Block, DBA 16777783, already marked corrupt
csc(0x0000.001082b4) higher than block scn(0x0000.00000000)
Page 567 failed with check code 6054
................................................................................
DBVERIFY - Verification complete
Total Pages Examined : 391520
Total Pages Processed (Data) : 239410
Total Pages Failing (Data) : 0
Total Pages Processed (Index): 55722
Total Pages Failing (Index): 1
Total Pages Processed (Other): 73037
Total Pages Processed (Seg) : 0
Total Pages Failing (Seg) : 0
Total Pages Empty : 23350
Total Pages Marked Corrupt : 2
Total Pages Influx : 0
Total Pages Encrypted : 0
Highest block SCN : 3784055 (0.3784055)
[oracle@wang ~]$
3.验证指定段(例如表)
该方法需要获得段所在表空间的ID,段所在数据文件的ID,段的头部ID,如下:
SQL> select owner,tablespace_id,tablespace_name,header_file,header_block from sys_dba_segs where segment_name='JOBS';
OWNER TABLESPACE_ID TABLESPACE_NAME HEADER_FILE HEADER_BLOCK
------------------------------ ------------- ------------------------------ ----------- ------------
SCOTT 4 USERS 4 1082
注意:sys用户的段可以查询sys_user_segs ,而普通用户的段信息,需要查询sys_dba_segs
[oracle@wang ~]$ dbv USERID=scott/tiger segment_id=4.4.1082
DBVERIFY: Release 11.2.0.4.0 - Production on Mon Nov 27 18:22:07 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
DBVERIFY - Verification starting : SEGMENT_ID = 4.4.1082
DBVERIFY - Verification complete
Total Pages Examined : 8
Total Pages Processed (Data) : 1
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 : 4
Total Pages Marked Corrupt : 0
Total Pages Influx : 0
Total Pages Encrypted : 0
Highest block SCN : 1388330 (0.1388330)
[oracle@wang ~]$
4.验证复制的数据文件或验证备份的镜像副本
--使用RMAN备份镜像副本
RMAN> backup as copy datafile 5;
Starting backup at 27-NOV-17
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00005 name=/u01/app/oracle/oradata/DBdb/example01.dbf
output file name=/u01/app/oracle/fast_recovery_area/DBDB/datafile/o1_mf_example_f1qtvfph_.dbf tag=TAG20171127T183941 RECID=2 STAMP=961180797
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25
Finished backup at 27-NOV-17
RMAN>
--校验:
[oracle@wang ~]$ dbv file=/u01/app/oracle/fast_recovery_area/DBDB/datafile/o1_mf_example_f1qtvfph_.dbf
DBVERIFY: Release 11.2.0.4.0 - Production on Mon Nov 27 18:40:44 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
DBVERIFY - Verification starting : FILE = /u01/app/oracle/fast_recovery_area/DBDB/datafile/o1_mf_example_f1qtvfph_.dbf
DBVERIFY - Verification complete
Total Pages Examined : 43360
Total Pages Processed (Data) : 6597
Total Pages Failing (Data) : 0
Total Pages Processed (Index): 1149
Total Pages Failing (Index): 0
Total Pages Processed (Other): 2844
Total Pages Processed (Seg) : 0
Total Pages Failing (Seg) : 0
Total Pages Empty : 32770
Total Pages Marked Corrupt : 0
Total Pages Influx : 0
Total Pages Encrypted : 0
Highest block SCN : 1795627 (0.1795627)
[oracle@wang ~]$
--注意
RMAN命令中的BACKUP VALIDATE DATABASE命令通常用于检查全库,该命令不产生任何备份集,可以通过Validate命令来检查是否能备份,如数据文件是否存在,是否存在坏块不能被备份,查询视图v$database_block_corruption,此视图将检查过程中存在的坏块
如使用下面的查询
RMAN> backup validate database;
RMAN> backup validate database archivelog all;
SQL> select * from v$database_block_corruption;
no rows selected
视图v$database_block_corruption将列出损坏的坏块所在的文件位置,损坏块的起始位置,损坏快的大小以及损坏类型如果上述视图中发现了坏块,则可以通过SQL查询获得坏块所影响的范围,以及确定坏块所影响的是索引段还是UNDO段
select owner,segment_name,segment_type from dba_extents where file_id= and between block_id and block_id+blocks-1;
(和分别是ORA-01578报出的坏块出现的文件号和块号)
下面使用rman 来修复受损的数据块
RMAN> run{
allocate channel ch2 device type disk;
blockrecover datafile 6 block 37;
release channel ch2;}
省略.................
四、其它
1.事实上使用dbv工具可以对控制文件进行验证(数据库处于OPEN状态),参见下面的例子
[oracle@wang ~]$ dbv file=/u01/app/oracle/oradata/DBdb/control01.ctl
DBVERIFY: Release 11.2.0.4.0 - Production on Mon Nov 27 18:48:48 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
DBV-00103: Specified BLOCKSIZE (8192) differs from actual (16384)
[oracle@wang ~]$
[oracle@wang ~]$ dbv file=/u01/app/oracle/oradata/DBdb/control01.ctl BLOCKSIZE=16384
DBVERIFY: Release 11.2.0.4.0 - Production on Mon Nov 27 18:49:11 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
DBVERIFY - Verification starting : FILE = /u01/app/oracle/oradata/DBdb/control01.ctl
DBVERIFY - Verification complete
Total Pages Examined : 604
Total Pages Processed (Data) : 0
Total Pages Failing (Data) : 0
Total Pages Processed (Index): 0
Total Pages Failing (Index): 0
Total Pages Processed (Other): 59
Total Pages Processed (Seg) : 0
Total Pages Failing (Seg) : 0
Total Pages Empty : 545
Total Pages Marked Corrupt : 0
Total Pages Influx : 0
Total Pages Encrypted : 0
Highest block SCN : 11504 (65535.11504)
[oracle@wang ~]$
2.对联机日志文件的验证(数据库处于OPEN状态),不支持
--可以执行,但出现下面很多的提示(介质错误)
[oracle@wang ~]$ dbv file=/u01/app/oracle/oradata/DBdb/redo01.log
DBVERIFY: Release 11.2.0.4.0 - Production on Mon Nov 27 18:51:19 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
DBV-00103: Specified BLOCKSIZE (8192) differs from actual (512)
[oracle@wang ~]$
[oracle@wang ~]$ dbv file=/u01/app/oracle/oradata/DBdb/redo01.log BLOCKSIZE=512
省略。。。。。。。。。。。。。。。。。。
Page 35627 is marked corrupt
Corrupt block relative dba: 0x00008b2b (file 0, block 35627)
Bad header found during dbv:
Data in bad block:
type: 1 format: 2 rdba: 0x00008b2b
last change scn: 0x801c.0000034c seq: 0x99 flg: 0xc2
spare1: 0x0 spare2: 0x0 spare3: 0x38
consistency value in tail: 0x0001040a
check value in block header: 0x1f4
block checksum disabled
Page 35628 is influx - most likely media corrupt
Corrupt block relative dba: 0x00008b2c (file 0, block 35628)
Fractured block found during dbv:
Data in bad block:
type: 1 format: 2 rdba: 0x00008b2c
last change scn: 0x8044.0000034c seq: 0xa2 flg: 0x11
spare1: 0x0 spare2: 0x0 spare3: 0x0
consistency value in tail: 0x000201f4
check value in block header: 0x2
block checksum disabled
Page 35629 is influx - most likely media corrupt
Corrupt block relative dba: 0x00008b2d (file 0, block 35629)
Fractured block found during dbv:
Data in bad block:
type: 1 format: 2 rdba: 0x00008b2d
last change scn: 0x80a8.0000034c seq: 0x46 flg: 0xcd
spare1: 0x0 spare2: 0x0 spare3: 0x0
consistency value in tail: 0x00395909
check value in block header: 0x19b9
computed block checksum: 0x0
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。