Oracle Data Guard Cheat Sheet A Must Have For DBAs ! 1745608429
Oracle Data Guard Cheat Sheet A Must Have For DBAs ! 1745608429
This document is mainly created for beginners to understand DATA GUARD related SQL queries
and DGMGRL Commands. Completely it deals with the management of Physical and Logical Standby
databases without using Grid Control. These guide would help you to get crystal clear idea
and also necessary information for understanding to troubleshoot Data Guard related issues.
DATABASE REGISTRATION
NOTE : It’s possible to open the Standby DB in READ-ONLY mode or READ-ONLY WITH APPLY mode.
$ cat dg_parameters.sql
SPOOL.txt SPOOL.txt
# Configured Archive destinations for Primary and Standby databases (at Primary database)
SYS> SELECT
ds.dest_id id, ad.dest_name, ad.status, ds.database_mode db_mode
, ad.archiver, ds.recovery_mode, ds.standby_logfile_count "SRLs"
, ds.standby_logfile_active active, ds.archived_seq#
FROM v$archive_dest_status ds, v$archive_dest ad
WHERE ds.dest_id = ad.dest_id
AND ad.status != 'INACTIVE' ORDER BY ds.dest_id;
SYS> select group#, thread#, status, (bytes/1024/1024) "File Size in MB" from v$standby_log;
SYS> select group#, thread#, status, (bytes/1024/1024) "File Size in MB" from v$standby_log;
THREAD# MAX(SEQUENCE#)
---------- --------------
1 1255
SYS> select thread#, max(sequence#) from v$archived_log where applied='YES' group by thread#;
THREAD# MAX(SEQUENCE#)
---------- --------------
1 1255
# On Primary database (Archived log info from the Primary database Control file)
APPLIED Indicates whether the archive log has been applied to its corresponding Standby
database (YES) or not (NO). The value is always NO for local destinations.
# On Standby database (Archived log info from the Standby database control file)
9 rows selected.
LOGS TIME
-------------------- ------------------
Last Log applied : 15-JUN-16:02:53:11
Last Log received : 15-JUN-16:02:53:11
# On Primary database
# Displays and logs events triggered by any message to the alert.log or trace files
The view V$DATAGUARD_STATUS displays messages recently written to the alert.log file or
Server process trace files that concern Physical Standby databases or redo transport
Services for all Standby database types.
MESSAGE
---------------------------------------------------------------------------------------------
LNS: Standby redo logfile selected for thread 1 sequence 1255 for destination LOG_ARCHIVE_DEST_2
LNS: Beginning to archive log 3 thread 1 sequence 1255
LNS: Completed archiving log 3 thread 1 sequence 1255
ARC2: Beginning to archive thread 1 sequence 1255 (6375081-6375114)
ARC2: Completed archiving thread 1 sequence 1255 (6375081-6375114)
LNS: Standby redo logfile selected for thread 1 sequence 1256 for destination LOG_ARCHIVE_DEST_2
LNS: Beginning to archive log 2 thread 1 sequence 1256
MESSAGE
---------------------------------------------------------------------------------------------
...
ARC0: Beginning to archive thread 1 sequence 1254 (6375073-6375081)
ARC0: Completed archiving thread 1 sequence 1254 (0-0)
Media Recovery Waiting for thread 1 sequence 1255 (in transit)
ARC1: Beginning to archive thread 1 sequence 1255 (6375081-6375114)
Media Recovery Waiting for thread 1 sequence 1256
ARC1: Completed archiving thread 1 sequence 1255 (0-0)
# Execute the Script at Primary database to find archived log gap details
SYS> @archive_gap.sql;
# On Standby database
NAME
--------------------------------------------------------------------------------------
/u01/app/oracle/flash_recovery_area/CRMS/archivelog/2016_06_15/o1_mf_1_1333_cp1vsq53_.arc
/u01/app/oracle/flash_recovery_area/CRMS/archivelog/2016_06_15/o1_mf_1_1334_cp1vwskv_.arc
/u01/app/oracle/flash_recovery_area/CRMS/archivelog/2016_06_15/o1_mf_1_1335_cp1vxzds_.arc
/u01/app/oracle/flash_recovery_area/CRMS/archivelog/2016_06_15/o1_mf_1_1336_cp1vy2lr_.arc
FYI: Incase listed archived logs already deleted at Primary, you need to roll forward
Standby database using RMAN incremental backup based on last SCN of the Standby database.
SYS> select name, value from v$dataguard_stats; or # Transport lag, Apply lag,
SYS> select * from v$dataguard_stats; # Apply finish time, Estimated Startup time
...
V$DATAGUARD_STATS displays information about Data Guard metrics when queried on a Standby
database. I.e. it is describing redo data generated by the primary database that is not
yet available on the standby database and how much redo has not yet been applied to the
Standby database. No rows are returned when queried on a primary database.
The view V$RECOVERY_PROGRESS can be used to track database recovery operations to ensure
that they are not stalled, and also to estimate the time required to complete the operation
In progress.
For a physical standby should have at least 1 remote destination that points the Primary.
Archive Lag Histogram: The V$STANDBY_EVENT_HISTOGRAM view came with 11gR2; histogram that
shows the historical occurrence (history of apply lag) values in terms of seconds since
the Standby database last started.
SYS> select group#, status, members, (bytes/1024/1024) "ORL File Size in MB" FROM v$log;
SYS> select group#, status, members,(bytes/1024/1024)"ORL File Size in MB" from v$log;
This following query shows any errors that occurred the last time an attempt to archive to
the destination was attempted. If ERROR is blank and status is VALID then the archive
completed correctly.
SYS> /
DEST_ID RECOVERY_MODE
---------- -----------------------
1 MANAGED REAL TIME APPLY
RECOVERY_MODE
-----------------------
MANAGED REAL TIME APPLY
RECOVERY_MODE
-----------------------
MANAGED REAL TIME APPLY
# Disabling
9 rows selected.
Following Shell command lists the archive log apply records of standby database alert log
with the corresponding times at the end of the line.