Wednesday, June 23, 2010

Recovery senario when database is in BEGIN backup mode ( recovery started by recover database until cancel )

Recovery senario when database is in BEGIN backup mode ( recovery started by recover database until cancel )

Think Database was in begin backup mode , database crashed or brought down by DBA with out turn of tablespace to end backup.
During database startup database will go for recovery with out checking datafiles in backup mode DBA Will start recovery using below recovery command.


recover database until cancel;

After applying all archive logfiles and redolog files, Database will not open , Since recovery command used until cancel DBA need to open with open resetlogs. Opening database with resetlogs will make DG/DR need to rebuild and old backups will become nomore valid.

How to resolve this issues with out using alter database open resetlogs ?;
Answer
========
This is one of the challenging status for DBA to test his skill set. Please follow below methode to fix issue.

Database is in mount state.

1. First turn off all datafiles to end backup using below command.

alter database datafile end backup;


2. alter database backup controlfile to trace;

3. Go to udump and open trace file generated by above command.

4. Just recreate control file using below entry changes in trace file create control file script.

NORESETLOGS
ARCHIVELOG

Example
========

CREATE CONTROLFILE REUSE DATABASE "RECOBASE" NORESETLOGS ARCHIVELOG

5. try to open database .

6. Some times database may ask for recovery ( because datafile header seqence will be overwitten by last sequence ) and just issue.

7. if database goes for recovery

recover database ;

8 alter database open ;

this methode will save both DG and old backup.

Lesson lernt.

Below recovery is used only for incomplete recovery only in critical situation like hot backup restoration will be issued below commands.

recover database until cancel ;

recover database until cancel using by backup control file;

Recovery Senario using datafiles of standby

Recovery senario
=====================
Think Database is having having backup copy which is not valid and DG/DR is there which is not in sync with production database.

Around 10 to 15 datafiles located in perticular vg/mount point is corrupted due to hardware error.

How to handle this senario ?


Solution
===========

1. If Database is not having any nologging objects try to sync up DG by applying all archive logfiles and carryout switch over process and start using DG as production database.

2. IF Database is having nologging objects i.e index try to sync up DG by applying all archive logfiles and carryout switch over process and start using DG as production database. After switch over recreate all indexes will fix issue.

3. Else copy Datafiles from DG/DR to production database and start recovery will also help to recover database. In this methode if objects are loaded with nologging option will loose data.

Hence before building DG enable forced login in all critical database which will helps all recovery senarios.