Steps to recreate standby log files in Data Guard

If the real-time apply feature is enabled, log apply services can apply redo data as it is received, without waiting for the current standby redo log file to be archived. This results in faster switchover and failover times because the standby redo log files have been applied already to the standby database by the time the failover or switchover begins.

# both primary and standby db

select group#, bytes/1024/1024, status, first_time, next_time
from v$standby_log;

GROUP# BYTES/1024/1024 STATUS FIRST_TIME NEXT_TIME
---------- --------------- ---------- ------------------- -------------------
7 100 UNASSIGNED
8 100 UNASSIGNED
9 100 UNASSIGNED
10 100 UNASSIGNED
11 100 UNASSIGNED

col member for a60
select group#, type, member from v$logfile;

select * from v$dataguard_stats;

NAME VALUE UNIT TIME_COMPUTED DATUM_TIME
-------------------------------- -------------------- ------------------------------ ------------------------------ ------------------------------
transport lag +00 00:00:00 day(2) to second(0) interval 03/17/2016 14:28:56 03/17/2016 14:28:55
apply lag +00 02:33:52 day(2) to second(0) interval 03/17/2016 14:28:56 03/17/2016 14:28:55
apply finish time +00 00:00:00.001 day(2) to second(3) interval 03/17/2016 14:28:56
estimated startup time 10 second 03/17/2016 14:28:56

— primary db

alter system set log_archive_dest_state_2 = defer scope = memory;

— standby db

alter database recover managed standby database cancel;

— primary db, make sure redo logs are not transfered to standby

alter system archive log current;

— drop standby redologs in standby and primary

alter database drop standby logfile group 7;
alter database drop standby logfile group 8;
alter database drop standby logfile group 9;
alter database drop standby logfile group 10;
alter database drop standby logfile group 11;

— recreate the standby redologs in standby

alter database add standby logfile thread 1 group 7 ('/oradata/KOBRASTD/onlinelog/stlog7.log') size 100M reuse;
alter database add standby logfile thread 1 group 8 ('/oradata/KOBRASTD/onlinelog/stlog8.log') size 100M reuse;
alter database add standby logfile thread 1 group 9 ('/oradata/KOBRASTD/onlinelog/stlog9.log') size 100M reuse;
alter database add standby logfile thread 1 group 10 ('/oradata/KOBRASTD/onlinelog/stlog10.log') size 100M reuse;
alter database add standby logfile thread 1 group 11 ('/oradata/KOBRASTD/onlinelog/stlog11.log') size 100M reuse;
alter database add standby logfile thread 1 group 12 ('/oradata/KOBRASTD/onlinelog/stlog12.log') size 100M reuse;

— recreate the standby redologs in primary

alter database add standby logfile thread 1 group 7 ('/oradata/KOBRAPRI/onlinelog/stlog7.log') size 100M reuse;
alter database add standby logfile thread 1 group 8 ('/oradata/KOBRAPRI/onlinelog/stlog8.log') size 100M reuse;
alter database add standby logfile thread 1 group 9 ('/oradata/KOBRAPRI/onlinelog/stlog9.log') size 100M reuse;
alter database add standby logfile thread 1 group 10 ('/oradata/KOBRAPRI/onlinelog/stlog10.log') size 100M reuse;
alter database add standby logfile thread 1 group 11 ('/oradata/KOBRAPRI/onlinelog/stlog11.log') size 100M reuse;
alter database add standby logfile thread 1 group 12 ('/oradata/KOBRAPRI/onlinelog/stlog12.log') size 100M reuse;

— enable log transport from primary db

alter system set log_archive_dest_state_2 = enable scope = both;

— start managed recovery from the standby db with real-time apply

alter database recover managed standby database using current logfile disconnect;

select * from v$dataguard_stats;

NAME VALUE UNIT TIME_COMPUTED DATUM_TIME
-------------------------------- -------------------- ------------------------------ ------------------------------ ------------------------------
transport lag +00 00:00:00 day(2) to second(0) interval 03/17/2016 15:07:27 03/17/2016 15:07:26
apply lag +00 00:00:00 day(2) to second(0) interval 03/17/2016 15:07:27 03/17/2016 15:07:26
apply finish time +00 00:00:00.000 day(2) to second(3) interval 03/17/2016 15:07:27
estimated startup time 10 second
Advertisements

2 thoughts on “Steps to recreate standby log files in Data Guard

  1. The question that always gets me though, is what needs to be done via dgmgrl when you do actions such as the above. Disable configuration? Disable database? Set state apply and transport off? What is best?

    Like

    1. Hi Matt,

      I believe setting off apply and redo transport is the correct answer.

      Anyway, you must be clear about what happened under the scene when you execute commands in dgmgrl. The CLI Reference may be a good point to start with.

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s