当前位置:首页 > 开发 > 数据库 > 正文

Active Data Guard

发表于: 2014-10-06   作者:czmmiao   来源:转载   浏览次数:
摘要: Oracle Active Data Guard is a new option with Oracle 11g.Oracle Active Data Guard enables read-only access to a physical standby database for queries, sorting, reporting, Web-based access, and so on,

Oracle Active Data Guard is a new option with Oracle 11g.
Oracle Active Data Guard enables read-only access to a physical standby database for queries, sorting, reporting, Web-based access, and so on, while continuously applying changes received from the production database.
In older versions of Oracle Data Guard, you were able to open your standby database in read-only mode, but the database was not able to receive the redo from the production DB.
For some applications Active Data Guard can represent a more efficient use of Oracle licenses on the standby database. Active Data Guard is available on Enterprise Edition only and is cost option which must be licensed on both the primary and standby database.
Before you perform these actions, a Data Guard Broker configuration should be already configured. If you need to configure Data Guard Broker, GO HERE.

Enable Active Data Guard using DG Broker
Connect to DG Broker and disable the MRP Process
$ dgmgrl
DGMGRL> connect sys
DGMGRL> show configuration
DGMGRL> edit database 'STDBY' set state = 'apply-off';
DGMGRL> show configuration
Open the physical standby database in read-only mode
sqlplus> alter database open read only;

Connect to DG Broker again and enable the MRP Process
$ dgmgrl
DGMGRL> connect sys
DGMGRL> edit database 'STDBY' set state = 'apply-on';
DGMGRL> show configuration

Now you can perform any Read Operation on the Standby!!!

As you can see, this process is very simple, you just type a few commands, re-start your DB and you are ready to test this amazing feature!!!

Redo data will continue to be received and applied by the database while it is operating in read only mode.

If you perform any DDL and DML operation in PROD, you will see those operations also reflected on the Standby. As an example you can insert some data into a table in PROD and that row will be also inserted in the Standby.

To determine whether a standby database is using Active Data Guard use the following query:
SQL> SELECT database_role, open_mode FROM v$database;
DATABASE_ROLE         OPEN_MODE
-------------------- --------------------
PHYSICAL STANDBY     READ ONLY WITH APPLY

Disable Active Data Guard using DG Broker
Connect to DG Broker and disable the MRP Process
$ dgmgrl
DGMGRL> connect sys
DGMGRL> show configuration
DGMGRL> edit database 'STDBY' set state = 'apply-off';
DGMGRL> show configuration

Shutdown the physical standby database
sqlplus> shutdown immediate;
sqlplus> startup mount;

Connect to DG Broker again and enable the MRP Process
$ dgmgrl
DGMGRL> connect sys
DGMGRL> edit database 'STDBY' set state = 'apply-on';
DGMGRL> show configuration

Now you Physical standby will be performing as usual


Enable Active Data Guard using SQL*Plus
We need to mention that the preferred method to Enable the Active Data Guard is by using the Broker.
As you can see, this process is very simple, you just type a few commands, re-start your DB and you are ready to test this amazing feature!!!
Redo data will continue to be received and applied by the database while it is operating in read only mode.

Connect to the physical standby, cancel the managed standby recovery, then open it in read only mode. After that enable again the managed recovery process
sqlplus> alter database recover managed standby database cancel
sqlplus> alter database open read only;
sqlplus> alter database recover managed standby database using current logfile disconnect;

Now the standby has been placed in managed recovery mode applying the log files while it is open.
Now you can perform any Read Operation on the Standby

If you perform any DDL and DML operation in PROD, you will see those operations also reflected on the Standby.
Confirm, changes applying on standby database

