Best Way to monitor standby, primary databases

Primary, Physical (redo apply) and Logical (SQL apply) Standby Databases or Active Data Guard
User avatar
jimb
Site Admin
Posts: 6146
Joined: Thu Jan 19, 2012 1:10 pm
Location: New Delhi, India
Contact:

Best Way to monitor standby, primary databases

Post by jimb »

Best Way to monitor standby, primary databases, including alert logs, etc.

Hi, Guys, I finally cutover the new environment to the new linux redhat and everything working great so far (the primary/standby).

Now I would like to setup monitoring scripts to monitor it automatically so I can let it run by itself.

What is the best way?

I talked to another dba friend outside of the company and he told me his shop not use any cron jobs to monitor, they use grid control.

We have no grid control. I would like to see what is the best option here? should we setup grid control?

And also for the meantime, I would appreciate any good ideas of any cronjob scripts.

Thanks
Oracle Database Administration Forums
http://www.oracle-forums.com/
User avatar
jimb
Site Admin
Posts: 6146
Joined: Thu Jan 19, 2012 1:10 pm
Location: New Delhi, India
Contact:

Re: Best Way to monitor standby, primary databases

Post by jimb »

Hello;

I came up with this which I run on the Primary daily, Since its SQL you can add any extras you need.
SPOOL OFF
CLEAR SCREEN
SPOOL /tmp/quickaudit.lst
PROMPT
PROMPT -----------------------------------------------------------------------|
-- PROMPT
SET TERMOUT ON
SET VERIFY OFF
SET FEEDBACK ON
PROMPT
PROMPT Checking database name and archive mode
PROMPT
column NAME format A9
column LOG_MODE format A12
SELECT
NAME,
CREATED,
LOG_MODE
FROM
V$DATABASE;
PROMPT
PROMPT -----------------------------------------------------------------------|
-- PROMPT
PROMPT
PROMPT Checking Tablespace name and status
PROMPT
column TABLESPACE_NAME format a30
column STATUS format a10
SET pagesize 400
SELECT
TABLESPACE_NAME,
STATUS
FROM
DBA_TABLESPACES;
PROMPT
PROMPT ------------------------------------------------------------------------
-- |
PROMPT
PROMPT
PROMPT Checking free space in tablespaces
PROMPT
column tablespace_name format a30
SELECT
tablespace_name ,
SUM(bytes)/1024/1024 "MB Free"
FROM
dba_free_space
WHERE
tablespace_name = 'TEMP'
GROUP BY
tablespace_name;
PROMPT
PROMPT ------------------------------------------------------------------------
-- |
PROMPT
PROMPT
PROMPT Checking freespace by tablespace
PROMPT
column dummy noprint
column pct_used format 999.9 heading "%|Used"
column name format a16 heading "Tablespace Name"
column bytes format 9,
999,
999,
999,
999 heading "Total Bytes"
column used format 99,
999,
999,
999 heading "Used"
column free format 999,
999,
999,
999 heading "Free"
BREAK ON report
compute SUM OF bytes ON report
compute SUM OF free ON report
compute SUM OF used ON report
SET linesize 132
SET termout OFF
SELECT
a.tablespace_name name,
b.tablespace_name dummy,
SUM(b.bytes)/COUNT( DISTINCT a.file_id
||'.'
||a.block_id ) bytes,
SUM(b.bytes)/COUNT( DISTINCT a.file_id
||'.'
||a.block_id ) - SUM(a.bytes)/COUNT( DISTINCT b.file_id ) used,
SUM(a.bytes) /COUNT( DISTINCT b.file_id ) free,
100 * ( (SUM(b.bytes)/COUNT( DISTINCT a.file_id
||'.'
||a.block_id )) - (SUM(a.bytes)/COUNT( DISTINCT b.file_id ) )) / (SUM(b.bytes
) /COUNT( DISTINCT a.file_id
||'.'
||a.block_id )) pct_used
FROM
sys.dba_free_space a,
sys.dba_data_files b
WHERE
a.tablespace_name = b.tablespace_name
GROUP BY
a.tablespace_name,
b.tablespace_name;
PROMPT
PROMPT ------------------------------------------------------------------------
-- |
PROMPT
PROMPT
PROMPT Checking Size and usage in GB of Flash Recovery Area
PROMPT
SELECT
ROUND((A.SPACE_LIMIT / 1024 / 1024 / 1024), 2) AS FLASH_IN_GB,
ROUND((A.SPACE_USED / 1024 / 1024 / 1024), 2) AS FLASH_USED_IN_GB,
ROUND((A.SPACE_RECLAIMABLE / 1024 / 1024 / 1024), 2) AS FLASH_RECLAIMABLE_GB,
SUM(B.PERCENT_SPACE_USED) AS PERCENT_OF_SPACE_USED
FROM
V$RECOVERY_FILE_DEST A,
V$FLASH_RECOVERY_AREA_USAGE B
GROUP BY
SPACE_LIMIT,
SPACE_USED ,
SPACE_RECLAIMABLE ;
PROMPT
PROMPT ------------------------------------------------------------------------
-- |
PROMPT
PROMPT
PROMPT Checking free space In Flash Recovery Area
PROMPT
column FILE_TYPE format a20
SELECT
*
FROM
v$flash_recovery_area_usage;
PROMPT
PROMPT ------------------------------------------------------------------------
-- |
PROMPT
PROMPT
PROMPT ------------------------------------------------------------------------
-- |
PROMPT
PROMPT
PROMPT Checking last sequence in v$archived_log
PROMPT
clear screen
SET linesize 100
column STANDBY format a20
column applied format a10
--select max(sequence#), applied from v$archived_log where applied = 'YES'
-- group by applied;
SELECT
name AS STANDBY,
SEQUENCE#,
applied,
completion_time
FROM
v$archived_log
WHERE
DEST_ID = 2
AND NEXT_TIME > SYSDATE -1;
prompt
prompt----------------Last log on Primary--------------------------------------
-- |
prompt
SELECT
MAX(sequence#)
FROM
v$archived_log
WHERE
NEXT_TIME > sysdate -1;
PROMPT
PROMPT ------------------------------------------------------------------------
-- |
PROMPT
PROMPT
PROMPT Checking switchover status
PROMPT
SELECT
switchover_status
FROM
v$database;
I run it from a shell script and email myself quickaudit.lst

Alert logs are great source of information when you have an issue or just want to check something.

Best Regards

mseberg
Oracle Database Administration Forums
http://www.oracle-forums.com/
User avatar
jimb
Site Admin
Posts: 6146
Joined: Thu Jan 19, 2012 1:10 pm
Location: New Delhi, India
Contact:

Re: Best Way to monitor standby, primary databases

Post by jimb »

Great. Thanks. I will wait for more help here. But your script is very good.
Oracle Database Administration Forums
http://www.oracle-forums.com/
User avatar
jimb
Site Admin
Posts: 6146
Joined: Thu Jan 19, 2012 1:10 pm
Location: New Delhi, India
Contact:

Re: Best Way to monitor standby, primary databases

Post by jimb »

EM dbconsole is good idea. However can everything be set inside EM DBCONSOLE to be monitored?
Oracle Database Administration Forums
http://www.oracle-forums.com/
User avatar
jimb
Site Admin
Posts: 6146
Joined: Thu Jan 19, 2012 1:10 pm
Location: New Delhi, India
Contact:

Re: Best Way to monitor standby, primary databases

Post by jimb »

Yes, there are many default events that can be customized (if you need to) -- or -- you can create your own events to monitor.
Oracle Database Administration Forums
http://www.oracle-forums.com/
User avatar
jimb
Site Admin
Posts: 6146
Joined: Thu Jan 19, 2012 1:10 pm
Location: New Delhi, India
Contact:

Re: Best Way to monitor standby, primary databases

Post by jimb »

I like using SQL myself because it always works. But there's nothing wrong with the other methods.

A couple of other things you could add to a script would be :

A breakdown of what transported and what applied :

Code: Select all

select archived_seq# from V$ARCHIVE_DEST_STATUS where dest_id = 2;
 
select applied_seq# from V$ARCHIVE_DEST_STATUS where dest_id = 2;


And some V$dataguard_status information :

Code: Select all

SELECT  
        FACILITY,  
        SEVERITY,  
        DEST_ID,  
        MESSAGE_NUM,  
        ERROR_CODE,  
        CALLOUT,  
       TIMESTAMP,  
        MESSAGE  
      FROM  
       V$DATAGUARD_STATUS;
Best Regards

mseberg
Oracle Database Administration Forums
http://www.oracle-forums.com/
xaeresis
Posts: 196117
Joined: Wed Oct 04, 2023 2:39 pm

Re: Best Way to monitor standby, primary databases

Post by xaeresis »

сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтtuchkasсайтсайт
xaeresis
Posts: 196117
Joined: Wed Oct 04, 2023 2:39 pm

Re: Best Way to monitor standby, primary databases

Post by xaeresis »

xaeresis
Posts: 196117
Joined: Wed Oct 04, 2023 2:39 pm

Re: Best Way to monitor standby, primary databases

Post by xaeresis »

Post Reply