In many cases monitoring Data Guard, at least in Maximum Performance mode, is down to checking transport and apply lag to make sure standby database is not “too far” behind primary, and quite often it is sufficient in a day to day operation. By checking v$archived_log we can easily get information about the last archived and applied log sequence number:
SQL> select sequence#,ARCHIVED,APPLIED from v$archived_log order by sequence#; SEQUENCE# ARCHIVED APPLIED ---------- --------- --------- … output truncated … 208 YES YES 209 YES YES 210 YES YES 211 YES IN-MEMORY
If we use real-time apply changes are applied to the standby database as soon as they are written to the standby redo logs, which should keep standby database as up to date as possibly without going to Maximum Availability or Maximum Protection.
However, if our primary database fails, how can we check what is the last change transmitted from the primary, or that all changes transmitted were actually applied before we activate standby?
Of course we can trust that Oracle will apply all the transmitted redo, when standby is activated, but without knowing what was the last transmitted change we have no way of verifying it. It is also possible that the failover decision depends on how far behind the primary the standby was at the time of failure or how much data can potentially be lost.
One way of finding the information we need is by checking v$standby_log and v$recovery_progress views.
v$standby_log displays information about standby redo logs. Columns LAST_CHANGE# and LAST_TIME can be used to find last changes transmitted from primary.
SQL> select GROUP#,THREAD#,SEQUENCE#,STATUS,LAST_CHANGE#,LAST_TIME from v$standby_log; GROUP# THREAD# SEQUENCE# STATUS LAST_CHANGE# LAST_TIME ---------- ---------- ---------- ---------- ------------------ ------------------- 4 1 213 ACTIVE 1699715 2013-04-18 20:26:15 5 1 0 UNASSIGNED 6 1 0 UNASSIGNED 7 1 0 UNASSIGNED SQL>
v$recovery_progress can be used to monitoring database recovery operations, and gives us access to information like: Last Applied Redo, Active Apply Rate, Average Apply Rate, Apply Time per Log and a few more. The item we are interested in is “Last Applied Redo” and the value of the “TIMESTAMP” column. The value should be very close to or match the value of LAST_TIME column from v$standby_log view.
SQL> select START_TIME,TYPE, ITEM,UNITS,SOFAR,TIMESTAMP 2 from v$recovery_progress where ITEM='Last Applied Redo'; START_TIME TYPE ITEM UNITS TIMESTAMP ------------------- ---------------- ------------------- --------- ------------------- 2013-04-17 22:46:26 Media Recovery Last Applied Redo SCN+Time 2013-04-18 20:26:16 SQL>