On the primary create any table, do a log switch and check the maximum log sequence number:
SQL> create table test (cd number);
SQL> alter system switch logfile;
SQL> select max(Sequence#) from v$log;

Connect to the Standby and also check the maximum log sequence number and the existence of that table:
SQL> select max(Sequence#) from v$log;
SQL> describe test;

Disable Active Data Guard using SQL*Plus
Connect to the physical standby and shut it down
sqlplus> shutdown immediate

Then Startup and mount it.
sqlplus> startup mount;
sqlplus> alter database recover managed standby database using current logfile disconnect;

Now you Physical standby will be performing as usual

Checking Different Scenarios
If you start a database in SQL*Plus using the STARTUP command and then invoke managed recovery, the Active Data Guard will be enabled.
For example:
SQL> STARTUP

SQL> SELECT database_role, open_mode FROM v$database;

DATABASE_ROLE         OPEN_MODE
-------------------- --------------------
PHYSICAL STANDBY     READ ONLY

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE disconnect;

SQL> SELECT database_role, open_mode FROM v$database;

SQL> SELECT database_role, open_mode FROM v$database;

DATABASE_ROLE         OPEN_MODE
-------------------- --------------------
PHYSICAL STANDBY     READ ONLY WITH APPLY

However, if the database is started in SQL*Plus using the STARTUP MOUNT command and then managed recovery is invoked, Active Data Guard will not be enabled.
SQL> STARTUP MOUNT

SQL> SELECT database_role, open_mode FROM v$database;

DATABASE_ROLE         OPEN_MODE
-------------------- --------------------
PHYSICAL STANDBY     MOUNTED

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE disconnect;

SQL> SELECT database_role, open_mode FROM v$database;
DATABASE_ROLE         OPEN_MODE
-------------------- --------------------
PHYSICAL STANDBY     MOUNTED

If the database has been started in SQL*Plus using STARTUP MOUNT and the database is subsequently opened read only, then invoking managed recovery will enable Active Data Guard.
For example:
SQL> STARTUP MOUNT

SQL> SELECT database_role, open_mode FROM v$database;

DATABASE_ROLE         OPEN_MODE
-------------------- --------------------
PHYSICAL STANDBY     MOUNTED

SQL> ALTER DATABASE OPEN READ ONLY;

SQL> SELECT database_role, open_mode FROM v$database;
DATABASE_ROLE         OPEN_MODE
-------------------- --------------------
PHYSICAL STANDBY     READ ONLY

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE disconnect;

SQL> SELECT database_role, open_mode FROM v$database;
DATABASE_ROLE         OPEN_MODE
-------------------- --------------------
PHYSICAL STANDBY     READ ONLY WITH APPLY

 

参考至:http://pafumi.net/Active_Data_Guard.html

如有错误,欢迎指正

邮箱:czmcj@163.com

Active Data Guard

  • 0

    开心

    开心

  • 0

    板砖

    板砖

  • 0

    感动

    感动

  • 0

    有用

    有用

  • 0

    疑问

    疑问

  • 0

    难过

    难过

  • 0

    无聊

    无聊

  • 0

    震惊

    震惊

编辑推荐
1.Oracle Data Guard概述<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:
是什么: pirmary/production database + physical standby database(redo) + logical standby data
Data Guard broker概览 Data Guard broker是建立在Data Guard基础上的一个对Data Guard配置,集中管
Data Gurad概述 不少未实际接触过dg的初学者可能会下意识以为data guard是一个备份恢复的工具。我要
1.概述 Data Guard支持两种使用LNS(Log Network Server)进程的重做传输方法:同步(SYNC)和异步
1、Data Guard组件介绍 Data Guard架构归类为3个主要的组件。 Data Guard 重做传输服务 重做传输服
Data Guard主要提供两个服务: 1)Redo传输服务:即把Primay端的Redo日志传输到一个或多个Standby目
配置data guard broker配置文件基本参数 每个数据库中都会维护两份配置文件,这样能保证任何时候我
Data Guard提供如下三种数据保护模式: 1)最高保护模式(Maximum Protection) 这里的”最大保护“
数据库状态管理 数据库状态分类 broker管理的数据库可以存在多种不同的状态,在DG中扮演不同角色的
版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号