如何针对物理DataGuard设置延时日志应用?
By JaneZhang(张建英) on 七月 09, 2012
为了设置延时Apply,需要在log_archive_dest_n 参数上使用“DELAY=",比如:DELAY=360(单位为分钟),表示延时360分钟(6小时)。比如:
SQL〉alter system set log_archive_dest_2='SERVICE=standby LGWR SYNC AFFIRM DELAY=360 VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) COMPRESSION=ENABLE DB_UNIQUE_NAME=standby';
如果只指定了DELAY参数,但是没有指定具体的值,默认是30分钟。
需要注意的是,如果已经启用了实时日志应用(real-time apply ),DELAY这个参数会被忽略,因此不会启用延时日志应用,同时,在备库的alert log中您可以看到类似下面的信息:
WARNING: Managed Standby Recovery started with USING CURRENT LOGFILE
DELAY 360 minutes specified at primary ignored <<<<<<<<<
这种情况下,需要停止实时日志应用,按照非实时模式启动MRP,比如:
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
请参考下面的具体的例子:
1. 查看主库的参数设置:
SQL> show parameter log_archive_dest_2
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_2 string SERVICE=STANDBY LGWR SYNC AFFI
RM VALID_FOR=(ONLINE_LOGFILES,
PRIMARY_ROLE) DB_UNIQUE_NAME=S
TANDBY
2. 在主库设置延时5分钟:
SQL> alter system set log_archive_dest_2='SERVICE=STANDBY LGWR SYNC AFFIRM delay=5 VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=STANDBY';
3. 验证是否延时:
主库执行:
SQL> alter system switch logfile;
System altered.
SQL> select max(sequence#) from v$archived_log;
MAX(SEQUENCE#)
--------------
28
备库:
Wed Jun 13 19:48:53 2012
Archived Log entry 14 added for thread 1 sequence 28 ID 0x4c9d8928 dest 1:
ARCb: Archive log thread 1 sequence 28 available in 5 minute(s)
Wed Jun 13 19:48:54 2012
Media Recovery Delayed for 5 minute(s) (thread 1 sequence 28) <<<<<<<<延时生效
Wed Jun 13 19:53:54 2012
Media Recovery Log /home/oracle/arch1/standby/1_28_757620395.arc<<<<<5分钟后才应用这个归档
Media Recovery Waiting for thread 1 sequence 29 (in transit)
更多的信息,请参考官方文档:
http://docs.oracle.com/cd/E11882_01/server.112/e25608/log_apply.htm
Oracle® Data Guard Concepts and Administration
11g Release 2 (11.2)
Part Number E25608-03