重庆思庄Oracle、Redhat认证学习论坛

标题: 备库日志的实时应用与非实时应用 [打印本页]

作者: mahan    时间: 2023-4-7 16:19
标题: 备库日志的实时应用与非实时应用
在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>






欢迎光临 重庆思庄Oracle、Redhat认证学习论坛 (http://bbs.cqsztech.com/) Powered by Discuz! X3.2