Tuesday, September 8, 2015

Standby Roll forward

When there is a big archivelog gap that has to be applied on the standby database, then it is wise to have to go ahead with a roll forward of the standby.

To get the standby sync with the primary please follow the steps below.


On standby database


SQL> alter database recover managed standby database cancel;

SQL> select current_scn from v$database;

-- If there are no READ ONLY Tablespaces/datafiles in database use the below query to find the current SCN number.
SQL> select min(fhscn) from x$kcvfh;

-- If there are any READ ONLY tablespaced/datafiles in database use the below query to find the current SCN number
SQL> select min(f.fhscn) from x$kcvfh f, v$datafile d
 where f.hxfil =d.file#
and d.enabled != 'READ ONLY' ;

If the output from v$database view and x$kcvfh are different please proceed by taking the SCN number from X$KCVFH view.

Now open a new session of the primary database in a new window.


On Primary database


Go to RMAN to take an incremental backup of the database from the SCN number noted in the standby database.


rman target /

RMAN> run {
2> allocate channel C1 device type disk;
3> backup as compressed backupset incremental from SCN 1966714724 database format '/oracle/backup/tostdby_%U' filesperset=10 tag 'FOR STANDBY';
4> release channel C1;
5> }


Take the control file backup for standby database.

rman> backup current controlfile for standby format '/oracle/backup/cntrltostdby_%U' tag 'FOR STANDBY';

exit from RMAN

navigate to the folder in which the backups are taken

$> cd /oracle/backup

copy the files over to the standby database server using the scp command (or by any command that serves the purpose)

$> scp to* oracle@hostname:/oracle/backup
$> scp cntrl* oralce@hotname:/oracle/backup

once the files are copied over to the standby database server. close the primary session.

On standby database server


Remove the control files

rm /oracle/oradata/cntrl/cntrl*
rm /oracle/cntrl1/cntrl*
rm /oracle/cntrl2/cntrl*

login to sql prompt to shutdown the database and start in nomount to restore the control file in respective locations from the backup taken in primary database server.

sqlplus / as sysdba

SQL> shutdown immediate;

SQL> startup nomount

SQL> exit

$> rman target /

RMAN> restore standby controlfile from '/oracle/backup/cntrlforstandby_rdqffbhg_1_1';

RMAN> sql 'alter database mount standby database';
RMAN> sql 'ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL';

Catalog the backup pieces to the RMAN

RMAN> catalog backuppiece '/oracle/backup/forstandby_qnqff9e6_1_1';
RMAN> catalog backuppiece '/oracle/backup/forstandby_qoqff9tb_1_1';
RMAN> catalog backuppiece '/oracle/backup/forstandby_rbqffalj_1_1';
RMAN> catalog backuppiece '/oracle/backup/forstandby_rcqffb96_1_1';

RMAN> sql 'ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL';

RMAN> run{
2 allocate channel C1 device type disk;
3 recover database noredo;
4 release channel C1;
5 }


RMAN> sql 'ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION';

RMAN> exit

Once every thing is done successfully, please login to the DB and see if the current archivelogs are being applied.

$> sqlplus / as sysdba



SQL> select max(sequence#) from v$archived_log;
SQL> set lines 200;
SQL> select dest_id,status,error from v$archive_dest;
SQL> select PROCESS,PID,STATUS,THREAD#,SEQUENCE# from  v$managed_standby;



No comments:

Post a Comment