本文接着前面做的DataGuard 实验, 前面搭建的Physical Standby 不能做到实时同步主库数据,当主库Online Redo 归档后,才会将这个归档日志传到备机并Applied 到备库,这个延迟时间较长,如果主库业务不繁忙,可能好几天才产生一个归档文件,这时备库数据和主库数据相差就好几天了,今天看了下
Oracle DataGuard官方文档,Oracle 提供实时应用日志的方式,以下摘自官网,就不翻译了。
Using Real-Time Apply to Apply Redo Data Immediately
If the real-time apply feature is enabled, log apply services can apply redo data as it is received,
without waiting for the current standby redo log file to be archived. This results in faster switchover
and failover times because the standby redo log files have been applied already to the standby database by the time
the failover or switchover begins.
Figure 6-1 shows a Data Guard configuration with a local destination and a standby destination.
As the remote file server (RFS) process writes the redo data to standby redo log files on the standby database,
log apply services can recover redo from standby redo log files as they are being filled.
下面是在已经搭建Physical Standby 的基础上进行,
1 停 Standby REDO 应用进程 (On standby )
1 |
alter database recover managed standby database cancel; |
2 增加 STANDBY redo 日志 (Both on standby and Primary)
1 |
ALTER DATABASE ADD STANDBY LOGFILE thread 1 GROUP 4 ('/oradata/MANUA/stadnbylog/stdlog01.rdo') SIZE 50M reuse; |
3 启动数据库到实时恢复管理模式(On Standby)
1 |
SQL> alter database recover managed standby database using current logfile disconnect from session; |
4 主库创建一张测试表
1 |
SQL> create table test_1 (id integer,name varchar2(32)); |
注意,这步操作后,不执行日志切换操作 “Alter system switch log file”, 并接着观察日志是否进来。
5 备库上初次验证
1 |
alter database recover managed standby database cancel; |
说明:第下次验证发现数据没有传过来,表是已经创建上了,猜想可能有延迟,再等等。
6 过了大概五分钟后,备库上再次验证
1 |
alter database recover managed standby database cancel; |
发现数据已经同步了。
总结:
- 在备库上创建 standby log ,可以实现主备机实时数据同步。
- 这种实时数据同步的方法比归档日志传递的方法高效得多,但也有延迟,这个延迟应该在五分钟以内。
原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/236358.html