How to Recover lost control file in oracle?


  Control file is the most important file in Oracle , if lose one , we are not able to start oracle instance. 
   At least we need to have one control file in order to  successfully start oracle instance. In case you lost your control file,
    In the absence of at least one of the control file(which is registered in parameter file) ,   you will face ORA-00205 (error identifying a control file



     
 To resolve the above error and recover the lost control file we have three different options : 
    
                       Option 1 :-
    If you have a backup/copy the lost control file at hand  and also you   know the previous location and name of the control file, just copy to all locations with the same name as previous one,the copy can be done with OS command or simple copy and  paste following the below steps.


Steps to restore lost control file, to its previous location and previous name:-

1.Shutdown the database


2.Copy the control file to its previous location

3.Shutdown again

4.Startup / startup open
                        
Now you should be able start the instance successfully.

           

But ,  If you don't know the previous name and location , follow the below steps to restore the control file to new location and new name.

 Steps to restore lost control file, to new location and new name:-

1.Shutdown the database

2.Copy or move the control file to the new location

3.Startup nomount and edit the path for the control file in pfile or set the path for control file using alter system (for spfile)

    pfile:-  CONTROL_FILES = (‘u01//app/oradata/ord/control01.ctl’,‘u01//app/oradata/ord/control02.ctl’)
    spfile:-  Alter system set CONTROL_FILES=’u01//app/oradata/ord/control01.ctl’, ’ u01//app/oradata/ord/control02.ctl’ scope=spfile;

4. Shutdown the instance

5. Startup open;


                   Option 2 :-
    If we don't have any copy/backup of the control file at hand , we need to follow this option.
   
   When have no backup of control file, we can create control file manually, provided that we have all information of our db at hand. 

 To create a control file manually we need provide information of datafile, logfile, database name, archive mode and other related info. As follows:

 Steps to create a control file from scratch/manually :

           1. Startup the instance in nomount mode
          2. Run the following command , the path to the files will be different depending on where you placed it:
 
 CREATE CONTROLFILE REUSE DATABASE  "Linktest"  NORESETLOGS archivelog
MAXLOGFILES 5
MAXLOGMEMBERS 3
MAXDATAFILES 10
MAXINSTANCES 1
MAXLOGHISTORY 113
LOGFILE
GROUP 1 'E:\app\dereje.balcha\oradata\Linktest\REDO01.LOG' SIZE 50M,
GROUP 2 'E:\app\dereje.balcha\oradata\Linktest\REDO02.LOG' SIZE 50M,
GROUP 3 'E:\app\dereje.balcha\oradata\Linktest\REDO03.LOG' SIZE 50M
DATAFILE
'E:\app\dereje.balcha\oradata\Linktest\SYSAUX01.DBF' ,
'E:\app\dereje.balcha\oradata\Linktest\SYSTEM01.DBF' ,
'E:\app\dereje.balcha\oradata\Linktest\AUDIT01.DBF' ,
'E:\app\dereje.balcha\oradata\Linktest\EXAMPLE01.DBF' ,
'E:\app\dereje.balcha\oradata\Linktest\UNDOTBS01.DBF' ,
'E:\app\dereje.balcha\oradata\Linktest\USERS01.DBF'   ;

 

N.B. You can generate the above create controlfile statement by running alter database backup control file to trace ; e.g. alter database backup controlfile to trace as ‘e:\controlfile.ctl

Once you executed the above command , the control files will restored to their previous location. 

                 Option 3: RMAN method (only if you have a backup)
 The last option to recover from lost control file is to use RMAN.
 You can use RMAN to recover lost control file, using  the following command,
         RMAN> Restore control file from auto backup; (only if control file autobackup is enabled).
         RMAN> Restore control file from 'e:\CONTROL_FILE_COPY_1019747246.CTL';




 Done!

Thanks !

No comments:

Post a Comment