A standby database that cascades redo to other standby databases can transmit redo directly from its standby redo log file as soon as it is received from the primary database. Cascaded standby databases receive redo in real-time. They no longer have to wait for standby redo log files to be archived before redo is transmitted.
启用real-time redo,不需要等归档standby redo日志文件,然后再传输到级联备库上。
As of Oracle Database 12c Release 1 (12.1), a cascading standby database can either cascade redo in real-time (as it is being written to the standby redo log file) or non-real-time (as complete standby redo log files are being archived on the cascading standby).
从12c开始,支持real-time级联redo(等写入备库redo log)。
限制:
Only physical standby databases can cascade redo.
Real-time cascading requires a license for the Oracle Active Data Guard option.
Non-real-time cascading is supported on destinations 1 through 10 only. (Real-time cascading is supported on all destinations.)
If you specify ASYNC transport mode on destinations 1 through 10, then redo is shipped in real-time. If you do not specify a transport mode or you specify SYNC on destinations 1 through 10, then redo is shipped in non-real-time. Destinations 11 through 31 operate only in ASYNC (real-time) transport mode.
在用于级联的备库中的LOG_ARCHIVE_DEST_n(1…10)指定ASYNC,则是real-time。如果不指定,或者指定SYNC,则是non-real-time。
LOG_ARCHIVE_DEST_n(11…31)只支持ASYNC,即real-time传输模式。
搭建级联备库参考:https://blog.csdn.net/qianglei6077/article/details/90736799
SQL> select * from V$DATAGUARD_CONFIG;
DB_UNIQUE_NAME PARENT_DBUN DEST_ROLE CURRENT_SCN CON_ID
------------------------------ ------------------------------ ----------------- ----------- ----------
cndba_p NONE PRIMARY DATABASE 2122746 0
cndba_s cndba_p PHYSICAL STANDBY 2122754 0
cndba_ss cndba_s PHYSICAL STANDBY 2112269 0
SQL> show parameter LOG_ARCHIVE_DEST_2
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_2 string SERVICE=cndba_ss ASYNC NOAFFIRM VALID_FOR=(ST
ANDBY_LOGFILES,STANDBY_ROLE) D
B_UNIQUE_NAME=cndba_ss
可以看到启用real-time redo cascade。
SQL> select max(sequence#) from v$archived_log;
MAX(SEQUENCE#)
-------------
51
–创建表,并插入数据
SQL> create table cndba(id number);
Table created.
SQL> insert into cndba select object_id from dba_objects;
90947 rows created.
SQL> commit;
Commit complete.
SQL> select count(*) from cndba;
COUNT(*)
----------
90947
–可以看到日志没有发生切换
SQL> select max(sequence#) from v$archived_log;
MAX(SEQUENCE#)
--------------
51
SQL> select max(sequence#) from v$archived_log;
MAX(SEQUENCE#)
--------------
51 --日志序列号没有变化,表示没有发生日志切换
SQL> select count(*) from cndba;
COUNT(*)
----------
90947 --由于DG默认启用实时redo应用,所以Cascading备库数据实时传输过来,下面注意是验证cascaded数据是否传输过来。
SQL> select max(sequence#) from v$archived_log;
MAX(SEQUENCE#)
--------------
51 --同样日志序列号没有变化。
SQL> select count(*) from cndba;
COUNT(*)
----------
90947 --数据已经传输过来了,符合预期。
从日志中也可以查看出来:
Recovery of Online Redo Log: Thread 1 Group 4 Seq 51 Reading mem 0
Mem# 0: /u01/app/oracle/fast_recovery_area/CNDBA_SS/onlinelog/o1_mf_4_ds84tg8t_.log
SQL> alter system set LOG_ARCHIVE_DEST_2='SERVICE=cndba_ss SYNC VALID_FOR=(STANDBY_LOGFILES,STANDBY_ROLE) DB_UNIQUE_NAME=cndba_ss' scope=both;
System altered.
SQL> show parameter LOG_ARCHIVE_DEST_2
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_2 string SERVICE=cndba_ss SYNC VALID_FO
R=(STANDBY_LOGFILES,STANDBY_RO
LE) DB_UNIQUE_NAME=cndba_ss
SQL> insert into cndba select object_id from dba_objects;
90947 rows created.
SQL> commit;
Commit complete.
SQL> select count(*) from cndba;
COUNT(*)
----------
181894
SQL> select max(sequence#) from v$archived_log;
MAX(SEQUENCE#)
--------------
51
SQL> select max(sequence#) from v$archived_log;
MAX(SEQUENCE#)
--------------
51
SQL> select count(*) from cndba;
COUNT(*)
----------
181894
SQL> select max(sequence#) from v$archived_log;
MAX(SEQUENCE#)
--------------
51
SQL> select count(*) from cndba;
COUNT(*)
----------
181894 --可以看到数据没有同步过来。
从日志也可以看出来:当前日志时51,等52日志来进程恢复。
Media Recovery Waiting for thread 1 sequence 52
至此对于Real-time redo的介绍已经结束了。该特性还是非常有用的,对于数据容灾更加可靠。