Oracle Data Guard Broker 是一个分布式管理框架,它不但自动化了 Data Guard 配置的创建、维护和监视,并对这些操作进行统一管理。可以通过 Oracle 企业管理器(它使用 Broker)或 Broker 的专用命令行界面 (DGMGRL) 执行所有管理操作。Data Guard Broker 11 g 还可以使用最大可用性或最佳性能模式将 Data Guard 配置为在数据库出现故障时自动切换。
Data Guard Broker
- 使用最大可用性或最佳性能模式针对配置启用自动数据库故障切换
- 启用可配置事件来触发对目标备用数据库的即时自动切换
- 改善了对重做传输选项的支持,使管理员可以为重做传输服务指定连接描述
- 消除在最大可用性和最佳性能保护模式间更换的数据库停机时间
- 支持使用 Oracle 集群件和冷故障切换集群针对高可用性配置单一实例数据库
1.配置Broker为自启动
在主备库查看dg_broker_start 参数:
该参数默认会被设为FALSE,设为TRUE会随数据库实例而自动启动
该参数只能在Broker未处于运行状态时进行修改
DMON进程是被Broker管理的Oracle后台进程,Broker启动后,DMON进程也就被随之创建
SQL>SHOW PARAMETER DG
NAME TYPE VALUE
----------------------------------------------- ------------------------------
dg_broker_config_file1 string /u01/app/oracle/product/11.2.0/db_1/dbs/dr1standby.dat
dg_broker_config_file2 string /u01/app/oracle/product/11.2.0/db_1/dbs/dr2standby.dat
dg_broker_start boolean TRUE
SQL>alter system set dg_broker_start = true;
Systemaltered.
SQL>SHOW PARAMETER DG_BROKER_START
NAME TYPE VALUE
----------------------------------------------- ------------------------------
dg_broker_start boolean TRUE
参数DG_BROKER_CONFIG_FILE1,DG_BROKER_CONFIG_FILE2,对于RAC,需要改到共享存储上;
只能在Broker处于未运行状态(DG_BROKER_START=FALSE)该参数才能被修改
这一步如果不配置,使用Broker的时候会提示不可用:
[oracle@node3admin]$ dgmgrl sys/oracle@std
DGMGRLfor Linux: Version 11.2.0.3.0 - 64bit Production
Copyright(c) 2000, 2009, Oracle. All rights reserved.
Welcometo DGMGRL, type "help" for information.
Connected.
DGMGRL>show configuration
Error:
ORA-16525: the Data Guard broker is not yet available
Configuration details cannot be determined by DGMGRL
=================================================
// *Cause: The Data Guard broker process was either notyet started, was
// initializing, or failed to start.
// *Action: If the broker has notbeen started, set the DG_BROKER_START
// initialization parameter to true andallow the broker to finish
// initializing before making therequest. If the broker failed to
// start, check the Data Guard log forpossible errors. Otherwise,
// retry the operation.
2.启用 Flashback
可以通过如下SQL 查看是否启用了Flashback:
SQL>select flashback_on from v$database;
FLASHBACK_ON
------------------
NO
在主备库查看:
SQL>show parameter db_recovery_file_dest
NAME TYPE VALUE
----------------------------------------------- ------------------------------
db_recovery_file_dest string /u01/app/oracle/fast_recovery_area
db_recovery_file_dest_size big integer 1G
在启用Flashback database 之前,需要先设置db_recovery_file_dest_size参数,而后才可以设置db_recovery_file_dest
如果在备库开启闪回需要先取消recover 进程,不然会报错。
SQL>alter database flashback on;
alterdatabase flashback on
*
ERRORat line 1:
ORA-01153:an incompatible media recovery is active
SQL>alter database recover managed standby database cancel;
Databasealtered.
SQL>alter database flashback on;
Database altered.
SQL>select flashback_on from v$database;
FLASHBACK_ON
------------------
YES
SQL>alter database recover managed standby database disconnect from session usingcurrent logfile;
Database altered.
3.创建配置及添加备库
[oracle@node2/]$ dgmgrl
DGMGRLfor Linux: Version 11.2.0.1.0 - Production Copyright (c) 2000, 2005, Oracle.All rights reserved. Welcome to DGMGRL, type "help" for information.
DGMGRL>connect sys/oracle@primary
Connected.
DGMGRL>createconfiguration 'Broker' as primary database is 'primary' connect identifier is primary;
Configuration"Broker" created with primary database "primary"
DGMGRL>add database'standby' as connect identifier is standby maintained as physical;
Database"standby" added
DGMGRL> show configuration
Configuration
Name: Broker
Enabled: NO
Protection Mode: MaxAvailability
Fast-Start Fai