Repair failure repairing bad blocks

Source: Internet
Author: User
Tags manual flush
Just go to the forum, see a netizen said he broke the block with repair failure repair not, I here also experiment a try

Make a backup before testing
rman> backup Database;
Starting backup at 12-mar-14
Using target database control file instead of recovery catalog
Allocated Channel:ora_disk_1
Channel ora_disk_1:sid=5 Device Type=disk
Channel ora_disk_1:starting full DataFile backup set
Channel ora_disk_1:specifying DataFile (s) in backup set
Input datafile file number=00001 name=/opt/app/oracle/oradata/goolen/system01.dbf
Input datafile file number=00002 name=/opt/app/oracle/oradata/goolen/sysaux01.dbf
Input datafile file number=00003 name=/opt/app/oracle/oradata/goolen/undotbs01.dbf
Input datafile file number=00006 name=/opt/app/oracle/oradata/goolen/goolen01.dbf
Channel ora_disk_1:starting piece 1 at 12-mar-14
Channel ora_disk_1:finished piece 1 at 12-mar-14
Piece Handle=/opt/app/oracle/product/11.2.0/dbs/1rp3029l_1_1 tag=tag20140312t112124 Comment=NONE
Channel Ora_disk_1:backup set complete, elapsed time:00:00:35
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:starting piece 1 at 12-mar-14
Channel ora_disk_1:finished piece 1 at 12-mar-14
Piece Handle=/opt/app/oracle/product/11.2.0/dbs/1sp302ao_1_1 tag=tag20140312t112124 Comment=NONE
Channel Ora_disk_1:backup set complete, elapsed time:00:00:01
Finished backup at 12-mar-14

Create a test table
Sql> CREATE TABLE Scott.rcsy tablespace Goolen as select Empno,ename from Scott.emp where RowNum <=2;
Table created.

Sql> Set Lines 120
Sql> Select Owner,table_name,tablespace_name from dba_tables where owner= ' SCOTT ' and table_name= ' Rcsy ';
OWNER table_name Tablespace_name
------------------------------ ------------------------------ ------------------------------
SCOTT Rcsy Goolen

Sql> Col file_name for A55
Sql> Select File_name,file_id,tablespace_name from dba_data_files where tablespace_name= ' Goolen ';
file_name file_id Tablespace_name
------------------------------------------------------- ---------- ------------------------------
/OPT/APP/ORACLE/ORADATA/GOOLEN/GOOLEN01.DBF 6 Goolen

Sql> Select Dbms_rowid. ROWID_RELATIVE_FNO (ROWID), Dbms_rowid.rowid_block_number (ROWID) block# from Scott.rcsy;
Dbms_rowid. ROWID_RELATIVE_FNO (ROWID) block#
------------------------------------ ----------
6 51
6 51
Now, we're going to destroy block 51st of file number 6th.
[Oracle@localhost xiaoming]$ dd if=/dev/zero of=/opt/app/oracle/oradata/goolen/goolen01.dbf count=1 seek=51 bs=8192 Conv=notrunc
1+0 Records in
1+0 Records out
8192 bytes (8.2 kB) copied, 3.9785e-05 s, 206 MB/s

Sql> select * from Scott.rcsy;
EMPNO ename
---------- ----------
7369 SMITH
7499 ALLEN

Sql> alter system flush Buffer_cache;
System altered.

Query the error again, there are bad blocks
Sql> select * from Scott.rcsy;
SELECT * FROM Scott.rcsy
*
ERROR at line 1:
Ora-01578:oracle data Block corrupted (file # 6, Block # 51)
Ora-01110:data file 6: '/OPT/APP/ORACLE/ORADATA/GOOLEN/GOOLEN01.DBF '

Use Rman to recover this bad block
rman> list failure;
Using target database control file instead of recovery catalog
List of Database Failures
=========================
Failure ID Priority Status Time detected Summary
---------- -------- --------- ------------- -------
8102 High OPEN 12-mar-14 datafile 6: '/opt/app/oracle/oradata/goolen/goolen01.dbf ' contains one or more Corrupt blocks

Rman> advise failure;
List of Database Failures
=========================
Failure ID Priority Status Time detected Summary
---------- -------- --------- ------------- -------
8102 High OPEN 12-mar-14 datafile 6: '/opt/app/oracle/oradata/goolen/goolen01.dbf ' contains one or more Corrupt blocks

Analyzing automatic repair options; This could take some time
Allocated Channel:ora_disk_1
Channel ora_disk_1:sid=5 Device Type=disk
Analyzing Automatic Repair Options complete
Mandatory Manual Actions
========================
No manual actions available
Optional Manual Actions
=======================
No manual actions available
Automated Repair Options
========================
Option Repair Description
------ ------------------
1 Perform Block Media recovery of block Wuyi in file 6
Strategy:the Repair includes complete media recovery with no data loss
Repair Script:/opt/app/oracle/diag/rdbms/goolen/goolen/hm/reco_697173025.hm

rman> repair failure;
Strategy:the Repair includes complete media recovery with no data loss
Repair Script:/opt/app/oracle/diag/rdbms/goolen/goolen/hm/reco_697173025.hm
Contents of repair Script:
# Block Media Recovery
Recover datafile 6 block 51;
Do you really want to execute the above repair (enter YES or NO)? Yes
Executing repair Script
Starting recover at 12-mar-14
Using channel Ora_disk_1
Channel ora_disk_1:restoring block (s)
Channel ora_disk_1:specifying block (s) to restore from backup set
Restoring blocks of datafile 00006
Channel ora_disk_1:reading from backup Piece/opt/app/oracle/product/11.2.0/dbs/1rp3029l_1_1
Channel Ora_disk_1:piece Handle=/opt/app/oracle/product/11.2.0/dbs/1rp3029l_1_1 tag=tag20140312t112124
Channel ora_disk_1:restored block (s) from backup piece 1
Channel Ora_disk_1:block restore complete, elapsed time:00:00:01
Starting Media recovery
Media recovery complete, elapsed time:00:00:01
Finished recover at 12-mar-14
Repair failure complete

Rman> exit

Recovery Manager complete.

Sql> alter system flush Buffer_cache;
System altered.

Sql> select * from Scott.rcsy;
EMPNO ename
---------- ----------
7369 SMITH
7499 ALLEN

Can see our test here can be restored, I guess it is his previous backup set has a problem, or after the recovery is not flush Buffercache, query or may be error



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.