crosscheck archivelog from logseq 7057 until logseq 7060
restore archivelog from sequence x1 until sequence x2 thread 1;
ADG:restore clone archivelog from sequence 55 until sequence 56;
Applies To
All Users
Summary
When there is a gap between the primary and the physical standby databases, and the archive log files are on ASM on both the primary and the standby sites,
how to move the missing archive log files from the primary site ASM diskgroup to the standby site ASM diskgroup?
Solution
NOTE: In 11g, you can use RMAN to copy the files across the network. See <Note 1909235.1> Copy database file directly across network using RMAN in 11g including Primary and Standby
Please use the rman scripts below to backup missing archive log files from the primary site and restore to the standby site.
RMAN> run {
allocate channel c1 type disk;
backup archivelog from sequence x1 until sequence x2 thread 1 format '/<path on Primary>/arch_%U';
}
Then use the same script to backup for thread 2. For example,
RMAN> run {
allocate channel c1 type disk;
backup archivelog from sequence x1 until sequence x2 thread 2 format '/<path on Primary>/arch_%U';
}
Note: Please make sure the directory path /<path on Primary>/ exists on the primary site or use any other existing path.
Copy the backup pieces from the primary site to the standby site. Then restore them by
RMAN> run
{
catalog start with '/<Directory path on standby where backuppiece was copied>/';
allocate channel c1 type disk ;
restore archivelog from sequence x1 until sequence x2 thread 1;
}
Use the same script to restore for thread 2 archive log files.
RMAN> run
{
catalog start with '/<Directory path on standby where backuppiece was copied>/';
allocate channel c1 type disk ;
restore archivelog from sequence x1 until sequence x2 thread 2;
}
Note: Please make sure the path /oraback/arch/ exists on the standby site.
Summary
The note describes how to find a GAP and resolve it in case of ASM on both primary and standby or ASM on either primary or standby.
NOTE: In the images and/or the document content below, the user information and environment data used represents fictitious data from the Oracle sample schema(s), Public Documentation delivered with an Oracle database product or other training material. Any similarity to actual environments, actual persons, living or dead, is purely coincidental and not intended in any manner.
For the purposes of this document, the following fictitious environment is used as an example to describe the procedure:
Primary Database:
DB_NAME: PRIM
Standby Database:
DB_UNIQUE_NAME: STDBY
Diskgroup name is +DGROUP2
Solution
OPTION -I : Copy archivelog
OPTION II : Take backup of archivelog
OPTION -I:
- Check for the GAP,
On standby,
SQL>SELECT THREAD#, LOW_SEQUENCE#, HIGH_SEQUENCE# FROM V$ARCHIVE_GAP;
- On primary Check the location where the missing logfiles exist.
SELECT NAME FROM V$ARCHIVED_LOG WHERE THREAD#=<n> AND DEST_ID=<n> AND SEQUENCE# BETWEEN <LOW_SEQUENCE#> AND <HIGH_SEQUENCE#>;
For example,
SQL> SELECT * FROM V$ARCHIVE_GAP;
THREAD# LOW_SEQUENCE# HIGH_SEQUENCE#
1 1113 1115
SQL> SELECT NAME FROM V$ARCHIVED_LOG WHERE THREAD#=1 AND DEST_ID=1 AND SEQUENCE# BETWEEN 1113 AND 1115;
NAME
+DGROUP2/PRIM/datafile/ARC00001113_0732997804.001
+DGROUP2/PRIM/datafile/ARC00001114_0732997804.001
+DGROUP2/PRIM/datafile/ARC00001115_0732997804.001
- Use RMAN to copy to someother local filesystem.
RMAN>copy archivelog '+DGROUP2/PROD/datafile/ARC00001113_0732997804.001' to '/u01/app/oracle/ARC00001113_0732997804.001';
Do the same for all the logs.
- SCP to standby.
scp /u01/app/oracle/ARC00001113_0732997804.001 remoteusername@destination_host_ofstandby:/u01/app/oracle/
- Register manually by mentioning the copied file location.
On standby,
SQL>alter database register logfile '/u01/app/oracle/ARC00001113_0732997804.001';
NOTE : Alternatively we can copy this archive log to standby ASM location and then do a register.
On standby,
$rman target /
RMAN>copy archivelog '/u01/app/oracle/ARC00001113_0732997804.001' to '+DGROUP2/STDBY/datafile/ARC00001113_0732997804.001';
Now register,
SQL>alter database register logfile '+DGROUP2/STDBY/datafile/ARC00001113_0732997804.001';
OPTION - II-----十几个node 不得累死
Please use the rman scripts below to backup missing archive log files from the primary site and restore to the standby site.
RMAN> run {
allocate channel c1 type disk;
backup archivelog from sequence x1 until sequence x2 thread 1 format '/oraback/arch/arch_%U';
}
Then use the same script to backup for thread 2. For example,
RMAN> run {
allocate channel c1 type disk;
backup archivelog from sequence x1 until sequence x2 thread 2 format '/oraback/arch/arch_%U';
}
Note: Please make sure the path /oraback/arch/ exists on the primary site or use any other existing path.
Copy the backup pieces from the primary site to the standby site. Then restore them by
RMAN> run
{
catalog start with '/oraback/arch/';
allocate channel c1 type disk ;
restore archivelog from sequence x1 until sequence x2 thread 1;
}
Use the same script to restore for thread 2 archive log files.
RMAN> run
{
catalog start with '/oraback/arch/';
allocate channel c1 type disk ;
restore archivelog from sequence x1 until sequence x2 thread 2;
}
Note: Please make sure the path /oraback/arch/ exists on the standby site.
---------------from from sequence thread 很复杂,简化
RMAN> show RETENTION POLICY;
RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
RMAN> restore archivelog from time='SYSDATE-7' validate;