Should your Streams archived log downstream capture environment suffer network outages, causing Log Transport Services to fail, archive log gaps may occur. Streams cannot always resolve gaps automatically depending on the length and frequency of the network outage. In such cases, Streams will fail to mine the “new” archived log files shipped from the source database.
In such a situation it is important to detect and resolve the gap by identifying the missing archived log files from the source database and manually register them on the target database.
The following SQL run on the target database will detect any archived log gaps and provide the missing thread and log sequence number(s):
select thread, seq+1
first_seq_missing , seq+(next_seq-seq-1) last_seq_missing, next_seq-seq-1 missing_count
from (select THREAD# thread, SEQUENCE# seq,
lead (SEQUENCE#, 1, SEQUENCE#) over
(partition by thread# order by sequence#)
next_seq
from
dba_registered_archived_log, dba_capture
where
capture_name = (select capture_name from v$streams_capture)
and
consumer_name = capture_name)
where next_seq - seq
> 1
order by 1,2;
We now need to establish the archived log filename from the sequence number. This is possible if the archived log filename contains the log sequence number. I.e The Source database initialisation parameter: log_archive_format must contain %s variable.
E.g. log_archive_format=arch_%t_%s_%r.log
To find the location of the archived log files, logon to the source database as SYSDBA and execute the following sqlplus command:
SQL>
show parameter log_archive_dest_1
If database is not using ASM, then cd to the location and run the following Unix command:
ls
arch_thread_<#>_seq_<#>*log
If database is using ASM, modify the environment variables for the oracle user and invoke ASM command line utility: asmcmd
N.B. You will need to look in the directory for the date the file was created
E.g.
ASMCMD>
cd +FLASH/<db_name>/ARCHIVELOG/<date>
ASMCMD>
ls arch_thread_<#>_seq_<#>*log
Having found the missing archived log files on the source database storage, we need to transfer them manually to the target database foreign archived log location. If using ASM, the files need to be copied from ASM to the local file system on the source database server, then copied to the target database server local file system and finally copied to ASM.
The following steps show the process:
In a RAC environment it is important that the target LOCATION specified on the source database specifies a service that uses the target Virtual IP address. If an instance should fail on the target database and the VIP is not used, Log Transport Services will fail and Streams will stop working until the archived logs for that particular thread are shipped including any gap resolution.
Sometimes the Capture process does not advance and appears stuck in one of the following states:
select STATE from V$STREAMS_CAPTURE;
shows :
The problem could be caused by:
- a missing logfile, or
- a logfile is not registered, or
- a logfile is corrupted, or
- Capture process is verifying/prechecking logfiles
The process will remain in this state until the log is located, it is registered or the corruption is resolved (in which case it will also be necessary to reregister the log or the Capture process has checked the logfiles on disk).
_______________________________________________________________________________
Did you find the article useful?
Please provide your feedback by voting now.
If you have a comment or question, please complete and submit the form below.
_______________________________________________________________________________