Use of DBV Tools

Source: Internet
Author: User

DBV is an external command capable of performing integrity checks on physical data structures. DBV can only check the blocks (blocks) of cacheable management, so it can only be used for data files, and block checking of control files and redo log files is not supported. DBV is used for offline or online data files, but also for verifying backup files, but the backup file can only be a copy command of Rman or a data file backed up by the operating system's CP (win copy) command. Check for control files and redo log files can be done with the DBMS_HM package.
DBV has two kinds of command-line interface, one is the data block of validating data file, and the other is verifying segment. The following tests are done separately:
one, the data block of validating data file
In this mode, the database can be in an open or closed state.
[Email protected]>create table Scott.test as SELECT * from Dba_objects where rownum <=100;
Table created.

---Identify the data file and the starting block ID and the number of blocks in the test table
[Email Protected]>select a.file_id,a.block_id,a.blocks,b.name
2 from dba_extents A,v$datafile b
3 where a.file_id=b.file# and a.owner= ' SCOTT ' and a.segment_name= ' TEST ';
file_id block_id BLOCKS NAME
---------- ---------- ---------- ---------------------------------------------
4 520 8/U01/APP/ORACLE/ORADATA/ORCL/USERS01.DBF

---The block where the record in the table is found
[Email protected]>select distinct dbms_rowid.rowid_block_number (ROWID) from Scott.test;
Dbms_rowid. Rowid_block_number (ROWID)
------------------------------------
523
524

---Destroy a recorded block of data
[[email protected] ~]$ dd of=/u01/app/oracle/oradata/orcl/users01.dbf bs=8192 conv=notrunc seek=524 <<eof
> ABCDEFGHICKLMN
> EOF
0+1 Records in
0+1 Records out
Bytes (B) copied, 3.1499e-05 S, 476 kb/s

---execute DBV command to check data file
[Email protected] ~]$ DBV file=/u01/app/oracle/oradata/orcl/users01.dbf blocksize=8192
Dbverify:release 11.2.0.3.0-production on Sat Jan 12 14:45:56 2013

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

Dbverify-verification Starting:file =/u01/app/oracle/oradata/orcl/users01.dbf
Page 524 is marked corrupt---data block 524 marked as bad block
Corrupt block relative dba:0x0100020c (file 4, block 524)
Bad header found during DBV:
Data in bad block:
type:97 Format:2 rdba:0x68676665
Last Change scn:0x6e6d.6c6b6369 seq:0xa flg:0x04
spare1:0x63 spare2:0x64 spare3:0x0
Consistency value in tail:0x65790602
Check value in block header:0x2f5b
Computed Block checksum:0xad06

Dbverify-verification Complete

Total Pages examined:1920
Total Pages processed (Data): 1161
Total Pages Failing (Data): 0
Total Pages processed (Index): 39
Total Pages Failing (Index): 0
Total Pages processed (other): 398
Total Pages processed (SEG): 0
Total Pages Failing (Seg): 0
Total Pages empty:321
Total Pages Marked corrupt:1
Total Pages influx:0
Total Pages encrypted:0
Highest block scn:1205628 (0.1205628)

pages--represents a block of data
Total Pages examined--Indicates the amount of data blocks in a file
Total Pages processed--Indicates the number of data blocks checked
Total Pages failing--Indicates the number of data blocks that failed to check
Total Pages Marked corrupt--indicates corrupted data block
Total Pages influx--represents the number of blocks of data being read and written at the same time. If the database is open, when the DBV runtime reads a block of data multiple times to get a consistent image, but because the database is open, it is possible that the same block of data has a write action while reading, DBV cannot get a consistent chunk image

DBV In addition to the ability to examine the contents of the data block, you can check the empty data block, which fully proves that DBV is the physical level to verify the integrity of the data block.
[[email protected] ~]$ dd of=/u01/app/oracle/oradata/orcl/users01.dbf bs=8192 conv=notrunc seek=526 <<eof
> ABCDEFGHIJKLMN
> EOF
0+1 Records in
0+1 Records out
Bytes (B) copied, 3.0521e-05 s, 491 kb/s

[Email protected] ~]$ DBV file=/u01/app/oracle/oradata/orcl/users01.dbf blocksize=8192

Dbverify:release 11.2.0.3.0-production on Sat Jan 12 15:11:51 2013

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

Dbverify-verification Starting:file =/u01/app/oracle/oradata/orcl/users01.dbf
Page 524 is marked corrupt---data block 524 marked as bad block
Corrupt block relative dba:0x0100020c (file 4, block 524)
Bad header found during DBV:
Data in bad block:
type:97 Format:2 rdba:0x68676665
Last Change scn:0x6e6d.6c6b6369 seq:0xa flg:0x04
spare1:0x63 spare2:0x64 spare3:0x0
Consistency value in tail:0x65790602
Check value in block header:0x2f5b
Computed Block checksum:0xad06

Page 526 is marked corrupt---empty data block 526 is also marked as bad block
Corrupt block relative dba:0x0100020e (file 4, block 526)
Bad header found during DBV:
Data in bad block:
type:97 Format:2 rdba:0x68676665
Last Change scn:0x6e6d.6c6b6a69 seq:0xa flg:0x04
spare1:0x63 spare2:0x64 spare3:0x0
Consistency value in tail:0x64b30601
Check value in block header:0x54c2
Computed Block CHECKSUM:0XA5CD

Dbverify-verification Complete

