log_archive_dest 为LGWR时需要创建standby redolog,为arch时无须设置standby redolog
--必须设置standby redolog,数据实时同步
alter database recover managed standby database using current controlfile disconnect;
--数据异步同步,当主库切换归档时进行数据同步
alter database recover managed standby database disconnect from session;
--关闭MRP进程
alter database recover managed standby database cancel;
select OPEN_MODE,PROTECTION_MODE,ACTIVATION#,DATABASE_ROLE,SWITCHOVER#,SWITCHOVER_STATUS FROM V$DATABASE;
确认主库状态为to standby或者为sessions active、保护模式应该maximum performance、角色为PRIMARY
在备库查询时通常为not allowed 或者sessions active,角色为PHYSICAL STANDBY
-查看应用日志延迟时间:
select value from v$dataguard_stats where name='apply lag';
-查看接收日志延迟时间:
select value from v$dataguard_stats where name='transport lag';
-查看主库归档
Primary: SQL> select thread#, max(sequence#) "Last Primary Seq Generated"
from v$archived_log val, v$database vdb
where val.resetlogs_change# = vdb.resetlogs_change#
group by thread# order by 1;
-查看备库已接收归档
PhyStdby:SQL> select thread#, max(sequence#) "Last Standby Seq Received"
from v$archived_log val, v$database vdb
where val.resetlogs_change# = vdb.resetlogs_change#
group by thread# order by 1;
-查看备库已应用归档
PhyStdby:SQL>select thread#, max(sequence#) "Last Standby Seq Applied"
from v$archived_log val, v$database vdb
where val.resetlogs_change# = vdb.resetlogs_change#
and val.applied in ('YES','IN-MEMORY')
group by thread# order by 1;
-查看归档应用详细情况
select first_time,sequence#,applied from v$archived_log;
-查看主备库GAP
select * from v$archive_gap;
SET LINES 300 PAGES 9999
COL name FOR a15
COL USED_PERCENT FOR a15
SELECT GROUP_NUMBER,
NAME,
TOTAL_MB / 1024 total_gb,
FREE_MB / 1024,
USABLE_FILE_MB / 1024,
ROUND ( (TOTAL_MB - USABLE_FILE_MB) * 100 / TOTAL_MB) || '%'
USED_PERCENT
FROM V$ASM_DISKGROUP
ORDER BY 1;