miércoles, 23 de mayo de 2012

DATAGUARD SCRIPTS SQL PARA VALIDAR ESTADO



Startup commands
startup nomount
alter database mount standby database;
alter database recover managed standby database disconnect;


To remove a delay from a standby
alter database recover managed standby database cancel;
alter database recover managed standby database nodelay disconnect;






Cancel managed recovery
alter database recover managed standby database cancel;






Register a missing log file
alter database register physical logfile '';






If FAL doesn't work and it says the log is already registered
alter database register or replace physical logfile '';


If that doesn't work, try this...
shutdown immediate
startup nomount
alter database mount standby database;
alter database recover automatic standby database;


wait for the recovery to finish - then cancel
shutdown immediate
startup nomount
alter database mount standby database;
alter database recover managed standby database disconnect;






Check which logs are missing
Run this on the standby...
select local.thread#
, local.sequence# from
(select thread#
, sequence#
from v$archived_log
where dest_id=1) local
where local.sequence# not in
(select sequence#
from v$archived_log
where dest_id=2 and
thread# = local.thread#)
/






Disable/Enable archive log destinations
alter system set log_archive_dest_state_2 = 'defer';
alter system set log_archive_dest_state_2 = 'enable';






Turn on fal tracing on the primary db
alter system set LOG_ARCHIVE_TRACE = 128;






Stop the Data Guard broker
alter system set dg_broker_start=false
/






Show the current instance role
select database_role
from v$database
/






Logical standby apply stop/start
Stop...
alter database stop logical standby apply;


Start...
alter database start logical standby apply;






See how up to date a physical standby is
Run this on the primary
set numwidth 15
select max(sequence#) current_seq
from v$log
/


Then run this on the standby
set numwidth 15
select max(applied_seq#) last_seq
from v$archive_dest_status
/






Display info about all log destinations
To be run on the primary
set lines 100
set numwidth 15
column ID format 99
column "SRLs" format 99
column active format 99
col type format a4

select ds.dest_id id
, ad.status
, ds.database_mode db_mode
, ad.archiver type
, ds.recovery_mode
, ds.protection_mode
, ds.standby_logfile_count "SRLs"
, ds.standby_logfile_active active
, ds.archived_seq#
from v$archive_dest_status ds
, v$archive_dest ad
where ds.dest_id = ad.dest_id
and ad.status != 'INACTIVE'
order by
ds.dest_id
/






Display log destinations options
To be run on the primary
set numwidth 8 lines 100
column id format 99
select dest_id id
, archiver
, transmit_mode
, affirm
, async_blocks async
, net_timeout net_time
, delay_mins delay
, reopen_secs reopen
, register,binding
from v$archive_dest
order by
dest_id
/






List any standby redo logs
set lines 100 pages 999
col member format a70
select st.group#
, st.sequence#
, ceil(st.bytes / 1048576) mb
, lf.member
from v$standby_log st
, v$logfile lf
where st.group# = lf.group#
/



SCRIPTS PARA VALIDAR ESTADO DEL DATA GUARD

export ORACLE_SID=DEUDA
df -h
sqlplus / as sysdba @monitor_dataguard.sql
rman target / LOG = dataguard.log append cmdfile=list_backup.rcv


@monitor_dataguard.sql

spool dataguard.log
@dbmap.sql
@@dataguard.sql
spool off
exit


@dbmap.sql

set serveroutput on size 10000

COLUMN name FORMAT A80
COLUMN member FORMAT A80
COLUMN dest_name FORMAT A40
COLUMN destination FORMAT A40
COLUMN datafile FORMAT A55
COLUMN tbs FORMAT A20
COLUMN file FORMAT A60
COLUMN highwater FORMAT 999999999999
COLUMN last_value FORMAT 999999999999
SET PAGESIZE 24
set linesize 180


PROMPT DATABASE INFO ...
select dbid, current_scn, db_unique_name, created, log_mode, open_mode, protection_mode, protection_level, dataguard_broker from v$database;

PROMPT ARCHIVOS DE CONTROLFILE ...
select name from v$controlfile;

PROMPT ARCHIVOS REDOLOGS ...
select group#, type, member from v$logfile;


prompt

prompt

PROMPT ARCHIVOS DE ARCHIVELOG ...
select dest_id, dest_name, destination from v$archive_dest where status='VALID' and schedule='ACTIVE' ;

PROMPT INFORMACION DE TABLESPACES Y DATAFILES...

select file#, name "DATAFILE", status, enabled, bytes/1024/1024 "SIZE Mb" from v$datafile order by file# ;



@dataguard.sql

set lines 150
col name format a50
col group format a10
col client_pid format a15
col client_dbid format a15
col message format a100
col member format a80
col status format a20

select * from v$instance;

show parameter control

show parameter config

show parameter db_recovery

select * from v$recovery_file_dest;

select * from v$flash_recovery_area_usage;

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 ;


select THREAD# "THREAD", (select max(sequence#) from v$archived_log where applied='YES') MAX_APPLIED,
(select max(sequence#) from v$archived_log where archived='YES') MAX_ARCHIVED, max(FIRST_TIME) "DATE"
from v$archived_log group by THREAD#;


PROMPT ESTADO DATAGUARD

select timestamp, to_char ( TIMESTAMP, 'dd-mon-yyyy hh24:mi:ss'), message
from v$dataguard_status
where to_date(timestamp,'dd-mon-yyyy') =to_date (sysdate,'dd-mon-yyyy');

PROMPT GAP DE ARCHIVOS DE LOG

select * from v$archive_gap;

PROMPT ESTADO DE LOS DESTINOS DE ARCHIVELOG

select dest_id, status, error from v$archive_dest where dest_id in (1,2,3);

PROMPT ARCHIVOS DE LOG

select * from v$logfile;

PROMPT MODO DE RECUPERACION

COL DEST_NAME FORMAT A50

SELECT DEST_ID, DEST_NAME, RECOVERY_MODE FROM V$ARCHIVE_DEST_STATUS;

PROMPT PROCESOS DATAGUARD

select * from v$managed_standby;

exit


list_backup.rcv

Show all;
list backup summary;