top of page
  • Grey LinkedIn Icon
  • Grey YouTube Icon
  • Grey Twitter Icon
  • Grey Facebook Icon

HOW TO CHECK WHETHER PHYSICAL STANDBY IS IN SYNC WITH THE PRIMARY OR NOT AND RESOLVED GAP ?

Updated: Feb 9, 2020

Step by Step Process to Resolve gap on the Standby database.

Summary 1. Check the name and status of database. 2. Check for GAP on standby 3. Check redo received on standby 4. Check redo applied on standby 5. Identify missing archive log files 6. Copy archive log files 7. Register archive log files with standby 8. Restart the managed recovery operations

*********************************************************************************************************

Step 1: Check the status of the database on both servers. On Primary Server.

SQL> select name, open_mode, database_role from v$database; NAME OPEN_MODE DATABASE_ROLE ——— ———- —————- MYDB READ WRITE PRIMARY

SQL> set sqlprompt “

>”

>

On Standby Server.

SQL> select name, open_mode, database_role from v$database; NAME OPEN_MODE DATABASE_ROLE ——— ———- —————- MYDB MOUNTED PHYSICAL STANDBY

SQL> set sqlprompt “

>”

>

Step 2: Check for GAP on Standby

max(sequence#) from v$log_history;

MAX(SEQUENCE#) ————– 76921

max(sequence#) from v$log_history; MAX(SEQUENCE#) ————– 76921

THREAD# “Thread”,SEQUENCE# “Last Sequence Generated” FROM V$ARCHIVED_LOG WHERE (THREAD#,FIRST_TIME ) IN (SELECT THREAD#,MAX(FIRST_TIME) FROM V$ARCHIVED_LOG GROUP BY THREAD#) ORDER BY 1; Thread Last Sequence Generated ———- ———————– 1 76921

Step 3 & 4: Check redo received and applied on the standby.

> SELECT ARCH.THREAD# "Thread", ARCH.SEQUENCE# "Last Sequence Received", APPL.SEQUENCE# "Last Sequence Applied", (ARCH.SEQUENCE# – APPL.SEQUENCE#) "Difference" FROM (SELECT THREAD# ,SEQUENCE# FROM V$ARCHIVED_LOG WHERE (THREAD#,FIRST_TIME ) IN (SELECT THREAD#,MAX(FIRST_TIME) FROM V$ARCHIVED_LOG GROUP BY THREAD#)) ARCH, (SELECT THREAD# ,SEQUENCE# FROM V$LOG_HISTORY WHERE (THREAD#,FIRST_TIME ) IN (SELECT THREAD#,MAX(FIRST_TIME) FROM V$LOG_HISTORY GROUP BY THREAD#)) APPL WHERE ARCH.THREAD# = APPL.THREAD# ORDER BY 1; Thread Last Sequence Received Last Sequence Applied Difference ———- ———————- ——————— ———- 1 76922 20931 55991

Step 5: Identify the missing archive log file.

THREAD#, LOW_SEQUENCE#, HIGH_SEQUENCE# FROM V$ARCHIVE_GAP; no rows selected

—-If a found gap

Step 6: Copy missing archive log file After identifying a gap (as shown above), the DBA will need to query the primary database to locate the archived redo logs on the primary database. The following query assumes the local archive destination on the primary database is LOG_ARCHIVE_DEST_1:

> SELECT name FROM v$archived_log WHERE thread# = 1 AND dest_id = 1 AND sequence# BETWEEN 20931 and 76922; Output: /oracle/bases/MYDB/archives/MYDB_0001_0716381751_0000076922.arc 56027 rows selected.

Step 7: Register archive logfile with standby. Copy the above redo log files to the physical standby database and register them using the ALTER DATABASE REGISTER LOGFILE … SQL statement on the physical standby database.

For example:

> ALTER DATABASE REGISTER LOGFILE ‘/oracle/bases/MYDB/archives/MYDB_0001_0716381751_0000076922.arc’;

Step 8: Restart the managed recovery operations. — After the redo logs have been registered on the physical standby database, the DBA can restart the managed recovery operations. For example, to put the physical standby database into automatic recovery managed mode:

> alter database recover managed standby database disconnect from session;

Join our Telegram group for a free session for new features and upcoming webinar.

(

)

6,992 views0 comments

Recent Posts

See All

How to Connect MySQL Without Root Password.

Many times, I got the question from my colleague or training participants, how to login MySQL if I forgot the password. I have explained the process in many times to them but thought to write this sce

Step by Step Oracle 21c Installation on Linux

Oracle Database 21c is the first Oracle database release with CDB-only architecture. Oracle 20c was announced only CDB architecture but it was not release for on premises. Only for Cloud. That's why i

bottom of page