Sunday 8 April 2012

Oracle: How to roll forward standby database using archivelogs

At times oracle standby database may get out of sync with primary database. After fixing the issue causing standby out of sync, we need to roll forward standby database so that it can sync up with primary again.
To roll forward standby database, we can use archivelogs.

1. If the archivelogs are deleted from primary already.
We can restore the archivelogs from backups. Suppose our catdb stores RMAN catalog.
we can use this code to restore the archivelogs.
connect target /
connect catalog catuser/catpass@catdb

RUN {
allocate channel c1 type 'SBT_TAPE' 
parms 'ENV=(NB_ORA_CLIENT=prod1)' maxopenfiles 10;

allocate channel c2 type 'SBT_TAPE'
parms 'ENV=(NB_ORA_CLIENT=prod2)' maxopenfiles 10;
restore archivelog from time 'sysdate - 1' until time 'sysdate';
release channel c1;
release channel c2;
}
Depending on how long the standby has been out of sync, we can change the 'from time' accordingly. 

2. If the archivelogs are still on primary database.
We can simply copy them to the standby database,
after copying archivelogs to the standby, we need to catalog the files copied over.
RMAN> catalog start with '/tmp/logs_from_primary';
Otherwise oracle cannot recognize these files.
 
Once we have the archivelogs, either through method 1 or method 2,
we can roll forward the standby database.
SQL> recover managed standby database disconnect;

No comments:

Post a Comment