Total Pages examined:1920
Total Pages processed (Data): 1160
Total Pages Failing (Data): 0
Total Pages processed (Index): 39
Total Pages Failing (Index): 0
Total Pages processed (other): 398
Total Pages processed (SEG): 0
Total Pages Failing (Seg): 0
Total Pages empty:321
Total Pages Marked Corrupt:2
Total Pages influx:0
Total Pages encrypted:0
Highest block scn:1205628 (0.1205628)


DBV can examine ASM-managed data files, but the database requirements are open and the option UserID is used, for example:
DBV userid=system/oracle file=+dataa/orcl/datafile/users01.dbf blocksize=8192

DBV Verify that the Rman backup as Copy command backs up the data file, for example:
rman> Backup as copy datafile 5;

Starting backup at 12-JAN-13
Using target database control file instead of recovery catalog
Allocated Channel:ora_disk_1
Channel ORA_DISK_1:SID=15 Device Type=disk
Channel ora_disk_1:starting datafile Copy
Input datafile file number=00005 name=/u01/app/oracle/oradata/orcl/example01.dbf
Output file name=/u01/app/oracle/fast_recovery_area/orcl/datafile/o1_mf_example_8h22vb6m_.dbf tag= tag20130112t150617 recid=2 stamp=804524793
Channel ora_disk_1:datafile copy complete, elapsed time:00:00:25
Finished backup at 12-JAN-13

[Email protected] ~]$ DBV file=/u01/app/oracle/fast_recovery_area/orcl/datafile/o1_mf_example_8h22vb6m_.dbf

Dbverify:release 11.2.0.3.0-production on Sat Jan 12 15:08:08 2013

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

Dbverify-verification starting:file =/u01/app/oracle/fast_recovery_area/orcl/datafile/o1_mf_example_8h22vb6m_. Dbf

Dbverify-verification Complete

Total Pages examined:44240
Total Pages processed (Data): 6600
Total Pages Failing (Data): 0
Total Pages processed (Index): 1148
Total Pages Failing (Index): 0
Total Pages processed (other): 2841
Total Pages processed (SEG): 0
Total Pages Failing (Seg): 0
Total Pages empty:33651
Total Pages Marked corrupt:0
Total Pages influx:0
Total Pages encrypted:0
Highest block scn:1126464 (0.1126464)

second, verification section
Verify that the database must be in the open state, also need to provide the account with SYSDBA permissions to query, query the command format of the segment such as:
DBV userid=system/oracle Segment_id=tsn.segfile.segblock
tsn--represents the Tablespace ID
segfile--indicates the data file number where the segment header resides
segblock--represents the segment header data block number
These three values can be obtained from the data dictionary sys_dba_segs, and the related columns are tablespace_id, Header_file, and Header_block

[Email Protected]>select tablespace_id,header_file,header_block
2 from Sys_dba_segs
3 where owner= ' SCOTT ' and segment_name= ' TEST ';

tablespace_id Header_file Header_block
------------- ----------- ------------
4 4 522

[Email protected] ~]$ DBV userid=system/oracle segment_id=4.4.522

Dbverify:release 11.2.0.3.0-production on Sat Jan 12 15:26:30 2013

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

Dbverify-verification starting:segment_id = 4.4.522
Page 524 is marked corrupt
Corrupt block relative dba:0x0100020c (file 4, block 524)
Bad header found during DBV:
Data in bad block:
type:97 Format:2 rdba:0x68676665
Last Change scn:0x6e6d.6c6b6369 seq:0xa flg:0x04
spare1:0x63 spare2:0x64 spare3:0x0
Consistency value in tail:0x65790602
Check value in block header:0x2f5b
Computed Block checksum:0xad06

Page 526 is marked corrupt
Corrupt block relative dba:0x0100020e (file 4, block 526)
Bad header found during DBV:
Data in bad block:
type:97 Format:2 rdba:0x68676665
Last Change scn:0x6e6d.6c6b6a69 seq:0xa flg:0x04
spare1:0x63 spare2:0x64 spare3:0x0
Consistency value in tail:0x64b30601
Check value in block header:0x54c2
Computed Block CHECKSUM:0XA5CD

Dbverify-verification Complete

Total Pages Examined:8
Total Pages processed (Data): 3
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:2
Total Pages influx:0
Total Pages encrypted:0
Highest block scn:1205628 (0.1205628)

Third, other
DBV Command Help:
[Email protected] ~]$ DBV

Dbverify:release 11.2.0.3.0-production on Sat Jan 12 15:48:28 2013

Copyright (c) 1982, Oracle and/or its affiliates. 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)
LOGFILE Output Log (NONE)
FEEDBACK Display Progress (0)
Parfile Parameter File (NONE)
USERID Username/password (NONE)
segment_id SEGMENT ID (tsn.relfile.block) (NONE)
HIGH_SCN highest Block SCN to Verify (NONE)
(Scn_wrap.scn_base OR SCN)

Write a script to check multiple data files at once
Save the following script as a dbv_all.sh file.
#!/bin/bash
Datadir=$1
Blocksize=$2
CD $DATADIR
Ls-1 *.dbf | While Read FILE
Do
dBV file= $FILE blocksize= $BLOCKSIZE
Done

The permissions to execute for the script.
[Email protected] ~]$ chmod +x dbv_all.sh

Executes the script.
[Email protected] ~]$/DBV_ALL.SH/U01/APP/ORACLE/ORADATA/ORCL 8192 >> dbv_all.log 2>&1

View the execution results.
[Email protected] ~]$ more Dbv_all.log

Ext.: http://blog.csdn.net/seertan/article/details/8496445

Use of DBV Tools

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.