Wednesday, September 19, 2012

Oracle Database and files corruption checks.



1. Corruption check with RMAN:

With RMAN you can check physical and logical corruptions.

#To check only physical corruptions:
RMAN> BACKUP VALIDATE DATABASE ARCHIVELOG ALL;

#To check both logical and physical corruptions:
 RMAN> BACKUP VALIDATE CHECK LOGICAL DATABASE ARCHIVELOG ALL; 

NOTE! BACKUP VALIDATE does not take real backup it is just checking the files. But you can  use CHECK LOGICAL when you are backuping your database. You can also check backups before restoring them with RESTORE DATABASE VALIDATE or RESTORE ARCHIVELOG ALL VALIDATE;


With RMAN you can also use VALIDATE command without BACKUP. And this gives your more options  for checking and this can also check control and sp files.:

#These check both logical and physical corruptions.
VALIDATE DATABASE;
VALIDATE BACKUPSET <backupset number>;
VALIDATE DATAFILE <datafile_number> BLOCK <block_number>;



2. Corruption check with dbv (DBVERIFY utility):

There is also dbv tool in Oracle server home directory bin folder. And with it you can also check datafile and segment corruptions. dbv finds both physical and logical corruptions.
#Example (there is more options but with this you can get started. Remember that blocksize can vary between databases. You can check it from dba_tablespaces view. (HELP gives all options)):
dbv  file=<filename> blocksize=<blocksize> logfile=<filename>
dbv file=system.dbf blocksize=8192 logfile=corrupt_check.log

And of course you can make for example a shell script where you run this check for all datafiles.

You can use dbv to check certain segments:
dbv segment_id=<segment_id>  logfile=corrupt_check.log


NOTE! Whatever of these tools you are using to check corruptions all findings are added in the 
V$DATABASE_BLOCK_CORRUPTION view.

No comments:

Post a Comment