Oracle Dataguard之Real-Time Apply
Oracle Dataguard一共支持三种模式:最大可用模式(Maximum Availability),最大性能模式(Maximum Performance),最大保护模式(Maximum Protection)。默认创建的是最大性能模式(Maximum Performance)。关于三者的区别,我们来看官方的定义。
Maximum Availability
Transactions do not commit until all redo data needed to recover those transactions has been written to the online redo log and to the standby redo log on at least one synchronized standby database.If the primary database cannot write its redo stream to at least one synchronized standby database,it operates as if it were in maximum performance mode to preserve primary database availability until it is again able to write its redo stream to a synchronized standby database.
Maximum Performance
This is accomplished by allowing transactions to commit as soon as all redo data generated by those transactions has been written to the online log. Redo data is also written to one of more standby databases,but this is done asynchronously with respect to transaction commitment,so primary database performance is unaffected by delays in writing redo data to the standby databases.
Maximum Protection
This protection mode ensures that no data loss will occur if the primary database fails.To provide this level of protection,the redo data needed to recover a transaction must be written to both the online redo log and to the standby redo on at least one synchronized standby database before the transaction commits.To ensure that data loss cannot occur,the primary database will shut down,rather than continue processing transactions,if it cannot write its redo stream to at least one synchronized standby database.
三种模式对于日志传输的要求如下:

在前篇文章中-《Oracle Dataguard之物理standby的基本配置》,我们最后配置出来的是Physical Standby Database 最大性能模式下的异步传输,现在我们配置该模式下的Real-Time Apply。启用Real-Time Apply需要配置standby redo log,而这也是其它两种模式的基础。
一、 创建standby redo log
1> 查询主库上online redo log的组数和大小 -->> node1 上操作
SQL> select group#,bytes/1024/1024 "size" from v$log;
GROUP# size
------ ----------
1 50
2 50
3 50
2> 在备库上添加standby redo log -->> group比主库多一组,大小和主库一样,node2上操作
[oracle@node2 ~]$ mkdir /u01/standby
SQL> alter database add standby logfile '/u01/standby/standby01.log' size 50M;
SQL> alter database add standby logfile '/u01/standby/standby02.log' size 50M;
SQL> alter database add standby logfile '/u01/standby/standby03.log' size 50M;
SQL> alter database add standby logfile '/u01/standby/standby04.log' size 50M;
注意:请确保已关闭Redo Apply,不然会报以下错误
SQL> alter database add standby logfile '/u01/standby/standby01.log' size 50M;
alter database add standby logfile '/u01/standby/standby01.log' size 50M
*
ERROR at line 1:
ORA-01156: recovery or flashback in progress may need access to files
关闭Redo Apply,
SQL> alter database recover managed standby database cancel;
二、 修改主库的配置参数 -->> node1 上操作
SQL> alter system set log_archive_dest_2='service=to_victor lgwr affirm sync valid_for=(online_logfiles,primary_role) db_unique_name=victor';
SQL> alter system switch logfile;
三、 在备库上启用Real-Time Apply -->> node2 上操作
SQL> alter database recover managed standby database using current logfile disconnect from session;
四、 测试
除了用前篇文章中,查看归档日志的应用情况来验证dataguard的配置以外,本文将采用实际案例进行测试。
1> 在主库上新建一个测试表
SQL> create table test(id number);
SQL> insert into test values(1);
2> 在备库中检测
SQL> select * from test;
no rows selected
3> 在主库中提交事务
SQL> commit;
4> 在备库中检测
SQL> select * from test;
ID
----------
1
总结:
这个总结包括物理standby的基本配置和本文中的Real-Time Apply
1> 如果只设置主/次两个本地归档目的地,可以使用初始化参数log_archive_dest指定主归档目的地,使用初始化参数log_archive_duplex_dest指定次归档目的地。
在数据库中,初始换参数log_archive_dest和log_archive_duplex_dest与log_archive_dest_n只能使用一组来设置归档目的地,不能同时使用
2> 备库log_archive_dest_1如果没有显性指定,默认的归档目录将是$ORACLE_HOME/dbs.倘若显性指定,但valid_for不是
(standby_logfiles,standby_role)或者(all_logfiles,all_roles),则该设置无效,报警日志中将报以下错误:
ORA-16032: parameter STANDBY_ARCHIVE_DEST destination string cannot be translated
归档目录将继续为$ORACLE_HOME/dbs
3> 在本文中,log_archive_dest_1='location=/u01/archivelog valid_for=(standby_logfiles,standby_role) db_unique_name=victor',如果再显性指定
log_archive_dest_3='location=/u01/standbyarchive valid_for=(standby_logfiles,standby_role) db_unique_name=victor',将会有两份standby的
归档日志产生,没有必要,只需要一个log_archive_dest_1即可
4> 最大性能模式下,如果是async,即异步,则需要主库切一次日志,备库采用应用。而如果启用Real-Time Apply,则只需要主库事务commit, 备库就能应用
5> 删除日志
SQL> alter database drop logfile group 7;
6> 如果发出了alter database recover managed standby database cancel;这个命令,MRP(Media Recovery process)将停止工作,但
RFS(Remote file server)仍继续工作
7> 如果没有standby redo logs,是不能启动real time apply的
SQL> alter database recover managed standby database using current logfile disconnect from session;
alter database recover managed standby database using current logfile disconnect from session
*
ERROR at line 1:
ORA-38500: USING CURRENT LOGFILE option not available without standby redo logs
8> standby数据库startup后,没有发出alter database recover managed standby database disconnect from session这个命令,RFS仍然工作,只要监听
都ok
9> disconnect from session代表这个命令后台运行。
10> Real-Time Apply的原理图

