目录
Oracle-DG/ADG灾备之二—主备一致性验证
一、主备库环境
1、操作系统
Oracle Linux 7.6
2、数据库版本
Oracle 11.2.0.4.0
二、主备库DG状态查看
1、主备库状态查看
(1)执行语句
SET lines 300; col force_logging for a10; select database_role,protection_mode,protection_level,open_mode,force_logging,switchover_status from v$database;
(2)主库
(3)备库
2、主备库归档查看
(1)执行语句:
archive log list;
(2)主库
(3)备库
3、主备库同步检查
(1)执行语句
select unique thread#,max(sequence#) over(partition by thread#)last,to_char(COMPLETION_TIME,'YYYY-MM-DD hh24:mi:ss') COMPLETION_TIME from v$archived_log;
(2)主库
(3)备库
4、查询主库日志传输序列号及备库日志应用序列号
如果相等则表示主、备库数据一致。反之则主、备库数据不一致。
(1)执行语句
SELECT AL.THRD "Thread", ALMAX "Last Seq Received", LHMAX "Last Seq Applied", AL.COMPLETION_TIME FROM (SELECT THREAD# THRD, MAX(SEQUENCE#) ALMAX, to_char(COMPLETION_TIME,'YYYY-MM-DD hh24:mi:ss') COMPLETION_TIME FROM V$ARCHIVED_LOG WHERE RESETLOGS_CHANGE# = (SELECT RESETLOGS_CHANGE# FROM V$DATABASE) GROUP BY THREAD#,COMPLETION_TIME) AL, (SELECT THREAD# THRD, MAX(SEQUENCE#) LHMAX FROM V$LOG_HISTORY WHERE RESETLOGS_CHANGE# = (SELECT RESETLOGS_CHANGE# FROM V$DATABASE) GROUP BY THREAD#) LH WHERE AL.THRD = LH.THRD order by ALMAX ;
(2)主库
(3)备库
5、检查备库MRP0进程以及进程的活动状态
(1)执行语句
SELECT process,client_process,sequence#,status FROM v$managed_standby;
(2)主库:
(3)备库:
6、检查备库日志应用详细情况
(1)执行语句
select * from ( SELECT registrar, creator, thread#, applied, sequence#, first_change#, next_change#, to_char(completion_time,'YYYY-MM-DD hh24:mi:ss') completion_time FROM v$archived_log order by sequence# desc,completion_time desc ) where rownum <10;
(2)备库
7、检查备库应用日志的进度
SET feed off SET lines 300 SET pages 999 col value for a20 SELECT to_char(sysdate, 'MM/DD/YYYY hh24:mi:ss') ctime, name, value, datum_time FROM v$dataguard_stats WHERE NAME LIKE '%lag';
8. 检查备库是否有GAP
查看备库是否有间隙序列,如果有,进行查看,没有则正常。
select * from v$archive_gap;