Search This Blog

Total Pageviews

Sunday, 2 June 2013

archive log status and error



set serveroutput on
DECLARE
CURSOR c is
select s.db_unique_name,
s.database_mode,
s.dest_id id, 
s.status stats,
s.recovery_mode,
s.protection_mode, 
s.standby_logfile_count,
s.standby_logfile_active,
s.archived_thread#, 
s.archived_seq#,
s.applied_thread#,
s.applied_seq#,
d.status, 
d.destination, 
d.archiver,
d.transmit_mode, 
d.affirm, 
d.async_blocks,
d.net_timeout, 
d.delay_mins, 
d.reopen_secs,
d.register,
d.binding, 
d.compression, 
d.error, 
to_char(d.FAIL_DATE,'dd-mm-yyyy hh24:mi:ss') FAIL_DATE
from v$archive_dest_status s, v$archive_dest d
where d.dest_id=s.dest_id
and s.db_unique_name != 'NONE'
and d.destination is not null;
BEGIN
dbms_output.put_line('-----------------------------------------------------');

FOR r IN c LOOP
DBMS_OUTPUT.PUT_LINE('Host Name          : ' || UTL_INADDR.GET_HOST_NAME);  
DBMS_OUTPUT.PUT_LINE('Ip Address         : ' || UTL_INADDR.GET_HOST_ADDRESS);  
dbms_output.put_line('Error date         : ' ||r.FAIL_DATE );
dbms_output.put_line('Dest ID            : ' ||r.id );
dbms_output.put_line('Status             : ' ||r.stats);
dbms_output.put_line('DB Name            : ' ||r.db_unique_name );
dbms_output.put_line('DB Mode            : ' ||r.database_mode);
dbms_output.put_line('Recovery Mode      : ' ||r.recovery_mode);
dbms_output.put_line('Protection Mode    : ' ||r.protection_mode);
dbms_output.put_line('SRL Count          : ' ||r.standby_logfile_count );
dbms_output.put_line('SRLActive          : ' ||r.standby_logfile_active);
dbms_output.put_line('Archived Thread#   : ' ||r.archived_thread# );
dbms_output.put_line('ArchivedSeq#       : ' ||r.archived_seq#);
dbms_output.put_line('Applied Thread#    : ' ||r.applied_thread# );
dbms_output.put_line('Destination        : ' ||r.destination);
dbms_output.put_line('Archiver           : ' ||r.archiver);
dbms_output.put_line('Transmit Mode      : ' ||r.transmit_mode);
dbms_output.put_line('Affirm             : ' ||r.affirm);
dbms_output.put_line('Asynchronous Blocks: ' ||r.async_blocks);
dbms_output.put_line('Net Timeout        : ' ||r.net_timeout);
dbms_output.put_line('Delay (Mins)       : ' ||r.delay_mins);
dbms_output.put_line('Reopen (Secs)      : ' ||r.reopen_secs);
dbms_output.put_line('Register           : ' ||r.register);
dbms_output.put_line('Binding            : ' ||r.binding);
dbms_output.put_line('Compression        : ' ||r.compression);
dbms_output.put_line('Error              : ' ||r.error);
dbms_output.put_line('----------------------------------------------------');
END LOOP;
END;
/




SQL> r
  1  DECLARE
  2  CURSOR c is
  3  select s.db_unique_name,
  4  s.database_mode,
  5  s.dest_id id,
  6  s.status stats,
  7  s.recovery_mode,
  8  s.protection_mode,
  9  s.standby_logfile_count,
 10  s.standby_logfile_active,
 11  s.archived_thread#,
 12  s.archived_seq#,
 13  s.applied_thread#,
 14  s.applied_seq#,
 15  d.status,
 16  d.destination,
 17  d.archiver,
 18  d.transmit_mode,
 19  d.affirm,
 20  d.async_blocks,
 21  d.net_timeout,
 22  d.delay_mins,
 23  d.reopen_secs,
 24  d.register,
 25  d.binding,
 26  d.compression,
 27  d.error,
 28  to_char(d.FAIL_DATE,'dd-mm-yyyy hh24:mi:ss') FAIL_DATE
 29  from v$archive_dest_status s, v$archive_dest d
 30  where d.dest_id=s.dest_id
 31  and s.db_unique_name !='NONE'
 32  and d.destination is not null;
 33  BEGIN
 34  dbms_output.put_line('-----------------------------------------------------');
 35
 36  FOR r IN c LOOP
 37  DBMS_OUTPUT.PUT_LINE('Host Name          : ' || UTL_INADDR.GET_HOST_NAME);
 38  DBMS_OUTPUT.PUT_LINE('Ip Address         : ' || UTL_INADDR.GET_HOST_ADDRESS);
 39  dbms_output.put_line('Error date         : ' ||r.FAIL_DATE );
 40  dbms_output.put_line('Dest ID            : ' ||r.id );
 41  dbms_output.put_line('Status             : ' ||r.stats);
 42  dbms_output.put_line('DB Name            : ' ||r.db_unique_name );
 43  dbms_output.put_line('DB Mode            : ' ||r.database_mode);
 44  dbms_output.put_line('Recovery Mode      : ' ||r.recovery_mode);
 45  dbms_output.put_line('Protection Mode    : ' ||r.protection_mode);
 46  dbms_output.put_line('SRL Count          : ' ||r.standby_logfile_count );
 47  dbms_output.put_line('SRLActive          : ' ||r.standby_logfile_active);
 48  dbms_output.put_line('Archived Thread#   : ' ||r.archived_thread# );
 49  dbms_output.put_line('ArchivedSeq#       : ' ||r.archived_seq#);
 50  dbms_output.put_line('Applied Thread#    : ' ||r.applied_thread# );
 51  dbms_output.put_line('Destination        : ' ||r.destination);
 52  dbms_output.put_line('Archiver           : ' ||r.archiver);
 53  dbms_output.put_line('Transmit Mode      : ' ||r.transmit_mode);
 54  dbms_output.put_line('Affirm             : ' ||r.affirm);
 55  dbms_output.put_line('Asynchronous Blocks: ' ||r.async_blocks);
 56  dbms_output.put_line('Net Timeout        : ' ||r.net_timeout);
 57  dbms_output.put_line('Delay (Mins)       : ' ||r.delay_mins);
 58  dbms_output.put_line('Reopen (Secs)      : ' ||r.reopen_secs);
 59  dbms_output.put_line('Register           : ' ||r.register);
 60  dbms_output.put_line('Binding            : ' ||r.binding);
 61  dbms_output.put_line('Compression        : ' ||r.compression);
 62  dbms_output.put_line('Error              : ' ||r.error);
 63  dbms_output.put_line('----------------------------------------------------');
 64  END LOOP;
 65* END;



-----------------------------------------------------
Host Name          : anuj.kumarsingh.co.uk
Ip Address         : 127.0.0.1
Error date         : 02-06-2013 06:49:58
Dest ID            : 2
Status             : ERROR
DB Name            : STANDBY
DB Mode            : UNKNOWN
Recovery Mode      : IDLE
Protection Mode    : MAXIMUM PERFORMANCE
SRL Count          : 0
SRLActive          : 0
Archived Thread#   : 0
ArchivedSeq#       : 0
Applied Thread#    : 0
Destination        : STDY
Archiver           : LGWR
Transmit Mode      : ASYNCHRONOUS
Affirm             : NO
Asynchronous Blocks: 16381
Net Timeout        : 180
Delay (Mins)       : 0
Reopen (Secs)      : 15
Register           : YES
Binding            : OPTIONAL
Compression        : DISABLE
Error              : ORA-12543: TNS:destination host unreachable
----------------------------------------------------




PROMPT *****************************************************************
PROMPT *  Archive Destinations
PROMPT *****************************************************************
set linesize 200 pagesize 200
COLUMN dest_id             HEADING "Dest|Id"                     FORMAT 99
COLUMN dest_name           HEADING "Dest Name"                   FORMAT a20
COLUMN db_unique_name      HEADING "UniqueName"                  FORMAT a15
COLUMN destination         HEADING "Destination"                 FORMAT a28
COLUMN archiver            HEADING "Arch|iver"                   FORMAT a4
COLUMN compression         HEADING "Compress"                    FORMAT a8
COLUMN transmit_mode       HEADING "Tranmit|Mode"                
COLUMN affirm              HEADING "AFFIRM"                      FORMAT a6

COLUMN reopen_secs         HEADING "Reopen|(sec)"                FORMAT 999999
COLUMN delay_mins          HEADING "Delay|(min)"                 FORMAT 99999
COLUMN max_connections     HEADING "Max|Conns"                   FORMAT 99999
COLUMN net_timeout         HEADING "Net|Time|Out"                FORMAT 9999
COLUMN alternate           HEADING "Alertnate"                   FORMAT a10
COLUMN dependency          HEADING "Dependency"                  FORMAT a10

COLUMN register            HEADING "Regi|ster"                   FORMAT a4
COLUMN log_sequence        HEADING "LogSeq"                      FORMAT 9999999

COLUMN async_blocks        HEADING "ASYNC|Blocks"                FORMAT 999999
COLUMN valid_now           HEADING "Valid|Now"                   FORMAT a7
COLUMN verify              HEADING "Verify"                      FORMAT a6

COLUMN fail_sequence       HEADING "FailSeq"                     FORMAT 9999999
COLUMN failure_count       HEADING "Fail|Count"                  FORMAT 99999
COLUMN max_failure         HEADING "Max|Fail"                    FORMAT 99999
COLUMN error               HEADING "Error"                       FORMAT a30

SELECT ad.dest_id
     , ad.dest_name
     , ad.db_unique_name
     , ad.destination
     , ad.status
     , ad.schedule
     , ad.target
     , ad.valid_type
     , ad.valid_role
     , ad.binding
     , ad.name_space
     , ad.compression
     , ad.archiver
     , ad.transmit_mode
     , ad.affirm
  FROM v$archive_dest ad
WHERE status <> 'INACTIVE'
;


Dest                                                                                                                                                               Arch Tranmit
  Id Dest Name            UniqueName      Destination                  STATUS    SCHEDULE TARGET           VALID_TYPE      VALID_ROLE   BINDING   NAME_SP Compress iver Mode         AFFIRM
---- -------------------- --------------- ---------------------------- --------- -------- ---------------- --------------- ------------ --------- ------- -------- ---- ------------ ------
   1 LOG_ARCHIVE_DEST_1   NONE            /u01/app/oracle/ArchiveLog   VALID     ACTIVE   PRIMARY          ALL_LOGFILES    ALL_ROLES    OPTIONAL  SYSTEM  DISABLE  ARCH SYNCHRONOUS  NO
   2 LOG_ARCHIVE_DEST_2   vihaan_stdy     stdy1                        DEFERRED  PENDING  STANDBY          ONLINE_LOGFILE  ALL_ROLES    OPTIONAL  SYSTEM  DISABLE  LGWR ASYNCHRONOUS NO




set lines 300 pagesize 300 numf 9999999999999
column destination format a25
column id 	format 999
column target 	format a7
column seq# 	format 999999999
column proc 	format a10
col transmit_mode for a20
select dest_id as id, status , target,archiver, destination, log_sequence as seq#, process ,register, transmit_mode, affirm,valid_type, valid_role, db_unique_name,applied_scn
from v$archive_dest 
where 1=1
and DB_UNIQUE_NAME!='NONE';





 select name,description from v$bgprocess where paddr<>'00' and description like 'Network%';
NAME  DESCRIPTION
----- ----------------------------------------------------------------
NSS2  Network Server SYNC

process that does the Redo Transport from Primary to Standby has changed from LNS to NSS (for synchronous Redo Transport):


SELECT ad.dest_id
     , ad.reopen_secs
     , ad.delay_mins
     , ad.max_connections
     , ad.net_timeout
     , ad.process
     , ad.register
     , ad.log_sequence
     , ad.alternate
     , ad.dependency
     , ad.async_blocks
     , ad.type
     , ad.valid_now
     , ad.verify
   --, ad.applied_scn
     , ad.fail_date
     , ad.fail_sequence
     , ad.failure_count
     , ad.max_failure
     , ad.error
  FROM v$archive_dest ad
WHERE status <> 'INACTIVE'
;

                             Net
Dest  Reopen  Delay    Max  Time            Regi                                  ASYNC         Valid                               Fail    Max
  Id   (sec)  (min)  Conns   Out PROCESS    ster   LogSeq Alertnate  Dependency  Blocks TYPE    Now     Verify FAIL_DATE  FailSeq  Count   Fail Error
---- ------- ------ ------ ----- ---------- ---- -------- ---------- ---------- ------- ------- ------- ------ --------- -------- ------ ------ ------------------------------
   1     300      0      1     0 ARCH       YES        40 NONE       NONE             0 PUBLIC  YES     NO                      0      0      0
   2     300      0      1    30 LGWR       YES         0 NONE       NONE         61440 PUBLIC  UNKNOWN NO                      0      0      
set linesize 200 pagesize 200 
col dest_id             heading "Dest|Id"                     format 9999
col destination         heading "Destination"                 format a15
col dest_status         heading "Dest|Status"                 format a8
col type                heading "Type"                        format a10
col database_mode       heading "Database Mode"               format a15
col recovery_mode       heading "Recovery Mode"               format a23
col protection_mode     heading "Protection Mode"             format a20
col gap_status          heading "GAP|Status"                  format a6
col applied             heading "A|p|p|l|i|e|d"               format a1   truncate
col archived            heading "A|r|c|h|e|v|e|d"             format a1   truncate
col deleted             heading "D|e|l|e|t|e|d"               format a1   truncate
col archlog_status      heading "S|t|a|t|u|s"                 format a1   truncate
col max_sequence#       heading "Max Sequence#"               format 999999
col max_next_time       heading "Max Next Time"               format a18
col max_first_time      heading "Max First Time"              format a18
SELECT l.dest_id
     , s.destination
     , s.status   dest_status
     , s.type
     , s.database_mode
     , s.recovery_mode
     , s.protection_mode
     , s.gap_status
     , l.applied
     , l.archived
     , l.deleted
     , l.status    archlog_status
     , l.thread#
     , max(l.sequence#) max_sequence#
     , TO_CHAR(max(l.next_time),'DD-MON-YY hh24:MI:SS')  max_next_time
     , TO_CHAR(max(l.first_time),'DD-MON-YY hh24:MI:SS') max_first_time
     , ROUND((SUM(l.block_size * l.blocks)/1024/1024/1024),2)  redo_size_GB
 FROM v$archived_log l
    , v$archive_dest_status s
WHERE l.dest_id = s.dest_id     
 GROUP BY l.dest_id
        , s.destination
        , s.status
        , s.type
        , s.database_mode
        , s.recovery_mode
        , s.protection_mode
        , s.gap_status
        , l.applied
        , l.archived
        , l.deleted
        , l.status
       , l.thread#
 ORDER BY l.applied desc
        , l.dest_id ;   



===

set line 500 
col  dest_name format a20
col destination format a15
col gap_status format a10
col db_unique_name format a15
col error format a25
col applied_scn for 999999999999999
SELECT AL.THREAD#,
       ADS.DEST_ID,
       ADS.DEST_NAME,
       (SELECT ADS.TYPE || ' ' || AD.TARGET      FROM V$ARCHIVE_DEST AD  WHERE AD.DEST_ID = ADS.DEST_ID) TARGET,
       ADS.DATABASE_MODE,
       ADS.STATUS,
       ADS.RECOVERY_MODE,
       ADS.DB_UNIQUE_NAME,
       ADS.DESTINATION,
       ADS.GAP_STATUS,
       (SELECT MAX(SEQUENCE#) FROM V$LOG NA WHERE NA.THREAD# = AL.THREAD#) CURRENT_SEQ#,
       MAX(SEQUENCE#) LAST_ARCHIVED,
       MAX(CASE  WHEN AL.APPLIED = 'YES' AND ADS.TYPE <> 'LOCAL' THEN         AL.SEQUENCE#
           END) APPLIED_SEQ#,
       (SELECT AD.APPLIED_SCN      FROM V$ARCHIVE_DEST AD  WHERE AD.DEST_ID = ADS.DEST_ID) APPLIED_SCN,
ADS.ERROR
  FROM (SELECT *    FROM V$ARCHIVED_LOG V
         WHERE V.RESETLOGS_CHANGE# = (SELECT D.RESETLOGS_CHANGE# FROM V$DATABASE D)) AL,
       V$ARCHIVE_DEST_STATUS ADS
 WHERE AL.DEST_ID(+) = ADS.DEST_ID
   AND ADS.STATUS != 'INACTIVE'
 GROUP BY AL.THREAD#,
          ADS.DEST_ID,
          ADS.DEST_NAME,
          ADS.STATUS,
          ADS.ERROR,
          ADS.TYPE,
          ADS.DATABASE_MODE,
          ADS.RECOVERY_MODE,
          ADS.DB_UNIQUE_NAME,
          ADS.DESTINATION,
          ADS.GAP_STATUS
 ORDER BY ADS.DEST_ID,AL.THREAD#;

 
                                                                                                                A
                                                                                                              A r D
                                                                                                              p c e S
                                                                                                              p h l t
                                                                                                              l e e a
                                                                                                              i v t t
 Dest                 Dest                                                                             GAP    e e e u
   Id Destination     Status   Type       Database Mode   Recovery Mode           Protection Mode      Status d d d s    THREAD# Max Sequence# Max Next Time      Max First Time     REDO_SIZE_GB
----- --------------- -------- ---------- --------------- ----------------------- -------------------- ------ - - - - ---------- ------------- ------------------ ------------------ ------------
    2 orajndr         VALID    PHYSICAL   MOUNTED-STANDBY MANAGED REAL TIME APPLY MAXIMUM PERFORMANCE  NO GAP Y Y N A          1        265642 10-JUL-17 09:02:50 10-JUL-17 09:01:08      3179.73
    1 +ORLOGS         VALID    LOCAL      OPEN            IDLE                    MAXIMUM PERFORMANCE         N Y N A          1        265643 10-JUL-17 09:10:48 10-JUL-17 09:02:50        44.22
----- ===============
PROMPT *****************************************************************
PROMPT *  D A T A G U A R D    L A G
PROMPT *****************************************************************
COLUMN name                HEADING "Name"                        FORMAT a23
COLUMN value               HEADING "Value"                       FORMAT a20
COLUMN unit                HEADING "Unit"                        FORMAT a30
COLUMN time_computed       HEADING "TimeComputed"                FORMAT a20
COLUMN datum_time          HEADING "datum_time"                  FORMAT a20
SELECT ds.name
     , ds.value
     , ds.unit
     , ds.time_computed
     , ds.datum_time
  FROM v$dataguard_stats ds ;
==

set linesize 300 pagesize 300
col VALUE for a150 wrap
col NAME for a30
select NAME,VALUE from V$SPPARAMETER where NAME like 'log_archive_dest%'
and VALUE is not null
and VALUE like '%db_unique_name%'
--and VALUE like 'LGWR%'
;


set linesize 300
col VALUE for a50
col NAME for a40
select name, value
from v$parameter
where name = 'log_archive_dest'
and value is not null
union all
select p.name, p.value
from v$parameter p where
name like 'log_archive_dest%'
and p.name not like '%state%'
and p.value is not null
and 'enable' = (
	select lower(p2.value)
	from v$parameter p2
	where p2.name =  substr(p.name,1,instr(p.name,'_',-1)) || 'state' || substr(p.name,instr(p.name,'_',-1))
)
union all
select p.name, p.value
from v$parameter p
where p.name like 'log_archive_dest_stat%'
and lower(p.value) = 'enable'
and (
	select p2.value
	from v$parameter p2
	where name = substr(p.name,1,16) || substr(p.name,instr(p.name,'_',-1))
) is not null
/



set linesize 300 pagesize 300
col VALUE for a150 wrap
col NAME for a30
select NAME,VALUE from V$SPPARAMETER where NAME like 'log_archive_dest%'
and VALUE is not null
and VALUE like '%db_unique_name%'
--and VALUE like 'LGWR%'
;


set linesize 300 pagesize 500
col DESTINATION for a40
col RECOVERY_MODE for a30
col DEST_NAME for a20
select DEST_ID,STATUS,DEST_NAME,RECOVERY_MODE,PROTECTION_MODE,DESTINATION,SYNCHRONIZATION_STATUS,SYNCHRONIZED ,ERROR from v$archive_dest_status
where 1=1
and STATUS='VALID'
;


set linesize 300
col ERROR for a80
select db_unique_name, status, error from v$archive_dest where db_unique_name != 'NONE' ;


13 comments:

Anuj Singh said...

select archived_thread#, archived_seq#, applied_thread#, applied_seq# ,STATUS,GAP_STATUS from v$archive_dest_status
where STATUS!='INACTIVE';


ARCHIVED_THREAD# ARCHIVED_SEQ# APPLIED_THREAD# APPLIED_SEQ# STATUS GAP_STATUS
---------------- ------------- --------------- ------------ --------- ------------------------
1 23 0 0 VALID
1 23 1 22 VALID NO GAP

Anuj Singh said...

set linesize 200
col DEST_NAME for a20
col DESTINATION for a40
select DEST_ID,DEST_NAME,LOG_SEQUENCE,ERROR,TYPE,STATUS,DESTINATION from v$archive_dest where DESTINATION is not null ;

Anuj Singh said...

alter system set log_archive_dest_1='LOCATION=+LOG' scope=both;

Anuj Singh said...

--escape OFF
set linesize 200 pagesize 200
set escape '\'
set linesize 200
col name for a25
col value for 25
col value for a25
select NAME,VALUE from v$parameter where NAME like 'log\_archive\_dest\_state\_2%' or name like 'log\_archive\_dest%'
and VALUE is not null;

Anuj Singh said...

set linesize 200
col MESSAGE for a100 wrap
select to_char(timestamp,'DD-MON-YYYY HH24:MI:SS'), severity, error_code,message from v$dataguard_status;

Anuj Singh said...



set linesize 200 pagesize 200
column destination format a70 wrap
column process format a7
column ID format 99
column mid format 99
SELECT gvi.inst_id,thread#, dest_id, gvad.status, target, schedule, process, mountid mid , destination FROM gv$archive_dest gvad, gv$instance gvi
WHERE 1=1
and gvad.inst_id = gvi.inst_id
AND destination is NOT NULL
ORDER BY thread#, dest_id;

Anuj Singh said...

set pages 9999 lines300
col OPEN_MODE for a10
col HOST_NAME for a10

select name,INSTANCE_NAME,HOST_NAME,OPEN_MODE,DATABASE_STATUS,DATABASE_ROLE, PROTECTION_LEVEL,CONTROLFILE_TYPE,LOGINS,to_char(STARTUP_TIME,'DD-MON-YYYY HH24:MI:SS') "UP TIME"from v$database,Gv$instance;

Anuj Singh said...

alter system set log_archive_dest_state_2 = 'defer';
alter system set log_archive_dest_state_2 = 'enable';

Anuj Singh said...


set linesize 200
col DEST_NAME for a40
col error for a20
select INST_ID,DEST_NAME,STATUS,RECOVERY_MODE,ARCHIVED_THREAD#,ARCHIVED_SEQ#,APPLIED_THREAD#,APPLIED_SEQ#,DB_UNIQUE_NAME,GAP_STATUS,ERROR from GV$ARCHIVE_DEST_STATUS
where DEST_NAME in ('LOG_ARCHIVE_DEST_2');

Anuj Singh said...

set linesize 300 pagesize 500
col DESTINATION for a40
col RECOVERY_MODE for a30
col DEST_NAME for a20
select DEST_ID,DEST_NAME,RECOVERY_MODE,PROTECTION_MODE,DESTINATION,ERROR from v$archive_dest_status;

Anuj Singh said...

set linesize 200
col MESSAGE for a100 wrap
select to_char(timestamp,'DD-MON-YYYY HH24:MI:SS'), severity, error_code,message from v$dataguard_status
where 1=1
and timestamp > sysdate - interval '5' minute;
--and timestamp > sysdate - interval '10' minute
;

Anuj Singh said...

--prod !!!
select ads.dest_id,max(sequence#) "Current Sequence",max(log_sequence) "Last Archived", max(applied_seq#) "Last Sequence Applied"
from v$archived_log al, v$archive_dest ad, v$archive_dest_status ads
where ad.dest_id=al.dest_id
and al.dest_id=ads.dest_id
group by ads.dest_id ;

Anuj Singh said...




How to make log shipping to continue work without copying password file from primary to physical standby when changing sys password on primary? (Doc ID 1416595.1) To BottomTo Bottom

Oracle DBA

anuj blog Archive