DG备库,实时应用如何判断,MR进程,及MRP应用归档,三种情况的查询及验证

本篇文档学习,DG备库,实时应用如何判断,MR进程,及MRP应用归档,三种情况的查询及验证

 

1.取消MRP进程

备库查询进程状态
select process,client_process,sequence#,status,BLOCK#,BLOCKS from v$managed_standby;
PROCESS CLIENT_P SEQUENCE# STATUS BLOCK# BLOCKS
--------- -------- ---------- ------------ ---------- ----------
ARCH ARCH 0 CONNECTED 0 0
ARCH ARCH 0 CONNECTED 0 0
ARCH ARCH 0 CONNECTED 0 0
ARCH ARCH 0 CONNECTED 0 0
RFS UNKNOWN 0 IDLE 0 0
RFS UNKNOWN 0 IDLE 0 0
MRP0 N/A 1124 WAIT_FOR_LOG 0 0

 

WAIT_FOR_LOG --等待日志传输,说明当前MRP进程应用归档文件进行介质恢复

取消MRP进程应用

alter database recover managed standby database cancel;

select process,client_process,sequence#,status,BLOCK#,BLOCKS from v$managed_standby where PROCESS like '%M%';

no rows selected

 

2.启用Foreground recovery session MR(fg),前台恢复进程应用归档文件进行恢复
启用MRP进程,应用归档进行进行恢复

SYS@dage >recover managed standby database;

查询MRP进程状态

PROCESS CLIENT_P SEQUENCE# STATUS BLOCK# BLOCKS
--------- -------- ---------- ------------ ---------- ----------
MR(fg) N/A 1126 APPLYING_LOG 58451 86733 --前台等待状态,应用归档日志

WAIT_FOR_LOG - 进程正在等待归档的重做日志完成

WAIT_FOR_GAP - 进程正在等待解决存档差距

APPLYING_LOG - 进程正在将归档的重做日志主动应用于备用数据库

 

查询归档进程状态

select dest_name,status,recovery_mode from v$archive_dest_status where dest_name='LOG_ARCHIVE_DEST_1';
DEST_NAME STATUS RECOVERY_MODE
---------------------------------------- --------- -----------------------
LOG_ARCHIVE_DEST_1 VALID MANAGED (Managed recovery is active)应用归档日志


--查询当前已归档的最大归档文件序列号
SYS@dage >select max(sequence#),thread# from v$archived_log group by thread#;
MAX(SEQUENCE#) THREAD#
-------------- ----------
1162 1

--再次查询MRP进程状态,WAIT_FOR_LOG,
MR(fg) N/A 1163 WAIT_FOR_LOG 0 0

 

小结:如下命令直接启用MR进程,会话不断开,最初MR进程,Foreground recovery session,进程状态最初APPLYING_LOG,应用归档日志,随后归档日志应用完毕后,进程处于等待WAIT_FOR_LOG状态,等待主库传输归档
recover managed standby database;

 

3.启用MRP进程,后台恢复进程应用归档文件进行恢复

alter database recover managed standby database cancel;

recover managed standby database disconnect from session;

select process,client_process,sequence#,status,BLOCK#,BLOCKS from v$managed_standby where PROCESS like '%M%';

PROCESS CLIENT_P SEQUENCE# STATUS BLOCK# BLOCKS
--------- -------- ---------- ------------ ---------- ----------
MRP0 N/A 1163 WAIT_FOR_LOG 0 0

--进程为MRP0进程, 处于WAIT_FOR_LOG 等待主库传输归档状态

查询归档进程状态

select dest_name,status,recovery_mode from v$archive_dest_status where dest_name='LOG_ARCHIVE_DEST_1';

DEST_NAME STATUS RECOVERY_MODE
---------------------------------------- --------- ----------
LOG_ARCHIVE_DEST_1 VALID MANAGED

 

 

4.启用Foreground recovery session MR(fg),前台恢复进程应用standby redo logfile进行恢复
alter database recover managed standby database cancel;

--启用MR前台恢复进程

alter database recover managed standby database using current logfile;

or

recover managed standby database using current logfile; --等价

--查询进程状态,APPLYING_LOG
select process,client_process,sequence#,status,BLOCK#,BLOCKS from v$managed_standby where PROCESS like '%M%';
PROCESS CLIENT_P SEQUENCE# STATUS BLOCK# BLOCKS
--------- -------- ---------- ------------ ---------- ----------
MR(fg) N/A 1169 APPLYING_LOG 202 203


查询归档进程状态
select dest_name,status,recovery_mode from v$archive_dest_status where dest_name='LOG_ARCHIVE_DEST_1';
DEST_NAME STATUS RECOVERY_MODE
--------------------------------------- --------- -----------------------
LOG_ARCHIVE_DEST_1 VALID MANAGED REAL TIME APPLY


查询standby 状态发现
select group#,thread#,sequence#,bytes/1024/1024 m,blocksize,status from v$standby_log;
GROUP# THREAD# SEQUENCE# M BLOCKSIZE STATUS
---------- ---------- ---------- ---------- ---------- ----------
11 1 1172 50 512 ACTIVE
12 1 0 50 512 UNASSIGNED
13 1 0 50 512 UNASSIGNED

 

 

5.启用MRP 进程,后台恢复进程应用standby redo logfile进行恢复

recover managed standby database using current logfile disconnect;
or
alter database recover managed standby database using current logfile disconnect;

--主库查询
select DEST_NAME,STATUS,TRANSMIT_MODE,NET_TIMEOUT from v$archive_dest;
DEST_NAME STATUS TRANSMIT_MOD NET_TIMEOUT
---------------------------------------- --------- ------------ -----------
LOG_ARCHIVE_DEST_1 VALID SYNCHRONOUS 0
LOG_ARCHIVE_DEST_2 VALID PARALLELSYNC 30 --并行同步数据

--备库查询
select dest_name,status,recovery_mode from v$archive_dest_status;
DEST_NAME STATUS RECOVERY_MODE
---------------------------------------- --------- -----------------------
LOG_ARCHIVE_DEST_1 VALID MANAGED REAL TIME APPLY

 

--进程状态MRP进程
select process,client_process,sequence#,status,BLOCK#,BLOCKS from v$managed_standby;
PROCESS CLIENT_P SEQUENCE# STATUS BLOCK# BLOCKS
--------- -------- ---------- ------------ ---------- ----------
MRP0 N/A 1172 APPLYING_LOG 1272 102400

 


总结:备库应用恢复有四种状态
MRP0 后台 应用归档 or 应用standby redo log
MR((fg) 前台 应用归档 or 应用standby redo log

什么是前台,后台,前台进程,会话断开,进程关闭
什么时候开启前台进程MR,什么时候开启后台MRP0进程
在执行程命令时,未加入disconnect参数,会话不断开,及开启MR前台进程

MRP0进程应用归档,v$managed_standby视图中status为何还存在APPLYING_LOG?
APPLYING_LOG,只是说明了进程正在应用归档,并非标识MRP0进程是否实时应用

如何查询,是否实时应用?
select dest_name,status,recovery_mode from v$archive_dest_status;
recovery_mode=MANAGED REAL TIME APPLY

开启实时应用的前提条件
1.数据库版本>10g
2.需要提取创建standby redo logfile

 

转载于:https://www.cnblogs.com/lvcha001/p/9592074.html

你可能感兴趣的:(DG备库,实时应用如何判断,MR进程,及MRP应用归档,三种情况的查询及验证)