Oracle DG 状态健康检查

本文提供了一系列Oracle数据库Data Guard状态检查的SQL语句,包括PRIMARY和STANDBY实例的传输状态、日志应用时间、DG后台进程状态等关键信息,帮助DBA确保数据同步与复制的健康运行。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

-- 在PRIMARY 确认正常:
primary> 
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;

-- 检查DG状态 primary执行
primary> 
select message, to_char(timestamp, 'DD-MM-YY HH24:MI'), error_code
  from v$dataguard_status
 where error_code != 0;

SELECT DESTINATION, STATUS, ERROR FROM V$ARCHIVE_DEST WHERE DEST_ID = 2;

-- 检查传输状态
primary> 
select * from v$archive_processes where status <> 'STOPPED';
select status,error from v$archive_dest where status <>'INACTIVE';

--检查dg 后台进程
standby or primary> 
select process,
       status,
       client_process,
       sequence#,
       block#,
       active_agents,
       known_agents
  from v$managed_standby;

--日志传输状态
standby> 
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);



-- 最后应用的sequence序列
Standby> 
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;

-- 查询传输时间,日志应用时间
standby>
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;


下面是我的公众号:定期会更新一些Oracle 数据库及Python相关的学习经验。欢迎关注:

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值