Oracle processing of corrupted data blocks

Source: Internet
Author: User

Have you ever encountered such a situation in actual operations? Sometimes, Oracle data files only damage the relevant data blocks while other items are intact. This is mainly because of intermittent or random I/O errors or memory block errors. In this case, you do not need to restore the entire data file so that the datafile is still online. You can perform the following Oracle operations to process corrupted data blocks.

** After Oracle 9i, you can use the blockrecover command BMR ):

You can use view v $ database_block_corruption uption to obtain information about the damaged data blocks. This view records two types of block upload uption: physical and logical.

@ Physical partition uption: The data block cannot be identified. checksum, header, and footer verification errors

@ Logical partition uption: The Verification of chechsum, header, and footer is correct, but the content of the data block is inconsistent.

Note: BMR cannot be used to restore the logical uption. In the backup command, checksum check is enabled by default and can be disabled by the NOCHECKSUM option attribute. LOGICAL verification is disabled by default. You can add check logical to the backup, restore, recover, and validate commands to enable it.

The specific operation method is as follows:

 
 
  1. rman> blockrecover datafile n1 block n1b1,
    n1b2 datafile n2 block n2b1,n2b2; 

** User-managed backup and recovery methods. If you want to restore the database in which Oracle processes corrupted data, you can only restore the entire data file.

 
 
  1. sql> alter database datafile 2 offline;  
  2. sql> host ‘cp /backup/datafile1.bak /opt/demo/datafile1.dt’;  
  3. sql> recover automatic datafile 2;  
  4. sql> alter database datafile 2 online;  

** If tables with partition uption blocks are not frequently used, you can block these blocks if they are tolerable. This requires the dbms_repair package. The details are as follows:

@ Create repair table used to store damaged block information of tables, table partitions, or indexes ).

 
 
  1. sql> exec dbms_repair.admin_tables
    (’REPAIR_TABLE’, DBMS_REPAIR.REPAIR_TABLE, DBMS_REPAIR.CREATE_ACTION); 

@ Determine the number of corrupted data blocks processed by Oracle

 
 
  1. sql> var cc number  
  2. sql> exec dbms_repair.check_object
    (’TBSPNAME’, ‘TABNAME’, corrupt_count=>:cc);  
  3. sql> print cc  

@ Mark the damaged block.

 
 
  1. sql> var fc number  
  2. sql> exec dbms_repair.fix_corrupt_blocks
    (’TBSPNAME’, ‘TABNAME’,fix_count=>:fc);  
  3. sql> print fc;  

@ Skip damaged blocks. This operation can continue to execute the query SQL statement that involves damaged blocks, skip the blocks, but the error message will still be displayed for DML.

 
 
  1. sql> exec dbms_repair.skip_corrupt_blocks(’TBSPNAME’, ‘TABNAME’); 

@ Confirm the Index Entry pointing to Oracle to process corrupted data blocks. After the damaged blocks of the table are identified above, there may still be indexes pointing to the damaged data blocks in Oracle processing. These indexes are called "isolated key values ". You can use the dbms_repair package to manage the isolated key values:

 
 
  1. sql> exec dbms_repair.admin_tables
    (’ORPHAN_TAB’, DBMS_REPAIR, ORPHAN_TABLE, DBMS_REPAIR, CREATE_ACTION);  
  2. sql> var kc number  
  3. sql> exec dbms_repair.dump_orphar_keys
    (’TBSPNAME’,'INDEXNAME’, orphan_table_name=> ‘ORPHAN_TAB’, key_count=> :kc);  
  4. sql> print kc;  

The above content describes how Oracle processes corrupted data blocks, hoping to help you in this regard.

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.