The first block 0 in an oracle file is the OS block header. No information is found in the database. It records OS information, file size, and other information:
SQL> select file_name,bytes from dba_data_files; FILE_NAME BYTES-------------------------------------------------- ----------/u01/app/oracle/oradata/PROD/user01.dbf 67108864 $ls -lrttotal 1390268-rw-r----- 1 oracle oinstall 67117056 Apr 12 09:31 user01.dbf |
We can see from the above that the size of the OS is a BLOCK larger than that of the database.
If the OS block header is corrupted, it does not affect the opening and use of the database, but an error is reported when the control file is re-created. The Bad blocks cannot be detected using dbverify/rman. However, you can use dbfsize to view them:
Normal status:
$dbfsize user01.dbf Database file: user01.dbfDatabase file type: file systemDatabase file size: 8192 8192 byte blocks |
Damaged:
$dbfsize user01.dbfuser01.dbf: Header block magic number is bad |
Compile BLOCK 0 to simulate damage. It can be started and used properly:
SQL> startup;ORACLE instance started. Total System Global Area 184549376 bytesFixed Size 1266488 bytesVariable Size 100666568 bytesDatabase Buffers 79691776 bytesRedo Buffers 2924544 bytesDatabase mounted.ORA-01113: file 4 needs media recoveryORA-01110: data file 4: '/u01/app/oracle/oradata/PROD/user01.dbf' SQL> recover datafile 4; Media recovery complete.SQL> alter database open; Database altered. SQL> create table test01 tablespace USERS as select * from dba_objects; Table created. |
Dbv check, no bad blocks found:
$dbv file=user01.dbf DBVERIFY: Release 10.2.0.4.0 - Production on Mon Apr 16 16:38:33 2012 Copyright (c) 1982, 2007, Oracle. All rights reserved. DBVERIFY - Verification starting : FILE = user01.dbf DBVERIFY - Verification complete Total Pages Examined : 8192Total Pages Processed (Data) : 357Total Pages Failing (Data) : 0Total Pages Processed (Index): 0Total Pages Failing (Index): 0Total Pages Processed (Other): 11Total Pages Processed (Seg) : 0Total Pages Failing (Seg) : 0Total Pages Empty : 7824Total Pages Marked Corrupt : 0Total Pages Influx : 0Highest block SCN : 336969 (0.336969) |
Check with dbfsize and report the following error:
$dbfsize user01.dbfuser01.dbf: Header block magic number is bad |
If you recreate the control file, an error is returned:
SQL> startup nomount;ORACLE instance started. Total System Global Area 184549376 bytesFixed Size 1266488 bytesVariable Size 100666568 bytesDatabase Buffers 79691776 bytesRedo Buffers 2924544 bytesSQL> CREATE CONTROLFILE REUSE DATABASE "PROD" NORESETLOGS ARCHIVELOG 2 MAXLOGFILES 5 3 MAXLOGMEMBERS 5 4 MAXDATAFILES 100 5 MAXINSTANCES 2 6 MAXLOGHISTORY 292 7 LOGFILE 8 GROUP 1 ( 9 '/u01/app/oracle/oradata/PROD/REDO1_1.log', 10 '/u01/app/oracle/oradata/PROD/REDO1_2.log', 11 '/u01/app/oracle/oradata/PROD/REDO1_3.log' 12 ) SIZE 100M, 13 GROUP 2 ( 14 '/u01/app/oracle/oradata/PROD/REDO2_1.log', 15 '/u01/app/oracle/oradata/PROD/REDO2_2.log', 16 '/u01/app/oracle/oradata/PROD/REDO2_3.log' 17 ) SIZE 100M 18 -- STANDBY LOGFILE 19 DATAFILE 20 '/u01/app/oracle/oradata/PROD/SYSTEM01.dbf', 21 '/u01/app/oracle/oradata/PROD/undotbs01.dbf', 22 '/u01/app/oracle/oradata/PROD/SYSAUX01.dbf', 23 '/u01/app/oracle/oradata/PROD/user01.dbf' 24 CHARACTER SET AL32UTF8 25 ;CREATE CONTROLFILE REUSE DATABASE "PROD" NORESETLOGS ARCHIVELOG*ERROR at line 1:ORA-01503: CREATE CONTROLFILE failedORA-01565: error in identifying file '/u01/app/oracle/oradata/PROD/user01.dbf'ORA-27047: unable to read the header block of fileAdditional information: 2 |
ORA-27047 error reported. In this case, you can resize datafile when the database is on, so that you can overwrite the OS block header information:
SQL> alter database open; Database altered. SQL> alter database datafile '/u01/app/oracle/oradata/PROD/user01.dbf' resize 65M; Database altered. SQL> select file_name,bytes from dba_data_files; FILE_NAME BYTES-------------------------------------------------- ----------/u01/app/oracle/oradata/PROD/user01.dbf 68157440 |
Dbfsize check is normal, and the reconstruction control file is normal:
$dbfsize user01.dbf Database file: user01.dbfDatabase file type: file systemDatabase file size: 8320 8192 byte blocks SQL> CREATE CONTROLFILE REUSE DATABASE "PROD" NORESETLOGS ARCHIVELOG 2 MAXLOGFILES 5 3 MAXLOGMEMBERS 5 4 MAXDATAFILES 100 5 MAXINSTANCES 2 6 MAXLOGHISTORY 292 7 LOGFILE 8 GROUP 1 ( 9 '/u01/app/oracle/oradata/PROD/REDO1_1.log', 10 '/u01/app/oracle/oradata/PROD/REDO1_2.log', 11 '/u01/app/oracle/oradata/PROD/REDO1_3.log' 12 ) SIZE 100M, 13 GROUP 2 ( 14 '/u01/app/oracle/oradata/PROD/REDO2_1.log', 15 '/u01/app/oracle/oradata/PROD/REDO2_2.log', 16 '/u01/app/oracle/oradata/PROD/REDO2_3.log' 17 ) SIZE 100M 18 -- STANDBY LOGFILE 19 DATAFILE 20 '/u01/app/oracle/oradata/PROD/SYSTEM01.dbf', 21 '/u01/app/oracle/oradata/PROD/undotbs01.dbf', 22 '/u01/app/oracle/oradata/PROD/SYSAUX01.dbf', 23 '/u01/app/oracle/oradata/PROD/user01.dbf' 24 CHARACTER SET AL32UTF8 25 ; Control file created. SQL> alter database open; Database altered. |
Note: If the original size of resize is used, an error is returned after reconstruction. You need to resize a different size.