Transactions on the primary are considered protected as soon as Data Guard has written the redo data to persistent storage in a standby redo log file. Once that is done, acknowledgment is quickly made back to the primary database so that it can proceed to the next transaction. This minimizes the impact of synchronous transport on primary database throughput and response time. To fully benefit from complete Data Guard validation at the standby database, be sure to operate in real-time apply mode so that redo changes are applied to the standby database as fast as they are received. Data Guard signals any corruptions that are detected so that immediate corrective action can be taken.”
最大保护模式是完全HA架构理想中的事务模式。如果Primary数据库进行一个事务,连带Standby数据库也要同步进行操作。如果由于网络、执行模式等原因,Standby不能够跟上主库的操作,那么主库会放弃事务,并且强制停库。
保护模式的三种和数据库之间传输日志的机制是密切相关的。主要体现是否同步传输Redo日志和对日志进行确认两个方面。我们配置三种日志模式,一定要以Log_Archive_Config参数配置为基础。
基于同一主机配置 Oracle 11g Data Guard
Oracle Data Guard (RAC+DG) 归档删除策略及脚本
Oracle 11g Data Guard Error 16143 Heartbeat failed to connect to standby 处理方法
Maximum Availability
Maximum Performance
Maximum Protection
AFFIRM
NOAFFIRM
AFFIRM
SYNC
ASYNC
SYNC
DB_UNIQUE_NAME
DB_UNIQUE_NAME
DB_UNIQUE_NAME
下面通过一系列的测试,来分析三种保护模式的工作行为方式。
2、环境介绍
笔者使用环境为Oracle 11gR2,具体版本为11.2.0.4。主备库环境已经搭建完成,同步保护模式是采用默认方式。
主库信息:
SQL> select name, open_mode, database_role, protection_mode from v$database;
NAME OPEN_MODE DATABASE_ROLE PROTECTION_MODE
--------- -------------------- ---------------- --------------------
VLIFE READ WRITE PRIMARY MAXIMUM PERFORMANCE
SQL> select instance_name from v$instance;
INSTANCE_NAME
----------------
vlife
主库与备库连接方式,采用默认的异步非确认方式。
SQL> select dest_id, dest_name, TRANSMIT_MODE, ASYNC_BLOCKS, AFFIRM TYPE, VALID_NOW, VALID_TYPE, VALID_ROLE, DB_UNIQUE_NAME from v$archive_dest where status<>'INACTIVE';
DEST_ID DEST_NAME TRANSMIT_MODE ASYNC_BLOCKS TYPE VALID_NOW VALID_TYPE VALID_ROLE DB_UNIQUE_NAME
---------- -------------------- ------------- ------------ ---- ---------------- --------------- ------------ ---------------
1 LOG_ARCHIVE_DEST_1 SYNCHRONOUS 0 NO YES ALL_LOGFILES ALL_ROLES NONE
2 LOG_ARCHIVE_DEST_2 ASYNCHRONOUS 61440 NO YES ONLINE_LOGFILE PRIMARY_ROLE vlifesb
此时,传输通道配置。
SQL> show parameter LOG_ARCHIVE_DEST_2;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_2 string SERVICE=vlifesb valid_for=(online_logfiles,primary_role) db_unique_name=vlifesb
log_archive_dest_20 string
log_archive_dest_21 string
备库信息如下:
SQL> select name, open_mode, database_role, protection_mode from v$database;
NAME OPEN_MODE DATABASE_ROLE PROTECTION_MODE
--------- -------------------- ---------------- --------------------
VLIFE READ ONLY WITH APPLY PHYSICAL STANDBY MAXIMUM PERFORMANCE
SQL> select instance_name from v$instance;
INSTANCE_NAME
----------------
vlifesb
SQL> col dest_name for a20;
SQL> select dest_id, dest_name, TRANSMIT_MODE, ASYNC_BLOCKS, AFFIRM TYPE, VALID_NOW, VALID_TYPE, VALID_ROLE, DB_UNIQUE_NAME from v$archive_dest where status<>'INACTIVE';
DEST_ID DEST_NAME TRANSMIT_MODE ASYNC_BLOCKS TYPE VALID_NOW VALID_TYPE VALID_ROLE DB_UNIQUE_NAME
---------- -------------------- ------------- ------------ ---- ---------------- --------------- ------------ ------------------------------