Saturday 1 September 2018

Restore latest control file from primary database to standby database in oracle

You may need to restore latest controlfile from primary database for any reason  like controlfile data corruption or missing. you find the below steps to follow restore.

--In RMAN, connect to the PRIMARY database and create a standby control file backup:

RMAN> BACKUP CURRENT CONTROLFILE FOR STANDBY FORMAT '/tmp/stdbycontrolfile.ctl';

--Copy the standby control file backup to the STANDBY system(in this example /tmp/stdbycontrolfile.ctl)

--Capture datafile information in STANDBY database.

spool datafile_names.txt
set lines 200
col name format a60
select file#, name from v$datafile order by file# ;
spool off

--From RMAN, connect to STANDBY database and restore the standby control file:

RMAN> SHUTDOWN IMMEDIATE ;
RMAN> STARTUP NOMOUNT;
RMAN> RESTORE STANDBY CONTROLFILE FROM '/tmp/stdbycontrolfile.ctl';

--Shut down the STANDBY database and startup mount:

RMAN> SHUTDOWN IMMEDIATE ;
RMAN> STARTUP MOUNT


--Catalog datafiles and archivelog files in STANDBY if location/name of datafiles is different.

RMAN> CATALOG START WITH '<datafiles_location>';
RMAN> CATALOG START WITH '<arch files location>';


--Start mrp as below.

ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT;