Data Guard备库日志的实时应用与非实时应用

在Dataguard的备库上应用日志的时候,通常有两个语句,但是这两个语句是有区别的,一个是实时应用,一个是非实时应用。

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

测试 

--在备库上启用实时应用日志,并创建表

alter database recover managed standby database using current logfile disconnect;
19:23:46 SYS@test>create table zbb.t3(id number);

Table created.

Elapsed: 00:00:00.03
19:23:59 SYS@test>

--在备库上查看表,立刻生效

ZBB@test_stdby>set time on
19:24:02 ZBB@test_stdby>desc t3
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 ID                                                 NUMBER

19:24:04 ZBB@test_stdby>

--drop掉表,在备库上启用日志应用,但不是实时的

drop table zbb.t3 purge;
alter database recover managed standby database cancel;
alter database recover managed standby database disconnect from session;

--在主库上创建表

19:26:51 SYS@test>create table zbb.t3 (id number);

Table created.

Elapsed: 00:00:00.03

--在备库上查看创建的表,表不存在

19:28:35 SYS@test>
19:28:38 ZBB@test_stdby>desc zbb.t3
ERROR:
ORA-04043: object zbb.t3 does not exist


19:28:41 ZBB@test_stdby>

19:30:04 ZBB@test_stdby>desc zbb.t3
ERROR:
ORA-04043: object zbb.t3 does not exist


19:30:08 ZBB@test_stdby>

--查看是否启用实时应用

select recovery_mode from v$archive_dest_status where dest_id=2;
19:28:35 SYS@test>select recovery_mode from v$archive_dest_status where dest_id=2;

RECOVERY_MODE
-----------------------
MANAGED

Elapsed: 00:00:00.01
19:31:34 SYS@test>

SYS@test>select recovery_mode from v$archive_dest_status where dest_id=2;

RECOVERY_MODE
-----------------------
MANAGED REAL TIME APPLY

SYS@test>

--关于recover mode的说明 。查询视图V$ARCHIVE_DEST_STATUS 

RECOVERY_MODE VARCHAR2(23) Current apply mode at the archival destination:
  • IDLE - Managed recovery is not active

  • MANAGED - Managed recovery is active

  • MANAGED REAL TIME APPLY - Log apply services recover redo data from standby redo logs at the same time the logs are being written to, as opposed to recovering redo from archived redo logs when a log switch occurs

  • LOGICAL REAL TIME APPLY - Real time SQL Apply

  • LOGICAL APPLY - SQL Apply

END

你可能感兴趣的:(Data,Guard)