Quantcast
Channel: Doyensys Allappsdba Blog..
Viewing all articles
Browse latest Browse all 1640

Article 0

$
0
0

Script to check the Data Guard status



set feedb off
set pages 99

set lines 200

column dbid              format 9999999999 heading "DbId"
column name              format a9 heading "Name"
column open_mode         format a21 heading "Open Mode"
column protection_mode   format a20 heading "Protect Mode"
column protection_level  format a20 heading "Protect Level"
column switchover_status format a18 heading "SwitchOver | Status"
column remote_archive    format a8 heading "Remote|Archive"
column database_role     format a16 heading "Database Role"
column flashback_on      format a5  heading "Flash|Back"
column created           format a19 heading "Created "
column RESETLOGS_TIME    format a19 heading "Resetlogs "
column db_unique_name    format a24 heading "DB Unique Name"

select dbid, db_unique_name, open_mode, database_role,
       -- to_char(created, 'mm/dd/yyyy hh24:mi:ss') created,
       -- to_char(RESETLOGS_TIME, 'mm/dd/yyyy hh24:mi:ss') RESETLOGS_TIME,
       protection_mode, switchover_status,
       flashback_on  /* 10g only */
from v$database
;
set lines 200
col dest_id       format 99 heading "ID"
col archiver      format a6 heading "Archvr"
col transmit_mode format a12 heading "Transmit|Mode"
col affirm        format a3  heading "Aff"
col async_blocks  format 999999 heading "Async|Blocks"
col net_timeout   format 999999 heading "Network|Timeout"
col delay_mins    format 999999 heading "Delay|Minutes"
col reopen_secs   format 999999 heading "Reopen|Seconds"
col register      format a3     heading "Reg"
col binding       format a10    heading "Binding"
col dest_name     format a20    heading "Dest Name"
col destination   format a29    heading "Destination"
col error         format a20    heading "Error"

SELECT dest_id, dest_name, status, protection_mode, destination, srl, error
FROM v$archive_dest_status
WHERE destination is not null    -- and status = 'VALID'
ORDER BY dest_id;

set lines 200
col dest_id       format 99  heading "ID"
col archiver      format a10 heading "Archiver"
col transmit_mode format a12 heading "Transmit|Mode"
col affirm        format a3  heading "Aff"
col async_blocks  format 999999 heading "Async|Blocks"
col net_timeout   format 999999 heading "Network|Timeout"
col delay_mins    format 999999 heading "Delay|Minutes"
col reopen_secs   format 999999 heading "Reopen|Seconds"
col register      format a3     heading "Reg"
col binding       format a10    heading "Binding"
col valid_type    format a15    heading "Valid Type"
col valid_role    format a12    heading "Valid Role"
col valid_now     format a16     heading "Valid now?"

SELECT dest_id, archiver, transmit_mode, affirm, async_blocks,
       net_timeout, delay_mins, reopen_secs, register, binding,
       valid_type, valid_role, valid_now
FROM v$archive_dest
WHERE register = 'YES' OR valid_now = 'YES'
ORDER BY dest_id;

set lines 200

column status            format a12
column time              format a22
column SEVERITY          format a13
column DEST_ID           format 9999  heading "Dest|  ID"
column ERROR_CODE        format 99999 heading "Error| Code"
column TIMESTAMP         format a20
column MESSAGE           format a80 word_wrapped

select PROCESS, status, SEQUENCE#, THREAD#, BLOCK#, BLOCKS,
       TO_CHAR(SYSDATE, 'DD-MON-YYYY HH:MI:SS') TIME
from V$MANAGED_STANDBY;

column message format a93 word_wrapped
select message, timestamp
from v$dataguard_status
where severity in ('Error','Fatal')
  and timestamp between systimestamp -1 and systimestamp
order by timestamp;

set lines 200
col thrd        format 9999          heading "Thrd"
col almax       format 9999999       heading "Last Seq|Received"
col alscn1      format 9999999999999 heading "Received|First-SCN"
col alnscn      format 9999999999999 heading "Received|Next-SCN"
col lhmax       format 9999999       heading "Last Seq|Applied"
col lhscn1      format 9999999999999 heading "Applied|First-SCN"
col lhnscn      format 9999999999999 heading "Applied|Next-SCN"
col log1sttime  format a19           heading "Received 1st Time"
col hist1sttime format a19           heading "Applied 1st Time"
col diff        format 9999          heading "Diff"

select al.thrd, almax, log1sttime, alscn1, alnscn,
       lhmax, hist1sttime, lhscn1, lhnscn, almax-lhmax diff
from (select thread# thrd, max(sequence#) almax, max(FIRST_CHANGE#) alscn1,
      max(next_change#) alnscn, to_char(max(first_time),'yyyy/mm/dd hh24:mi:ss') log1sttime
      from v$archived_log
      where resetlogs_change#=(select resetlogs_change# from v$database)
      group by thread#) al,
     (select thread# thrd, max(sequence#) lhmax,  max(FIRST_CHANGE#) lhscn1,
        max(next_change#) lhnscn, to_char(max(first_time),'yyyy/mm/dd hh24:mi:ss') hist1sttime
      from v$log_history
      where first_time=(select max(first_time) from v$log_history)
      group by thread#) lh
where al.thrd(+) = lh.thrd;

col name format a24
col value format a90
select name, value from v$parameter
where name ='log_archive_config' or name like 'dg_broker_%'
   or name like 'fal_%'
order by name;

set feedb on


Viewing all articles
Browse latest Browse all 1640

Trending Articles