Data Guard启动实时日志应用

Posted lottu

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Data Guard启动实时日志应用相关的知识,希望对你有一定的参考价值。

1. REDO数据实时应用

启动实时应用的优势在于,REDO数据不需要等待归档完成,接收到即可被应用,这样执行角色切换时,操作能够执行得更快,因为日志是被即时应用的。

要启动实时应用也简单,前提是Standby数据库端配置了Standby Redologs。

物理Standby要启用实时应用,要在启动REDO应用的语句后附加USING CURRENT LOGFIE子句,例如:

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE ; 

2. 启动实时应用redo日志操作

2.1添加standby redo log

首先查询当前redo log的大小、位置;Standby redo的大小要和redo 的一致

primary>col status format a10
primary>select group#,thread#,archived,status, bytes/1024/1024 from v$log;  

    GROUP#    THREAD# ARCHIVED    STATUS       BYTES/1024/1024
---------- ---------- --------- ---------- ---------------
     1        1 YES    INACTIVE        50
     2        1 NO    CURRENT         50
     3        1 YES    INACTIVE        50

primary>col member format a35;
primary>select group#,type, member from v$logfile;

    GROUP# TYPE          MEMBER
---------- --------------------- -----------------------------------
     1 ONLINE         /u01/app/oradata/ora234/redo01.log
     2 ONLINE         /u01/app/oradata/ora234/redo02.log
     3 ONLINE         /u01/app/oradata/ora234/redo03.log

添加standby redo 操作;主库/备库都操作;
主库操作原因;当发生故障;主备库发生切换;减少切换过程操作

主库操作
primary> ALTER DATABASE ADD STANDBY LOGFILE GROUP 4 (/home/oracle/oradata/redolog/std_redo04.log) size 50M;
Database altered.

primary> ALTER DATABASE ADD STANDBY LOGFILE GROUP 5 (/home/oracle/oradata/redolog/std_redo05.log) size 50M;
Database altered.

primary> ALTER DATABASE ADD STANDBY LOGFILE GROUP 6 (/home/oracle/oradata/redolog/std_redo06.log) size 50M;
Database altered.

primary> ALTER DATABASE ADD STANDBY LOGFILE GROUP 7 (/home/oracle/oradata/redolog/std_redo07.log) size 50M;
Database altered.

备库操作
standby> ALTER DATABASE ADD STANDBY LOGFILE GROUP 4 (/home/oracle/oradata/redolog/std_redo04.log) size 50M;
Database altered.

standby> ALTER DATABASE ADD STANDBY LOGFILE GROUP 5 (/home/oracle/oradata/redolog/std_redo05.log) size 50M;
Database altered.

standby> ALTER DATABASE ADD STANDBY LOGFILE GROUP 6 (/home/oracle/oradata/redolog/std_redo06.log) size 50M;
Database altered.

standby> ALTER DATABASE ADD STANDBY LOGFILE GROUP 7 (/home/oracle/oradata/redolog/std_redo07.log) size 50M;
Database altered.

2.2修改主备库参数;

启动实时应用日志;需采用lgwr模式;即应用redolog。不再是archivelog

primary>alter system set LOG_ARCHIVE_DEST_2=SERVICE=tns_standby LGWR VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=db_standby ;

System altered.

standby>alter system set log_archive_dest_2=SERVICE=tns_primary LGWR VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=db_primary;

System altered.

2.3启用实时StandBy端redo应用

StandBy>alter database recover managed standby database using current logfile disconnect from session;

取消实时应用:alter database recover managed standby database cancel;

2.4验证结果

primary>truncate table t;

Table truncated.

primary>insert into t values (1000);

1 row created.

primary>commit;

Commit complete.


standby>select * from t;

no rows selected

standby>select * from t;

    ID
----------
      1000

以上是关于Data Guard启动实时日志应用的主要内容,如果未能解决你的问题,请参考以下文章

Data Guard 主备库角色转换

Data Guard备库未应用日志的问题一则

Active Data Guard

Oracle12cR1 Data Guard 实施文档

Data Guard - Snapshot Standby Database配置

F5-ASM-AdvWAF-data guard