Fix Dataguard Archivelog Gap While Archivelog Files Backed Up and Deleted
Fix Dataguard Archivelog Gap While Archivelog Files Backed Up and Deleted
Deleted
Issue Description:
The archivelog files were backed up using RMAN and deleted from the primary database and were not
shipped to the standby database.
Error message in the standby database alert log file will be like this
Issue Solution 1: If you will restore the archivelog files to the default archivelog destination on the
primary
To fix this gap issue you need to restore the missing archivelog files from RMAN backup taken from the
primary database to the default archive log destination and they will be shipped and applied
automatically on the standby database.
Step 1: On the standby database check the missing log sequence numbers causing this gap
Step 2: On the primary database, restore the missing archivelog files from RMAN backup taken
RUN {
CONFIGURE DEFAULT DEVICE TYPE TO DISK;
ALLOCATE CHANNEL t1 TYPE DISK ;
RESTORE ARCHIVELOG FROM logseq=37 UNTIL LOGSEQ=43 thread 1;
RELEASE CHANNEL t1;
}
Step 4: Start the managed standby apply process on the standby database
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT
FROM SESSION;
Step 5: Now check the gap between primary and standby it will be fixed
select al.thrd "Thread", almax "Last Seq Received", lhmax "Last Seq Applied"
from (select thread# thrd, max(sequence#) almax
from v$archived_log
where resetlogs_change#=(select resetlogs_change# from v$database)
group by thread#) al,
(select thread# thrd, max(sequence#) lhmax
from v$log_history
where resetlogs_change#=(select resetlogs_change# from v$database)
group by thread#) lh
where al.thrd = lh.thrd order by "Thread";
Issue Solution 2: If you will restore the archivelog files to a none default archivelog destination on the
primary
Step 1: On the standby database check the missing log sequence numbers causing this gap
select * from v$archive_gap;
Step 2: On the primary database, restore the missing archivelog files from RMAN backup taken to
another destination and in our case we choose /tmp
RUN {
CONFIGURE DEFAULT DEVICE TYPE TO DISK;
ALLOCATE CHANNEL t1 TYPE DISK ;
SET ARCHIVELOG DESTINATION TO '/tmp';
RESTORE ARCHIVELOG FROM logseq=37 UNTIL LOGSEQ=43 thread 1;
RELEASE CHANNEL t1;
}
Step 3: On the primary database, copy the archivelog files restored from RMAN backup to the standby
database
cd /tmp
Step 4: On the standby database register the copied archivelog files in the controlfile
Step 5: On the standby database, start the managed standby apply process on the standby database
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT
FROM SESSION;
Step 6: Now check the gap between primary and standby it will be fixed
select al.thrd "Thread", almax "Last Seq Received", lhmax "Last Seq Applied"
from (select thread# thrd, max(sequence#) almax
from v$archived_log
where resetlogs_change#=(select resetlogs_change# from v$database)
group by thread#) al,
(select thread# thrd, max(sequence#) lhmax
from v$log_history
where resetlogs_change#=(select resetlogs_change# from v$database)
group by thread#) lh
where al.thrd = lh.thrd order by "Thread";