文章摘要:通过实验模拟DataGuard 在最高可用模式下,模拟故障导致主库不能向物理备库(Physical Standby )传输日志时,主备库情况。
Data Guard 提供三种数据保护模式:最大保护(Maximum Protection),最大可用(Maximum Availability)和 最大性能(Maximum Performance)。
最高可用模式(Maximum Availability)能提供非常高级别的数据保护。在这种模式下,只有当所有的redo日志备写入至少一个standby database时,事物才能提交。
当主库不能将redo日志写入至少一个standby database时,那么DG就相当于在最大性能(maximum performance)模式工作。
【Oracle11g官方文档中关于Dataguard 最高可用模式的介绍】
This protection mode provides the highest level of data protection that is possible without compromising the availability of a primary database. 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.
This mode ensures that no data loss will occur if the primary database fails, but only if a second fault does not prevent a complete set of redo data from being sent from the primary database to at least one standby database.
![](http://img.blog.itpub.net/blog/attachment/201408/24/29475508_1408881204CFzx.jpg?x-oss-process=style/bb)
【实验环境】
操作系统:Red Hat Enterprise Linux Server release 5.4数据库:Oracle Database 11g Enterprise Edition Release 11.2.0.3.0
【主库、物理备库结构信息】
![](http://img.blog.itpub.net/blog/attachment/201408/24/29475508_1408880813Yvz7.jpg?x-oss-process=style/bb)
【实验过程】
主库 Primary database:绿色
物理备库 Physical standby database:黄色
1、查询主、备库角色和状态
![](http://img.blog.itpub.net/blog/attachment/201408/24/29475508_140888083561WC.jpg?x-oss-process=style/bb)
![](http://img.blog.itpub.net/blog/attachment/201408/24/29475508_1408880848Ttth.jpg?x-oss-process=style/bb)
2、模拟故障,主库停止向远程传归档
alter system set log_archive_dest_state_2=defer;
show parameter log_archive_dest_stat_2
3、查看状态和当前保护级别
主库查看发现,protection_mode仍然是最高可用模式,但当前protection_level显示resynchronization
即保护模式的目标没变,当前状态变了,需要同步。此时相当于 【最大性能模式】
select database_role,protection_mode,protection_level from v$database;
![](http://img.blog.itpub.net/blog/attachment/201408/24/29475508_1408880894gJcy.png?x-oss-process=style/bb)
4、主库创建测试表,插入数据并提交
5、主、备库查看日志,备库一直在等待
![](http://img.blog.itpub.net/blog/attachment/201408/24/29475508_1408880919SPz2.jpg?x-oss-process=style/bb)
![](http://img.blog.itpub.net/blog/attachment/201408/24/29475508_1408880929wVb2.jpg?x-oss-process=style/bb)
6、主库开启远程归档
主库开启远程归档,查看保护模式,protection_level已经变成 maximum availability 最高可用模式
alter system set log_archive_dest_stat_2=enable;
select database_role,protection_mode,protection_level from v$database;
![](http://img.blog.itpub.net/blog/attachment/201408/24/29475508_1408880937rR16.jpg?x-oss-process=style/bb)
7、查看跟踪日志、测试表
主库已经开始将日志传向备库, FAL 挖 日志代沟
![](http://img.blog.itpub.net/blog/attachment/201408/24/29475508_1408880947toWE.jpg?x-oss-process=style/bb)
备库查看测试表,已经可以查到
![](http://img.blog.itpub.net/blog/attachment/201408/24/29475508_1408880957UW1Z.jpg?x-oss-process=style/bb)
【实验总结】
当故障恢复,主库可以重新向备库传输日志后,保护模式重新恢复为最高可用模式,备库可以通过FAL发现日志代沟(GAP)并同主库同步。
吕星昊
2014.8.24
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29475508/viewspace-1256939/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/29475508/viewspace-1256939/