数据库坏块校验我们通常使用dbv进行校验,Oracle对其解释为
[quote] DBVERIFY is an external command-line utility that performs a physical data structure integrity check. It can be used on offline or online databases, as well on backup files.
DBVERIFY checks are limited to cache-managed blocks (that is, data blocks). Because DBVERIFY is only for use with datafiles, it will not work against control files or redo logs.[/quote]
其限制为(据matalink doc 35512.1描述)
[quote]Limitations and Special Notes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- As DBV performs checks at a block level it cannot detect problems
such as INDEX versus TABLE mismatches which can be detected by the
'ANALYZE TABLE .. VALIDATE STRUCTURE CASCADE' command.
- This utility can ONLY be used against DATA files.
It CANNOT be used to verify redo log files or control files.
- You can use DBV to verify an Automatic Storage Management (ASM) file.
However, the database must be opened and the option USERID has to be used
Example : dbv file=+DG1/ORCL/datafile/system01.dbf userid=system/sys
DBV checks the userid/password for ASM managed files, which is not possible when database is not open.
- On most releases on Unix DBV expects a filename extension.
This means that DBV cannot be used against datafiles with no
filename suffix, or against RAW devices.
The workaround is to create a symbolic link to the raw device where
the link name MUST have an extension.
Eg: ln -s /dev/rdsk/mydevice /tmp/mydevice.dbf
Now use DBV against /tmp/mydevice.dbf
- For RAW devices you should use the END parameter to avoid running
off the end of the Oracle file space.
eg: "dbv FILE=/dev/rdsk/r1.dbf END=<last_block_number>"
If you get the END value too high DBV can report the last page/s of the
file as corrupt as these are beyond the end of the Oracle portion of
the raw device.
You can find value for END from the V$DATAFILE view by dividing the
BYTES value by the database block size.
Eg: To find out the END value to use for file#=5:
SVRMGRL> show parameter db_block_size
NAME TYPE VALUE
----------------------------------- ------- ------
db_block_size integer 2048
SVRMGRL> select BYTES/2048 from v$datafile where FILE#=5;
BYTES/2048
----------
5120
So the command would be:
dbv file=/dev/rdsk/r1.dbf blocksize=2048 END=5120
- DBV may not be able to scan datafiles larger than 2Gb and
may report "DBV-100". This is reported in Bug:710888 for Unix and
Bug:1372172 for 8.1.6 on NT. This problem is platform and release
specific so if you get DBV-100 errors check the filesize first.
- DBV from 8.1.6 onwards may report spurious errors for rollback segment
blocks if the database has been migrated from Oracle7. See Bug:1359160
and Note:118008.1.
- DBV only checks a block in isolation - it does not know if the block
is part of an existing object or not.
- DBV is broken on SCO Unix - see Bug:814249
- DBV of a lower version should not be used against a higher DB version.[/quote]
其使用方法如下
[quote][ora11g@mchz ~]$ dbv
DBVERIFY: Release 11.1.0.6.0 - Production on Sat Nov 20 14:18:38 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)
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)[/quote]
[quote]
[ora11g@mchz ~]$ dbv file=/opt/ora11g/oradata/db11g/sysaux01.dbf
DBVERIFY: Release 11.1.0.6.0 - Production on Sat Nov 20 14:19:21 2010
Copyright (c) 1982, 2007, Oracle. All rights reserved.
DBVERIFY - Verification starting : FILE = /opt/ora11g/oradata/db11g/sysaux01.dbf
DBVERIFY - Verification complete
Total Pages Examined : 124920
Total Pages Processed (Data) : 30843
Total Pages Failing (Data) : 0
Total Pages Processed (Index): 32868
Total Pages Failing (Index): 0
Total Pages Processed (Lob) : 2864
Total Pages Failing (Lob) : 0
Total Pages Processed (Other): 27857
Total Pages Processed (Seg) : 0
Total Pages Failing (Seg) : 0
Total Pages Empty : 30488
Total Pages Marked Corrupt : 0
Total Pages Influx : 0
Total Pages Encrypted : 0
Highest block SCN : 32211870 (0.32211870)[/quote]
但我们也可以使用rman进性坏块校验,提供的信息相对于dbv更加直观,若有坏块,校验结果将存在v$database_block_corruption中。如果数据库处于归档模式,且有有效全备份,即可以通过block recover corruption list进行恢复。需要提醒的是[color=red]rman校验数据库非归档模式也支持。
[/color]
[quote]RMAN> backup validate database;
Starting backup at 20-NOV-10
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00002 name=/opt/ora11g/oradata/db11g/sysaux01.dbf
input datafile file number=00001 name=/opt/ora11g/oradata/db11g/system01.dbf
input datafile file number=00003 name=/opt/ora11g/oradata/db11g/undotbs01.dbf
input datafile file number=00004 name=/opt/ora11g/oradata/db11g/users01.dbf
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:55
List of Datafiles
=================
File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
1 OK 0 12503 90880 32211897
File Name: /opt/ora11g/oradata/db11g/system01.dbf
Block Type Blocks Failing Blocks Processed
---------- -------------- ----------------
Data 0 64333
Index 0 11434
Other 0 2610
File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
2 OK 0 30488 124920 32211870
File Name: /opt/ora11g/oradata/db11g/sysaux01.dbf
Block Type Blocks Failing Blocks Processed
---------- -------------- ----------------
Data 0 30843
Index 0 32868
Other 0 30721
File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
3 OK 0 1 32000 32211897
File Name: /opt/ora11g/oradata/db11g/undotbs01.dbf
Block Type Blocks Failing Blocks Processed
---------- -------------- ----------------
Data 0 0
Index 0 0
Other 0 31999
File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
4 OK 0 557 640 31714940
File Name: /opt/ora11g/oradata/db11g/users01.dbf
Block Type Blocks Failing Blocks Processed
---------- -------------- ----------------
Data 0 30
Index 0 3
Other 0 50
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
List of Control File and SPFILE
===============================
File Type Status Blocks Failing Blocks Examined
------------ ------ -------------- ---------------
SPFILE OK 0 2
Control File OK 0 594
Finished backup at 20-NOV-10[/quote]
[quote] DBVERIFY is an external command-line utility that performs a physical data structure integrity check. It can be used on offline or online databases, as well on backup files.
DBVERIFY checks are limited to cache-managed blocks (that is, data blocks). Because DBVERIFY is only for use with datafiles, it will not work against control files or redo logs.[/quote]
其限制为(据matalink doc 35512.1描述)
[quote]Limitations and Special Notes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- As DBV performs checks at a block level it cannot detect problems
such as INDEX versus TABLE mismatches which can be detected by the
'ANALYZE TABLE .. VALIDATE STRUCTURE CASCADE' command.
- This utility can ONLY be used against DATA files.
It CANNOT be used to verify redo log files or control files.
- You can use DBV to verify an Automatic Storage Management (ASM) file.
However, the database must be opened and the option USERID has to be used
Example : dbv file=+DG1/ORCL/datafile/system01.dbf userid=system/sys
DBV checks the userid/password for ASM managed files, which is not possible when database is not open.
- On most releases on Unix DBV expects a filename extension.
This means that DBV cannot be used against datafiles with no
filename suffix, or against RAW devices.
The workaround is to create a symbolic link to the raw device where
the link name MUST have an extension.
Eg: ln -s /dev/rdsk/mydevice /tmp/mydevice.dbf
Now use DBV against /tmp/mydevice.dbf
- For RAW devices you should use the END parameter to avoid running
off the end of the Oracle file space.
eg: "dbv FILE=/dev/rdsk/r1.dbf END=<last_block_number>"
If you get the END value too high DBV can report the last page/s of the
file as corrupt as these are beyond the end of the Oracle portion of
the raw device.
You can find value for END from the V$DATAFILE view by dividing the
BYTES value by the database block size.
Eg: To find out the END value to use for file#=5:
SVRMGRL> show parameter db_block_size
NAME TYPE VALUE
----------------------------------- ------- ------
db_block_size integer 2048
SVRMGRL> select BYTES/2048 from v$datafile where FILE#=5;
BYTES/2048
----------
5120
So the command would be:
dbv file=/dev/rdsk/r1.dbf blocksize=2048 END=5120
- DBV may not be able to scan datafiles larger than 2Gb and
may report "DBV-100". This is reported in Bug:710888 for Unix and
Bug:1372172 for 8.1.6 on NT. This problem is platform and release
specific so if you get DBV-100 errors check the filesize first.
- DBV from 8.1.6 onwards may report spurious errors for rollback segment
blocks if the database has been migrated from Oracle7. See Bug:1359160
and Note:118008.1.
- DBV only checks a block in isolation - it does not know if the block
is part of an existing object or not.
- DBV is broken on SCO Unix - see Bug:814249
- DBV of a lower version should not be used against a higher DB version.[/quote]
其使用方法如下
[quote][ora11g@mchz ~]$ dbv
DBVERIFY: Release 11.1.0.6.0 - Production on Sat Nov 20 14:18:38 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)
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)[/quote]
[quote]
[ora11g@mchz ~]$ dbv file=/opt/ora11g/oradata/db11g/sysaux01.dbf
DBVERIFY: Release 11.1.0.6.0 - Production on Sat Nov 20 14:19:21 2010
Copyright (c) 1982, 2007, Oracle. All rights reserved.
DBVERIFY - Verification starting : FILE = /opt/ora11g/oradata/db11g/sysaux01.dbf
DBVERIFY - Verification complete
Total Pages Examined : 124920
Total Pages Processed (Data) : 30843
Total Pages Failing (Data) : 0
Total Pages Processed (Index): 32868
Total Pages Failing (Index): 0
Total Pages Processed (Lob) : 2864
Total Pages Failing (Lob) : 0
Total Pages Processed (Other): 27857
Total Pages Processed (Seg) : 0
Total Pages Failing (Seg) : 0
Total Pages Empty : 30488
Total Pages Marked Corrupt : 0
Total Pages Influx : 0
Total Pages Encrypted : 0
Highest block SCN : 32211870 (0.32211870)[/quote]
但我们也可以使用rman进性坏块校验,提供的信息相对于dbv更加直观,若有坏块,校验结果将存在v$database_block_corruption中。如果数据库处于归档模式,且有有效全备份,即可以通过block recover corruption list进行恢复。需要提醒的是[color=red]rman校验数据库非归档模式也支持。
[/color]
[quote]RMAN> backup validate database;
Starting backup at 20-NOV-10
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00002 name=/opt/ora11g/oradata/db11g/sysaux01.dbf
input datafile file number=00001 name=/opt/ora11g/oradata/db11g/system01.dbf
input datafile file number=00003 name=/opt/ora11g/oradata/db11g/undotbs01.dbf
input datafile file number=00004 name=/opt/ora11g/oradata/db11g/users01.dbf
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:55
List of Datafiles
=================
File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
1 OK 0 12503 90880 32211897
File Name: /opt/ora11g/oradata/db11g/system01.dbf
Block Type Blocks Failing Blocks Processed
---------- -------------- ----------------
Data 0 64333
Index 0 11434
Other 0 2610
File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
2 OK 0 30488 124920 32211870
File Name: /opt/ora11g/oradata/db11g/sysaux01.dbf
Block Type Blocks Failing Blocks Processed
---------- -------------- ----------------
Data 0 30843
Index 0 32868
Other 0 30721
File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
3 OK 0 1 32000 32211897
File Name: /opt/ora11g/oradata/db11g/undotbs01.dbf
Block Type Blocks Failing Blocks Processed
---------- -------------- ----------------
Data 0 0
Index 0 0
Other 0 31999
File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
4 OK 0 557 640 31714940
File Name: /opt/ora11g/oradata/db11g/users01.dbf
Block Type Blocks Failing Blocks Processed
---------- -------------- ----------------
Data 0 30
Index 0 3
Other 0 50
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
List of Control File and SPFILE
===============================
File Type Status Blocks Failing Blocks Examined
------------ ------ -------------- ---------------
SPFILE OK 0 2
Control File OK 0 594
Finished backup at 20-NOV-10[/quote]