Recover from datafile block corruption leveraging physical standby
Here are the steps I used to recover my primary database by leveraging a Dataguard environment.
## on standby
1. stop managed recovery on standby.
SQL> alter database recover managed standby database cancel;
2. Backup as a copy of the datafile from standby.
RMAN> backup as copy datafile 2 format '/app/oracle/temp/sysaux_01.dbf';
3. SCP the backup copy of the datafile to the primary database server.
scp /app/oracle/temp/sysaux_01.dbf <target_server>:/app/oracle/temp
## on primary
4. Take corrupt datafile offline.
SQL> alter database datafile 2 offline;
5. Catalog datafile to the primary database so the controlfile knows about it.
RMAN> catalog datafilecopy '/app/oracle/temp/sysaux_01.dbf';
6. Restore and recover the datafile in question.
RMAN> restore datafile 2;
RMAN> recover datafile 2;
7. Bring the datafile back online.
SQL> alter database datafile 2 online;
8. Validate that the corruption is no longer present.
RMAN> validate check logical datafile 2;
SQL> select * from v$database_block_corruption;
## on standby
1. stop managed recovery on standby.
SQL> alter database recover managed standby database cancel;
2. Backup as a copy of the datafile from standby.
RMAN> backup as copy datafile 2 format '/app/oracle/temp/sysaux_01.dbf';
3. SCP the backup copy of the datafile to the primary database server.
scp /app/oracle/temp/sysaux_01.dbf <target_server>:/app/oracle/temp
## on primary
4. Take corrupt datafile offline.
SQL> alter database datafile 2 offline;
5. Catalog datafile to the primary database so the controlfile knows about it.
RMAN> catalog datafilecopy '/app/oracle/temp/sysaux_01.dbf';
6. Restore and recover the datafile in question.
RMAN> restore datafile 2;
RMAN> recover datafile 2;
7. Bring the datafile back online.
SQL> alter database datafile 2 online;
8. Validate that the corruption is no longer present.
RMAN> validate check logical datafile 2;
SQL> select * from v$database_block_corruption;
Comments