Oracle Dataguard之Real-Time Apply的更多相关文章
- Oracle Dataguard之failover
Oracle Dataguard中,角色转换包含两类:Switchover和Failover.上文<Oracle Dataguard之switchover>中,我们已经谈过了switcho ...
- Oracle Dataguard之switchover
Oracle Dataguard的角色转换包含两类:Switchover和Failover.Switchover指主备之间角色转换,主库降为备库,备库升级为主库.而failover则是指主库出现问题时 ...
- Oracle Dataguard之物理standby的基本配置
尽管网上有很多Oracle Dataguard的配置教程,但不难发现,很多采用的是rman duplicate这种方法,尽管此种方法较为简便.但在某种程度上,却也误导了初学者,虽说也能配置成功,但只知 ...
- Oracle DataGuard 物理Standby 搭建(上)
物理standby database 环境搭建 Arch asysnc Oracle Dataguard host IP Oracle_sid DB_unique_name FAL_server FA ...
- 9. Oracle DataGuard的介绍
一. Oracle DataGuard简介 Oracle DataGuard:简称DG.是由一个Primary Database(主库)和一个或者多个Standby Database(备库)组成.对O ...
- [Oracle] DataGuard switchover
Oracle DataGuard switchover 2013/07/11 Tag.Data Guard,primary,standby,switchover 切换前primary site和sta ...
- Oracle DataGuard主库丢失归档日志后备库的RMAN增量恢复一例
第一部分 问题描述和环境状态确认 ----1. 问题场景 Oracle DataGuard主库丢失archivelog,如何不重建备库完成同步? 在Oracle DataGuard主从同步过程中可能 ...
- Oracle DataGuard主备切换(switchover)
Oracle DataGuard主备切换可以使用传统的手动命令切换,也可以使用dgmgr切换,本文记录手动切换. (一)将主库切换为物理备库 STEP1:查看主库状态 SQL> SELECT O ...
- Oracle DataGuard搭建(一)
第一次搭建oracle dataguard.学oracle很长时间,却没有完整的搭过dg,说起来让人笑.总得有第一次,而且第一次总是很痛苦的. 数据库版本: Oracle Database 11g E ...
随机推荐
- LR loadrunner参数化-笔记
LR在录制程序运行的过程中,VuGen(脚本生成器) 自动生成了包含录制过程中实际用到的数值的脚本,如果你企图在录制的脚本中使用不同的数值执行脚本的活动(如查询.提交等等),那么你必须用参数值取代 ...
- php tools for visual studio 2013 完美 破解 Cracker
PHP Tools for Visual Studio 2013,这个是 目前在 Visual Studio 2010/2012/2013 中 下最好用的php插件了, 破解 好的 Cracker ...
- 项目修改有感_主要是以js、Gridview为主
1.弹出提示:confirm--弹出的窗口有确认.取消按钮 alert--弹出的窗口只有确认按钮 例:若需要在点击确认后执行其他操作(confirm) var toAlert = confirm(&q ...
- iOS关于定制某个控件四个角是否为圆角
UIView *myView=[[UIView alloc]initWithFrame:CGRectMake(50, 70, 200, 200)]; UIBezierPath * bezierPath ...
- C++之友元
友元提供了不同类的成员函数之间.类的成员函数与一般函数之间进行数据共享的机制.通过友元,一个不同函数或另一个类中的成员函数可以访问类中的私有成员和保护成员.C++中的友元为封装隐藏这堵不透明的墙开了一 ...
- 手Q兴趣号的价值在哪里
拥有5.21亿月活跃用户,如果不做点什么东西出来,实在是浪费至极.如此庞大的用户量,如果能够将内容贡献出来,那将是恐怖的,QQ空间产品就是很好的佐证. QQ群让个体用户能够连接在一起,单个的用户关系链 ...
- node(thrift)
thrift是一种跨语言的RPC框架,据说uber采在node.js项目中采用thrfit后,比原有的http+json的方式提高近20倍的性能. 所谓的RPC本质上就是客户端将需要调用的方法名和参数 ...
- Visual Studio 2015 RC版官方下载(ISO)
微软Build2015开发者大会发布了下代开发套件Visual Studio 2015 RC候选版,覆盖企业版.专业版以及免费授权的Community社区版,原生支持开发通用型Windows Apps ...
- nodejs获取客户端IP Address
在网上看见很多问node.js如何获取客户端IP,所以记录下来,以供大家参考. function getClientIp(req) { return req.headers['x-forwarded- ...
- Python--增量循环删除MySQL表数据
需求场景: 有一业务数据库,使用MySQL 5.5版本,每天会写入大量数据,需要不定期将多表中“指定时期前“的数据进行删除,在SQL SERVER中很容易实现,写几个WHILE循环就搞定,虽然MySQ ...