DataGuard broker是建立在DataGuard之上的集中管理操作的一个平台,配置简单,使用起来也很方便。主要由DMON进程负责设置和维护broker配置,在RAC环境中,配置文件是由组成这个RAC的各个instance共享的。在实际管理中我们只需把一个broker配置当成单个的单元(可以包含多个broker配置,但是每个数据库只维护一组配置文件)管理就可以了,剩下的工作由DMON去做。当执行一个影响到多个数据库的命令的时候,实际上DMON做了下面的操作:
在Primary数据库上处理请求 协调其他相关数据库上的DMON进程处理相应的请求 更新本地系统中的配置文件 与其他数据库上的DMON进程通讯以更新各自的配置文件
A.配置静态监听
在主备库各个节点的$GI_HOME/network/admin/listener.ora增加下面的内容
prod1
SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME =prod_DGMGRL) (SID_NAME = prod1) (ORACLE_HOME = /pgold/ordb/oracle/product/112) ) )
prod2
SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME =prod_DGMGRL) (SID_NAME = prod2) (ORACLE_HOME = /pgold/ordb/oracle/product/112) ) )stdby1
SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME =stdby_DGMGRL) (SID_NAME = stdby1) (ORACLE_HOME = /pgold/ordb/oracle/product/112) ) )stdby2
SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME =stdby_DGMGRL) (SID_NAME = stdby2) (ORACLE_HOME = /pgold/ordb/oracle/product/112) ) )
B.启用DG broker
在主库上启用dg broker
alter system set dg_broker_config_file1='+DATA_PROD/prod/dr1prod.dat' scope=both; alter system set dg_broker_config_file2='+DATA_PROD/prod/dr2prod.dat' scope=both; alter system set dg_broker_start=true scope=both; [oracle@ohs1 ~]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.4.0 Production on Tue Nov 29 09:26:55 2016 Copyright (c) 1982, 2013, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Data Mining and Real Application Testing options SQL> alter system set dg_broker_config_file1='+DATA_PROD/prod/dr1prod.dat' scope=both; System altered. SQL> alter system set dg_broker_config_file2='+DATA_PROD/prod/dr2prod.dat' scope=both; System altered. SQL> alter system set dg_broker_start=true scope=both; System altered. SQL> exit Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Data Mining and Real Application Testing options在备库上启用dg broker
alter system set dg_broker_config_file1='+DATA_STDBY/stdby/dr1stdby.dat' scope=both; alter system set dg_broker_config_file2='+DATA_STDBY/stdby/dr2stdby.dat' scope=both; alter system set dg_broker_start=true scope=both; [oracle@ohs3 dbs]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.4.0 Production on Tue Nov 29 09:27:40 2016 Copyright (c) 1982, 2013, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Data Mining and Real Application Testing options SQL> alter system set dg_broker_config_file1='+DATA_STDBY/stdby/dr1stdby.dat' scope=both; System altered. SQL> alter system set dg_broker_config_file2='+DATA_STDBY/stdby/dr2stdby.dat' scope=both; System altered. SQL> alter system set dg_broker_start=true scope=both; System altered. SQL>DG broker帮助信息
帮助信息很方便,不看白皮书也可以
DGMGRL for Linux: Version 11.2.0.4.0 - 64bit Production Copyright (c) 2000, 2009, Oracle. All rights reserved. Welcome to DGMGRL, type "help" for information. Connected. DGMGRL> help The following commands are available: add Adds a standby database to the broker configuration connect Connects to an Oracle database instance convert Converts a database from one type to another create Creates a broker configuration disable Disables a configuration, a database, or fast-start failover edit Edits a configuration, database, or instance enable Enables a configuration, a database, or fast-start failover exit Exits the program failover Changes a standby database to be the primary database help Displays description and syntax for a command quit Exits the program reinstate Changes a database marked for reinstatement into a viable standby rem Comment to be ignored by DGMGRL remove Removes a configuration, database, or instance show Displays information about a configuration, database, or instance shutdown Shuts down a currently running Oracle database instance sql Executes a SQL statement start Starts the fast-start failover observer startup Starts an Oracle database instance stop Stops the fast-start failover observer switchover Switches roles between a primary and standby database Use "help <command>" to see syntax for individual commands DGMGRL> help create Creates a broker configuration Syntax: CREATE CONFIGURATION <configuration name> AS PRIMARY DATABASE IS <database name> CONNECT IDENTIFIER IS <connect identifier>; DGMGRL> help add Adds a standby database to the broker configuration Syntax: ADD DATABASE <database name> [AS CONNECT IDENTIFIER IS <connect identifier>] [MAINTAINED AS {PHYSICAL|LOGICAL}];
C.创建DG broker配置,并启用
DGMGRL> create configuration 'dg_ohs' as primary database is 'prod' connect identifier is prod; Configuration "dg_ohs" created with primary database "prod" DGMGRL> add database 'stdby' as connect identifier is stdby; Database "stdby" added DGMGRL> show configuration; Configuration - dg_ohs Protection Mode: MaxPerformance Databases: prod - Primary database stdby - Physical standby database Fast-Start Failover: DISABLED Configuration Status: DISABLED DGMGRL> enable configuration; Enabled. DGMGRL> show configuration; Configuration - dg_ohs Protection Mode: MaxPerformance Databases: prod - Primary database stdby - Physical standby database Fast-Start Failover: DISABLED Configuration Status: SUCCESS DGMGRL> show configuration verbose; Configuration - dg_ohs Protection Mode: MaxPerformance Databases: prod - Primary database stdby - Physical standby database Properties: FastStartFailoverThreshold = '30' OperationTimeout = '30' FastStartFailoverLagLimit = '30' CommunicationTimeout = '180' ObserverReconnect = '0' FastStartFailoverAutoReinstate = 'TRUE' FastStartFailoverPmyShutdown = 'TRUE' BystandersFollowRoleChange = 'ALL' ObserverOverride = 'FALSE' ExternalDestination1 = '' ExternalDestination2 = '' PrimaryLostWriteAction = 'CONTINUE' Fast-Start Failover: DISABLED Configuration Status: SUCCESS DGMGRL> show database verbose prod; Database - prod Role: PRIMARY Intended State: TRANSPORT-ON Instance(s): prod1 prod2 Properties: DGConnectIdentifier = 'prod' ObserverConnectIdentifier = '' LogXptMode = 'ASYNC' DelayMins = '0' Binding = 'optional' MaxFailure = '0' MaxConnections = '1' ReopenSecs = '300' NetTimeout = '30' RedoCompression = 'DISABLE' LogShipping = 'ON' PreferredApplyInstance = '' ApplyInstanceTimeout = '0' ApplyParallel = 'AUTO' StandbyFileManagement = 'AUTO' ArchiveLagTarget = '0' LogArchiveMaxProcesses = '4' LogArchiveMinSucceedDest = '1' DbFileNameConvert = '+DATA_STDBY/stdby, +DATA_PROD/prod' LogFileNameConvert = '+DATA_STDBY/stdby, +DATA_PROD/prod' FastStartFailoverTarget = '' InconsistentProperties = '(monitor)' InconsistentLogXptProps = '(monitor)' SendQEntries = '(monitor)' LogXptStatus = '(monitor)' RecvQEntries = '(monitor)' ApplyLagThreshold = '0' TransportLagThreshold = '0' TransportDisconnectedThreshold = '30' SidName(*) StaticConnectIdentifier(*) StandbyArchiveLocation(*) AlternateLocation(*) LogArchiveTrace(*) LogArchiveFormat(*) TopWaitEvents(*) (*) - Please check specific instance for the property value Database Status: SUCCESS DGMGRL> show database verbose stdby; Database - stdby Role: PHYSICAL STANDBY Intended State: APPLY-ON Transport Lag: 0 seconds (computed 1 second ago) Apply Lag: 0 seconds (computed 1 second ago) Apply Rate: 584.00 KByte/s Real Time Query: ON Instance(s): stdby1 (apply instance) stdby2 Properties: DGConnectIdentifier = 'stdby' ObserverConnectIdentifier = '' LogXptMode = 'ASYNC' DelayMins = '0' Binding = 'OPTIONAL' MaxFailure = '0' MaxConnections = '1' ReopenSecs = '15' NetTimeout = '30' RedoCompression = 'DISABLE' LogShipping = 'ON' PreferredApplyInstance = '' ApplyInstanceTimeout = '0' ApplyParallel = 'AUTO' StandbyFileManagement = 'AUTO' ArchiveLagTarget = '0' LogArchiveMaxProcesses = '4' LogArchiveMinSucceedDest = '1' DbFileNameConvert = '+DATA_PROD/prod, +DATA_STDBY/stdby' LogFileNameConvert = '+DATA_PROD/prod, +DATA_STDBY/stdby' FastStartFailoverTarget = '' InconsistentProperties = '(monitor)' InconsistentLogXptProps = '(monitor)' SendQEntries = '(monitor)' LogXptStatus = '(monitor)' RecvQEntries = '(monitor)' ApplyLagThreshold = '0' TransportLagThreshold = '0' TransportDisconnectedThreshold = '30' SidName(*) StaticConnectIdentifier(*) StandbyArchiveLocation(*) AlternateLocation(*) LogArchiveTrace(*) LogArchiveFormat(*) TopWaitEvents(*) (*) - Please check specific instance for the property value Database Status: SUCCESS DGMGRL> DGMGRL> show database prod statusreport; STATUS REPORT INSTANCE_NAME SEVERITY ERROR_TEXT DGMGRL> show database stdby statusreport; STATUS REPORT INSTANCE_NAME SEVERITY ERROR_TEXT DGMGRL>
D.测试DG broker
主库切换至备库(prod--->stdby)
主库切换至备库(stdby--->prod)
Reference
http://docs.oracle.com/cd/E11882_01/server.112/e40771/toc.htm