-- 在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相关的学习经验。欢迎关注: