data guard 的redo 传输
data guard 通过把redo从primary数据库传输到standby数据库并应用在standby数据库来实现自己的功能。 redo 传输是有2种模式
1. 同步 sync
2. 异步 async
同步就是指一个transaction在commit之前必须把redo传输到standby,而异步则是指commit不必等redo传输就可以commit成功。
data guard中的redo 传输是通过参数 log_archive_dest_n来配置的,下面的两个配置就对应了同步和异步模式。
log_archive_dest_8='SERVICE=itid2 SYNC VALID_FOR=( ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=itid2'
log_archive_dest_2='SERVICE=itid2 ASYNC VALID_FOR=( ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=itid2'
要注意的是sync只能配置在 log_archive_dest_1-10这10个参数之间。
log_archive_dest_n这个参数对于理解redo传输特别重要。它可以配置
1. 把redo archive到本地
2. 把redo archive到远端比如standby
3. 从standby redo log中提取redo 生成archive
4. 同步异步
。。。
当检查primary和standby之间redo传输情况的时候可以通过以下几个SQL
查看primary端的归档情况
SELECT MAX(SEQUENCE#), THREAD# FROM V$ARCHIVED_LOG WHERE RESETLOGS_CHANGE# = (SELECT MAX(RESETLOGS_CHANGE#) FROM V$ARCHIVED_LOG) GROUP BY THREAD#;
查看standby端归档应用的情况
SELECT SEQUENCE#,APPLIED FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;
查看archive dest的归档情况
SELECT DESTINATION, STATUS, ARCHIVED_THREAD#, ARCHIVED_SEQ# FROM V$ARCHIVE_DEST_STATUS WHERE STATUS <> 'DEFERRED' AND STATUS <> 'INACTIVE';
这个视图包含了各个archive dest的很多详细信息,非常有用。
查看某个dest是不是有log没有收到
SELECT LOCAL.THREAD#, LOCAL.SEQUENCE# FROM (SELECT THREAD#, SEQUENCE# FROM V$ARCHIVED_LOG WHERE DEST_ID=1) LOCAL WHERE LOCAL.SEQUENCE# NOT IN (SELECT SEQUENCE# FROM V$ARCHIVED_LOG WHERE DEST_ID=2 AND THREAD# = LOCAL.THREAD#);
同时,通过下面的视图可以知道redo传输的效率
V$REDO_DEST_RESP_HISTOGRAM
V$REDO_DEST_RESP_HISTOGRAM
provides statistical information for each redo transport destination.
Column | Datatype | Description |
---|---|---|
DEST_ID |
NUMBER |
A non-negative integer value from 1 - 10 for each possible LGWR SYNC standby destination |
TIME |
VARCHAR2(20) |
A text string that shows the last wall-clock time that a bucket was hit |
DURATION |
NUMBER |
A positive integer value that represents a bucket of seconds, 1, 2, 3, up to 300 seconds, followed by 5 additional buckets that represent 600, 1200, 2400, 4800, and 9600 ( >= 4801) seconds |
FREQUENCY |
NUMBER |
A non-negative integer that shows the number of times a particular bucket was hit by theSYNC LNS process |