Recovery of Block Corruption by using RMAN util

Recovery of Block Corruption by using  RMAN 

For this we need to simmulate the issue in TEST DB
1) in our case take emp table which is already existed under scott schema and the default tablespace is users
2) try to access the emp table
select count(*) from scott.emp;
 check segemnt header block number
SQL> col SEGMENT_NAME for a20
SQL> select segment_name,header_block,owner from dba_segments where segment_name='EMP'

SEGMENT_NAME         HEADER_BLOCK OWNER
-------------------- ------------ ------------------------------
EMP                           146 SCOTT

3) OS level check datafile status using db verify tool.
oracle@localhost.localdomain:/home/oracle [TESTDB] >dbv file=/u01/app/oracle/oradata/TESTDB/users01.dbf

DBVERIFY: Release 11.2.0.3.0 - Production on Wed Jul 5 23:09:35 2017

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

DBVERIFY - Verification starting : FILE = /u01/app/oracle/oradata/TESTDB/users01.dbf


DBVERIFY - Verification complete

Total Pages Examined         : 2560
Total Pages Processed (Data) : 1758
Total Pages Failing   (Data) : 0
Total Pages Processed (Index): 39
Total Pages Failing   (Index): 0
Total Pages Processed (Other): 461
Total Pages Processed (Seg)  : 0
Total Pages Failing   (Seg)  : 0
Total Pages Empty            : 302
Total Pages Marked Corrupt   : 0
Total Pages Influx           : 0
Total Pages Encrypted        : 0
Highest block SCN            : 1675906 (0.1675906)

4) Now we will simmulate the issue, by corrupting block

oracle@localhost.localdomain:/home/oracle [TESTDB] >dd of=/u01/app/oracle/oradata/TESTDB/users01.dbf bs=8192 conv=notrunc seek=147
<
Hello My Name Sri0+1 records in
0+1 records out
6 bytes (6 B) copied, 34.005 seconds, 0.0 kB/s

Ctrl+C

5) flush buffer cache
SQL> alter system flush buffer_cache;

System altered.
6) check status of emp table
SQL> select * from scott.emp;
select * from scott.emp
                    *
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 4, block # 147)
ORA-01110: data file 4: '/u01/app/oracle/oradata/TESTDB/users01.dbf'
7) again verify OS level check datafile status using db verify tool.
oracle@localhost.localdomain:/home/oracle [TESTDB] >dbv file=/u01/app/oracle/oradata/TESTDB/users01.dbf

DBVERIFY: Release 11.2.0.3.0 - Production on Wed Jul 5 23:48:48 2017

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

DBVERIFY - Verification starting : FILE = /u01/app/oracle/oradata/TESTDB/users01.dbf
Page 147 is marked corrupt
Corrupt block relative dba: 0x01000093 (file 4, block 147)
Bad header found during dbv:
Data in bad block:
 type: 60 format: 4 rdba: 0x01000a46
 last change scn: 0x0000.0018d668 seq: 0x1 flg: 0x04
 spare1: 0x45 spare2: 0x4f spare3: 0x0
 consistency value in tail: 0xd6680601
 check value in block header: 0xde9
 computed block checksum: 0xdbaa



DBVERIFY - Verification complete

Total Pages Examined         : 2560
Total Pages Processed (Data) : 1757
Total Pages Failing   (Data) : 0
Total Pages Processed (Index): 39
Total Pages Failing   (Index): 0
Total Pages Processed (Other): 461
Total Pages Processed (Seg)  : 0
Total Pages Failing   (Seg)  : 0
Total Pages Empty            : 302
Total Pages Marked Corrupt   : 1
Total Pages Influx           : 0
Total Pages Encrypted        : 0
Highest block SCN            : 1675906 (0.1675906)
oracle@localhost.localdomain:/home/oracle [TESTDB] >

8) recover block by using rman utility
oracle@localhost.localdomain:/home/oracle [TESTDB] >rman target /

Recovery Manager: Release 11.2.0.3.0 - Production on Wed Jul 5 23:52:47 2017

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database: TESTDB (DBID=2720074507)

RMAN> blockrecover datafile 4 block 147;

Starting recover at 05-JUL-17
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=40 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=46 device type=DISK

channel ORA_DISK_1: restoring block(s)
channel ORA_DISK_1: specifying block(s) to restore from backup set
restoring blocks of datafile 00004
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/product/11.2.0/dbhome_1/dbs/1rs8ke27_1_1
channel ORA_DISK_1: piece handle=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/1rs8ke27_1_1 tag=TAG20170705T230750
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:04

Finished recover at 05-JUL-17

RMAN>
9) check block recover happend or not 

SQL> select * from scott.emp

     EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
---------- ---------- --------- ---------- --------- ---------- ---------- ----------
      7369 SMITH      CLERK           7902 17-DEC-80        800                    20
      7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300         30
      7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
      7566 JONES      MANAGER         7839 02-APR-81       2975                    20
      7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
      7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
      7782 CLARK      MANAGER         7839 09-JUN-81       2450                    10
      7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
      7839 KING       PRESIDENT            17-NOV-81       5000                    10
      7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
      7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
      7900 JAMES      CLERK           7698 03-DEC-81        950                    30
      7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
      7934 MILLER     CLERK           7782 23-JAN-82       1300                    10

14 rows selected.


Comments

Popular posts from this blog

ORA-01565: error in identifying file '?/dbs/spfile@.ora'

Reboot Exadata Machine

How to combine Oracle .ova files