Scripts to Monitor a Data Guard Environment:
At the end of this topic I have also mentioned some script which you can run in your environment.
Run the following queries in your standby database in order to know details about your Data Guard environment.
1) In order to know when your log last applied as well as last received log time issue following query:
Example output:
2) Verify the last sequence# received and the last sequence# applied to standby database by following query:
3)In order to know about transport lag time, apply lag and apply finish time issue,
Example output:
4)In order to know the status of the processes involved in Data Guard configuration issue following query,
Where the types of PROCESS may be,
- RFS - Remote file server
- MRP0 - Detached recovery server process
- MR(fg) - Foreground recovery session
- ARCH - Archiver process
- FGRD
- LGWR
- RFS(FAL)
- RFS(NEXP)
- LNS - Network server process
The process status may be,
UNUSED - No active process
ALLOCATED - Process is active but not currently connected to a primary database
CONNECTED - Network connection established to a primary database
ATTACHED - Process is actively attached and communicating to a primary database
IDLE - Process is not performing any activities
ERROR - Process has failed
OPENING - Process is opening the archived redo log
CLOSING - Process has completed archival and is closing the archived redo log
WRITING - Process is actively writing redo data to the archived redo log
RECEIVING - Process is receiving network communication
ANNOUNCING - Process is announcing the existence of a potential dependent archived redo log
REGISTERING - Process is registering the existence of a completed dependent archived redo log
WAIT_FOR_LOG - Process is waiting for the archived redo log to be completed
WAIT_FOR_GAP - Process is waiting for the archive gap to be resolved
APPLYING_LOG - Process is actively applying the archived redo log to the standby database
The client process may be,
Archival - Foreground (manual) archival process (SQL)
ARCH - Background ARCn process
LGWR - Background LGWR process
5) In the primary database ensure that everything is fine by issuing following commands. In case of RAC database ensure that these output is ok across all the instances.
Run the following queries in your standby database in order to know details about your Data Guard environment.
1) In order to know when your log last applied as well as last received log time issue following query:
select 'Last Applied : ' Logs, to_char(next_time,'DD-MON-YY:HH24:MI:SS') Time
from v$archived_log
where sequence# = (select max(sequence#) from v$archived_log where applied='YES')
union
select 'Last Received : ' Logs, to_char(next_time,'DD-MON-YY:HH24:MI:SS') Time
from v$archived_log
where sequence# = (select max(sequence#) from v$archived_log);
Example output:
SQL> select 'Last Applied : ' Logs, to_char(next_time,'DD-MON-YY:HH24:MI:SS') Time
2 from v$archived_log
3 where sequence# = (select max(sequence#) from v$archived_log where applied='YES')
4 union
5 select 'Last Received : ' Logs, to_char(next_time,'DD-MON-YY:HH24:MI:SS') Time
6 from v$archived_log
7 where sequence# = (select max(sequence#) from v$archived_log);
LOGS TIME
---------------- ------------------
Last Applied : 08-MAR-11:19:18:30
Last Received : 22-MAR-11:14:20:28
2) Verify the last sequence# received and the last sequence# applied to standby database by following query:
select al.thrd "Thread", almax "Last Seq Received", lhmax "Last Seq Applied"
from (select thread# thrd, max(sequence#) almax
from v$archived_log
where resetlogs_change#=(select resetlogs_change# from v$database)
group by thread#) al,
(select thread# thrd, max(sequence#) lhmax
from v$log_history
where first_time=(select max(first_time) from v$log_history)
group by thread#) lh
where al.thrd = lh.thrd;
Example output:SQL> select al.thrd "Thread", almax "Last Seq Received", lhmax "Last Seq Applied"
2 from (select thread# thrd, max(sequence#) almax
3 from v$archived_log
4 where resetlogs_change#=(select resetlogs_change# from v$database)
5 group by thread#) al,
6 (select thread# thrd, max(sequence#) lhmax
7 from v$log_history
8 where first_time=(select max(first_time) from v$log_history)
9 group by thread#) lh
10 where al.thrd = lh.thrd;
Thread Last Seq Received Last Seq Applied
---------- ----------------- ----------------
1 33978 2074
3)In order to know about transport lag time, apply lag and apply finish time issue,
set lines 180
col name for a40
col value for a40
col unit for a40
select
NAME,
VALUE,
UNIT
from v$dataguard_stats
union
select null,null,' ' from dual
union
select null,null,'Time Computed: '||MIN(TIME_COMPUTED)
from v$dataguard_stats;
Example output:
SQL> set lines 180
SQL> col name for a40
SQL> col value for a40
SQL> col unit for a40
SQL> select
2 NAME,
3 VALUE,
4 UNIT
5 from v$dataguard_stats
6 union
7 select null,null,' ' from dual
8 union
9 select null,null,'Time Computed: '||MIN(TIME_COMPUTED)
10 from v$dataguard_stats;
NAME VALUE UNIT
---------------------------------------- ---------------------------------------- ----------------------------------------
apply finish time day(2) to second(3) interval
apply lag +13 16:29:57 day(2) to second(0) interval
estimated startup time 45 second
transport lag day(2) to second(0) interval
Time Computed: 03/22/2011 14:24:26
6 rows selected.
4)In order to know the status of the processes involved in Data Guard configuration issue following query,
select process,status,client_process,sequence#,block#,active_agents,known_agents
from v$managed_standby;
Example output:SQL> select process,status,client_process,sequence#,block#,active_agents,known_agents
from v$managed_standby;
PROCESS STATUS CLIENT_P SEQUENCE# BLOCK# ACTIVE_AGENTS KNOWN_AGENTS
--------- ------------ -------- ---------- ---------- ------------- ------------
ARCH CLOSING ARCH 33979 61441 0 0
ARCH CLOSING ARCH 33976 61441 0 0
ARCH CONNECTED ARCH 0 0 0 0
ARCH CLOSING ARCH 33977 61441 0 0
ARCH CLOSING ARCH 33978 61441 0 0
RFS IDLE LGWR 33980 42566 0 0
MRP0 WAIT_FOR_LOG N/A 24128 0 25 25
RFS IDLE UNKNOWN 0 0 0 0
8 rows selected.
Where the types of PROCESS may be,
- RFS - Remote file server
- MRP0 - Detached recovery server process
- MR(fg) - Foreground recovery session
- ARCH - Archiver process
- FGRD
- LGWR
- RFS(FAL)
- RFS(NEXP)
- LNS - Network server process
The process status may be,
UNUSED - No active process
ALLOCATED - Process is active but not currently connected to a primary database
CONNECTED - Network connection established to a primary database
ATTACHED - Process is actively attached and communicating to a primary database
IDLE - Process is not performing any activities
ERROR - Process has failed
OPENING - Process is opening the archived redo log
CLOSING - Process has completed archival and is closing the archived redo log
WRITING - Process is actively writing redo data to the archived redo log
RECEIVING - Process is receiving network communication
ANNOUNCING - Process is announcing the existence of a potential dependent archived redo log
REGISTERING - Process is registering the existence of a completed dependent archived redo log
WAIT_FOR_LOG - Process is waiting for the archived redo log to be completed
WAIT_FOR_GAP - Process is waiting for the archive gap to be resolved
APPLYING_LOG - Process is actively applying the archived redo log to the standby database
The client process may be,
Archival - Foreground (manual) archival process (SQL)
ARCH - Background ARCn process
LGWR - Background LGWR process
5) In the primary database ensure that everything is fine by issuing following commands. In case of RAC database ensure that these output is ok across all the instances.
select status,error from v$archive_dest where status <>'INACTIVE';
select * from v$archive_processes where status <> 'STOPPED';
show parameter dest_2
show parameter state_2
alter system set log_archive_dest_state_2=enable scope=both sid='*';
alter system switch logfile;
alter system switch logfile;
select status,error from v$archive_dest where status <>'INACTIVE';
No comments:
Post a Comment