DG broker是管理Data Guard环境的利器,她使用起来非常方便,易于管理,在很大程度上简化了DBA的工作量。一般情况下,DBA需要在主备库上修改log_archive_dest等相关参数,并且在主备库上都配置好,这样在后期的switchover才能保证不出问题。通过DG Broker,我们可以用几条简单的命令把整个环境搭建起来,用起来非常方便。
注意:通过DG Broker配置Data Guard环境,不需要再修log_archive_dest等参数。
环境信息

通过DG Broker配置DG
[oracle@ohs1 ~]$ dgmgrl sys/oracle
DGMGRL for Linux: Version 12.1.0.2.0 - 64bit Production
Copyright (c) 2000, 2013, Oracle. All rights reserved.
Welcome to DGMGRL, type "help" for information.
Connected as SYSDG.
DGMGRL>
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> add far_sync prodfs as connect identifier is prodfs;
far sync instance "prodfs" added
DGMGRL> enable configuration;
Enabled.
DGMGRL> edit database prod set property redoroutes='(LOCAL : prodfs SYNC)';
Property "redoroutes" updated
DGMGRL> edit database stdby set property redoroutes='(LOCAL : prodfs SYNC)';
Property "redoroutes" updated
DGMGRL> edit far_sync prodfs set property redoroutes='(prod : stdby)(stdby: prod)';
Property "redoroutes" updated
DGMGRL> show configuration;
Configuration - dg_ohs
Protection Mode: MaxPerformance
Members:
prod - Primary database
prodfs - Far sync instance
stdby - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS (status updated 6 seconds ago)
DGMGRL>
DGMGRL> validate database verbose prod;
Database Role: Primary database
Ready for Switchover: Yes
Capacity Information:
Database Instances Threads
prod 2 2
Temporary Tablespace File Information:
prod TEMP Files: 2
Flashback Database Status:
prod: On
Data file Online Move in Progress:
prod: No
Transport-Related Information:
Transport On: Yes
Log Files Cleared:
prod Standby Redo Log Files: Cleared
Automatic Diagnostic Repository Errors:
Error prod
No logging operation NO
Control file corruptions NO
System data file missing NO
System data file corrupted NO
System data file offline NO
User data file missing NO
User data file corrupted NO
User data file offline NO
Block Corruptions found NO
DGMGRL> validate database verbose stdby;
Database Role: Physical standby database
Primary Database: prod
Ready for Switchover: Yes
Ready for Failover: Yes (Primary Running)
Capacity Information:
Database Instances Threads
prod 2 2
stdby 2 2
Temporary Tablespace File Information:
prod TEMP Files: 1
stdby TEMP Files: 1
Flashback Database Status:
prod: On
stdby: On
Data file Online Move in Progress:
prod: No
stdby: No
Standby Apply-Related Information:
Apply State: Running
Apply Lag: 0 seconds (computed 0 seconds ago)
Apply Delay: 0 minutes
Transport-Related Information:
Transport On: Yes
Gap Status: No Gap
Transport Lag: 0 seconds (computed 0 seconds ago)
Transport Status: Success
Log Files Cleared:
prod Standby Redo Log Files: Cleared
stdby Online Redo Log Files: Cleared
stdby Standby Redo Log Files: Available
Current Log File Groups Configuration:
Thread # Online Redo Log Groups Standby Redo Log Groups Status
(prod) (stdby)
1 3 4 Sufficient SRLs
2 3 4 Sufficient SRLs
Future Log File Groups Configuration:
Thread # Online Redo Log Groups Standby Redo Log Groups Status
(stdby) (prod)
1 3 4 Sufficient SRLs
2 3 4 Sufficient SRLs
Current Configuration Log File Sizes:
Thread # Smallest Online Redo Smallest Standby Redo
Log File Size Log File Size
(prod) (stdby)
1 50 MBytes 50 MBytes
2 50 MBytes 50 MBytes
Future Configuration Log File Sizes:
Thread # Smallest Online Redo Smallest Standby Redo
Log File Size Log File Size
(stdby) (prod)
1 50 MBytes 50 MBytes
2 50 MBytes 50 MBytes
Apply-Related Property Settings:
Property prod Value stdby Value
DelayMins 0 0
ApplyParallel AUTO AUTO
Transport-Related Property Settings:
Property prod Value stdby Value
LogXptMode ASYNC ASYNC
RedoRoutes (LOCAL : prodfs SYNC) (LOCAL : prodfs SYNC)
Dependency <empty> <empty>
DelayMins 0 0
Binding optional optional
MaxFailure 0 0
MaxConnections 1 1
ReopenSecs 300 300
NetTimeout 30 30
RedoCompression DISABLE DISABLE
LogShipping ON ON
Automatic Diagnostic Repository Errors:
Error prod stdby
No logging operation NO NO
Control file corruptions NO NO
SRL Group Unavailable NO NO
System data file missing NO NO
System data file corrupted NO NO
System data file offline NO NO
User data file missing NO NO
User data file corrupted NO NO
User data file offline NO NO
Block Corruptions found NO NO
DGMGRL> validate far_sync verbose prodfs;
Member Role: Far Sync Instance
When Primary Is: prod
Active Redo Source: prod
Redo Destinations:
stdby
Thread # Online Redo Log Groups Standby Redo Log Groups Status
prod prodfs
1 3 4 Sufficient SRLs
2 3 4 Sufficient SRLs
Transport-Related Information:
Transport On: Yes
Gap Status: No Gap
Transport Lag: 0 seconds (computed 1 second ago)
Transport Status: Success
DGMGRL>
DGMGRL>
为far_sync实例配置alternate dest
DGMGRL> edit database stdby set property redoroutes='(LOCAL : prodfs SYNC alt=(prod async fallback))'; Error: ORA-16863: A member whose MaxFailure property is set to zero cannot have an alternate destination. Failed. DGMGRL> edit far_sync prodfs set property MaxFailure=3; Property "maxfailure" updated DGMGRL> edit database stdby set property redoroutes='(LOCAL : prodfs SYNC alt=(prod async fallback))'; Property "redoroutes" updated DGMGRL> edit database prod set property redoroutes='(LOCAL : prodfs SYNC alt=(stdby async fallback))'; Property "redoroutes" updated DGMGRL>注意:far_sync实例MaxFailure的值必须大于0,否则不能设置备用位置
关闭far_sync实例,验证alternate dest
[oracle@ohs5 ~]$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Thu Jan 5 10:10:55 2017
Copyright (c) 1982, 2014, Oracle. All rights reserved.
SQL> shut abort
ORACLE instance shut down.
SQL>
[oracle@ohs1 ~]$ dgmgrl sys/oracle
DGMGRL for Linux: Version 12.1.0.2.0 - 64bit Production
Copyright (c) 2000, 2013, Oracle. All rights reserved.
Welcome to DGMGRL, type "help" for information.
Connected as SYSDG.
DGMGRL>
DGMGRL> show configuration;
Configuration - dg_ohs
Protection Mode: MaxPerformance
Members:
prod - Primary database
stdby - Physical standby database (alternate of prodfs)
Members Not Receiving Redo:
prodfs - Far sync instance
Warning: ORA-01034: ORACLE not available
Fast-Start Failover: DISABLED
Configuration Status:
WARNING (status updated 42 seconds ago)
DGMGRL>
注意:关闭far_sync后,可以观察到日志直接从prod到stdby。说明far_sync的ALT配置没有问题
启动far_sync实例,查看配置
[oracle@ohs5 admin]$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Thu Jan 5 10:15:43 2017
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 209715200 bytes
Fixed Size 2922712 bytes
Variable Size 113248040 bytes
Database Buffers 88080384 bytes
Redo Buffers 5464064 bytes
Database mounted.
ORA-16476: far sync instance does not allow Open operation
SQL>
[oracle@ohs1 ~]$ dgmgrl sys/oracle
DGMGRL for Linux: Version 12.1.0.2.0 - 64bit Production
Copyright (c) 2000, 2013, Oracle. All rights reserved.
Welcome to DGMGRL, type "help" for information.
Connected as SYSDG.
DGMGRL>
DGMGRL> show configuration;
Configuration - dg_ohs
Protection Mode: MaxPerformance
Members:
prod - Primary database
prodfs - Far sync instance
stdby - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS (status updated 1 second ago)
DGMGRL>
switchover测试
DGMGRL> show configuration;
Configuration - dg_ohs
Protection Mode: MaxPerformance
Members:
prod - Primary database
prodfs - Far sync instance
stdby - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS (status updated 25 seconds ago)
DGMGRL> switchover to stdby;
Performing switchover NOW, please wait...
Operation requires a connection to instance "stdby2" on database "stdby"
Connecting to instance "stdby2"...
Connected as SYSDBA.
New primary database "stdby" is opening...
Oracle Clusterware is restarting database "prod" ...
Switchover succeeded, new primary is "stdby"
DGMGRL>
DGMGRL> show configuration;
Configuration - dg_ohs
Protection Mode: MaxPerformance
Members:
stdby - Primary database
prodfs - Far sync instance
Warning: ORA-16778: redo transport error for one or more databases
prod - Physical standby database (alternate of prodfs)
Warning: ORA-16858: last communication time from redo source could not be determined
Fast-Start Failover: DISABLED
Configuration Status:
WARNING (status updated 37 seconds ago)
DGMGRL> show configuration;
Configuration - dg_ohs
Protection Mode: MaxPerformance
Members:
stdby - Primary database
prodfs - Far sync instance
prod - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS (status updated 40 seconds ago)
DGMGRL>
注意:切换过程中,far_sync实例无需重启,整个切换过程对far_sync来说是透明的,但要注意LogFileNameConvert的设置
far_sync HA配置
在生产数据中心有一个主库和一个far_sync实例,在灾备数据中心有一个备库和一个far_sync实例。当生产数据中心的数据库为主库时,使用距离生产数据中心较近的far_sync实例。当灾备数据中心的数据库为主库时,使用距离灾备中心较近的far_sync实例
配置命令如下
DGMGRL> create configuration dg_ohs as primary database is prod connect identifier is prod;
DGMGRL> add database stdby as connect identifier is stdby;
DGMGRL> add far_sync prodfs as connect identifier is prodfs;
DGMGRL> add far_sync stdbyfs as connect identifier is stdbyfs;
DGMGRL> edit database prod set property redoroutes='(LOCAL : prodfs SYNC)';
DGMGRL> edit database stdby set property redoroutes='(LOCAL : stdbyfs SYNC)';
DGMGRL> edit far_sync prodfs set property redoroutes='(prod : stdby)';
DGMGRL> edit far_sync stdbyfs set property redoroutes='(stdby : prod)';
DGMGRL> enable configuration;
Bug 19399918
Bug 19399918 Role transition fails with terminal standby as alternate of far sync (ORA-16778)
DGMGRL> switchover to stdby
Performing switchover NOW, please wait...
Error: ORA-16778: redo transport error for one or more databases
Failed.
Unable to switchover, primary database is still "prod"
[oracle@ohs1 ~]$ /pgold/ordb/oracle/product/121/OPatch/opatch lsinv |grep 19399918
19058490, 19032777, 20781373, 19399918, 20540694, 22184431, 19434529
[oracle@ohs1 ~]$
Potential issue(潜在的问题)
如果far_sync配置了ALT,在DG Broker中通过validate命令时,会重置LOG_ARCHIVE_DEST_3,这个应该是Bug。
[oracle@ohs1 ~]$ adrci
ADRCI: Release 12.1.0.2.0 - Production on Thu Jan 5 11:05:30 2017
Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved.
ADR base = "/pgold/ordb/log"
adrci> show alert -tail 50
2017-01-05 10:59:59.760000 -05:00
LGWR: Setting 'active' archival for destination LOG_ARCHIVE_DEST_2
******************************************************************
LGWR: Standby redo logfile selected for thread 1 sequence 460 for destination LOG_ARCHIVE_DEST_2
Thread 1 advanced to log sequence 460 (LGWR switch)
Current log# 5 seq# 460 mem# 0: +FRA_PROD/prod/onlinelog/group_5.257.929587199
Archived Log entry 1625 added for thread 1 sequence 459 ID 0x1486590f dest 1:
ARC0: Standby redo logfile selected for thread 1 sequence 459 for destination LOG_ARCHIVE_DEST_2
minact-scn: Inst 1 is a slave inc#:6 mmon proc-id:28085 status:0x2
minact-scn status: grec-scn:0x0000.00000000 gmin-scn:0x0000.00000000 gcalc-scn:0x0000.00000000
2017-01-05 11:00:01.222000 -05:00
No Resource Manager plan active
2017-01-05 11:00:03.812000 -05:00
Starting background process AQPC
AQPC started with pid=64, OS id=7204
2017-01-05 11:00:06.120000 -05:00
Starting background process CJQ0
Completed: ALTER DATABASE OPEN
CJQ0 started with pid=66, OS id=7222
ALTER SYSTEM SET log_archive_trace=0 SCOPE=BOTH SID='prod1';
ALTER SYSTEM SET log_archive_format='prod1_%t_%s_%r.arc' SCOPE=SPFILE SID='prod1';
ALTER SYSTEM SET standby_file_management='AUTO' SCOPE=BOTH SID='*';
ALTER SYSTEM SET archive_lag_target=0 SCOPE=BOTH SID='*';
ALTER SYSTEM SET log_archive_max_processes=4 SCOPE=BOTH SID='*';
ALTER SYSTEM SET log_archive_min_succeed_dest=1 SCOPE=BOTH SID='*';
ALTER SYSTEM SET db_file_name_convert='+DATA_STDBY/stdby','+DATA_PROD/prod' SCOPE=SPFILE;
ALTER SYSTEM SET log_file_name_convert='+DATA_STDBY/stdby','+DATA_PROD/prod' SCOPE=SPFILE;
2017-01-05 11:00:07.114000 -05:00
ALTER SYSTEM SET log_archive_dest_state_2='RESET' SCOPE=BOTH;
ALTER SYSTEM SET log_archive_dest_state_3='RESET' SCOPE=BOTH;
ALTER SYSTEM SET log_archive_dest_state_2='ALTERNATE' SCOPE=BOTH;
ALTER SYSTEM SET log_archive_dest_state_3='ALTERNATE' SCOPE=BOTH;
ALTER SYSTEM SET log_archive_dest_state_2='ENABLE' SCOPE=BOTH;
ALTER SYSTEM ARCHIVE LOG
2017-01-05 11:00:09.977000 -05:00
******************************************************************
LGWR: Setting 'active' archival for destination LOG_ARCHIVE_DEST_2
******************************************************************
LGWR: Standby redo logfile selected for thread 1 sequence 461 for destination LOG_ARCHIVE_DEST_2
Thread 1 advanced to log sequence 461 (LGWR switch)
Current log# 1 seq# 461 mem# 0: +DATA_PROD/prod/redo01.log
Archived Log entry 1633 added for thread 1 sequence 460 ID 0x1486590f dest 1:
2017-01-05 11:00:19.094000 -05:00
Thread 1 cannot allocate new log, sequence 462
Checkpoint not complete
Current log# 1 seq# 461 mem# 0: +DATA_PROD/prod/redo01.log
2017-01-05 11:00:25.622000 -05:00
******************************************************************
LGWR: Setting 'active' archival for destination LOG_ARCHIVE_DEST_2
******************************************************************
LGWR: Standby redo logfile selected for thread 1 sequence 462 for destination LOG_ARCHIVE_DEST_2
Thread 1 advanced to log sequence 462 (LGWR switch)
Current log# 2 seq# 462 mem# 0: +DATA_PROD/prod/redo02.log
Archived Log entry 1639 added for thread 1 sequence 461 ID 0x1486590f dest 1:
2017-01-05 11:00:55.724000 -05:00
Thread 1 cannot allocate new log, sequence 463
Checkpoint not complete
Current log# 2 seq# 462 mem# 0: +DATA_PROD/prod/redo02.log
2017-01-05 11:00:59.930000 -05:00
******************************************************************
LGWR: Setting 'active' archival for destination LOG_ARCHIVE_DEST_2
******************************************************************
LGWR: Standby redo logfile selected for thread 1 sequence 463 for destination LOG_ARCHIVE_DEST_2
Thread 1 advanced to log sequence 463 (LGWR switch)
Current log# 5 seq# 463 mem# 0: +FRA_PROD/prod/onlinelog/group_5.257.929587199
Archived Log entry 1643 added for thread 1 sequence 462 ID 0x1486590f dest 1:
2017-01-05 11:02:47.360000 -05:00
This is cascading configuration.
LOG_ARCHIVE_DEST_3 has already been configured to switchover target stdby. Clearing LOG_ARCHIVE_DEST_3.
Using STANDBY_ARCHIVE_DEST parameter default value as USE_DB_RECOVERY_FILE_DEST
ALTER SYSTEM SET log_archive_dest_3='' SCOPE=MEMORY SID='*';
LOG_ARCHIVE_DEST3 is cleared.
Configuring a new LOG_ARCHIVE_DEST to switchover target stdby.
Using STANDBY_ARCHIVE_DEST parameter default value as USE_DB_RECOVERY_FILE_DEST
ALTER SYSTEM SET log_archive_dest_31='service=stdby ASYNC db_unique_name=stdby' SCOPE=MEMORY SID='*';
SWITCHOVER VERIFY: Send VERIFY request to switchover target stdby
Thread 1 cannot allocate new log, sequence 464
Checkpoint not complete
Current log# 5 seq# 463 mem# 0: +FRA_PROD/prod/onlinelog/group_5.257.929587199
SWITCHOVER VERIFY COMPLETE
SWITCHOVER VERIFY WARNING: switchover target has no standby database defined in LOG_ARCHIVE_DEST_n parameter. If the switchover target is converted to a primary database, the new primary database will not be protected.
Using STANDBY_ARCHIVE_DEST parameter default value as USE_DB_RECOVERY_FILE_DEST
ALTER SYSTEM SET log_archive_dest_31='' SCOPE=MEMORY SID='*';
Data Guard Broker: Switchover processing will set LOG_ARCHIVE_DEST_n parameter. Continuing switchover
2017-01-05 11:02:51.058000 -05:00
LGWR: Standby redo logfile selected for thread 1 sequence 464 for destination LOG_ARCHIVE_DEST_2
Thread 1 advanced to log sequence 464 (LGWR switch)
Current log# 1 seq# 464 mem# 0: +DATA_PROD/prod/redo01.log
Archived Log entry 1645 added for thread 1 sequence 463 ID 0x1486590f dest 1:
adrci>
DGMGRL> show database verbose prod;
Database - prod
Role: PRIMARY
Intended State: TRANSPORT-ON
Instance(s):
prod1
Error: ORA-16736: unable to find the destination entry of standby database "stdby" in V$ARCHIVE_DEST
Warning: ORA-16715: redo transport-related property RedoRoutes of standby database "prodfs" is inconsistent
Warning: ORA-16728: consistency check for property LogXptMode found ORA-16777 error
Warning: ORA-16777: unable to find the destination entry of a standby database in V$ARCHIVE_DEST
Warning: ORA-16728: consistency check for property RedoRoutes found ORA-16777 error
Warning: ORA-16777: unable to find the destination entry of a standby database in V$ARCHIVE_DEST
Warning: ORA-16728: consistency check for property DelayMins found ORA-16777 error
Warning: ORA-16777: unable to find the destination entry of a standby database in V$ARCHIVE_DEST
Warning: ORA-16728: consistency check for property Binding found ORA-16777 error
Warning: ORA-16777: unable to find the destination entry of a standby database in V$ARCHIVE_DEST
Warning: ORA-16728: consistency check for property MaxFailure found ORA-16777 error
Warning: ORA-16777: unable to find the destination entry of a standby database in V$ARCHIVE_DEST
Warning: ORA-16728: consistency check for property MaxConnections found ORA-16777 error
Warning: ORA-16777: unable to find the destination entry of a standby database in V$ARCHIVE_DEST
Warning: ORA-16728: consistency check for property ReopenSecs found ORA-16777 error
Warning: ORA-16777: unable to find the destination entry of a standby database in V$ARCHIVE_DEST
Warning: ORA-16728: consistency check for property RedoCompression found ORA-16777 error
Warning: ORA-16777: unable to find the destination entry of a standby database in V$ARCHIVE_DEST
prod2
Error: ORA-16736: unable to find the destination entry of standby database "stdby" in V$ARCHIVE_DEST
Warning: ORA-16715: redo transport-related property RedoRoutes of standby database "prodfs" is inconsistent
Warning: ORA-16728: consistency check for property LogXptMode found ORA-16777 error
Warning: ORA-16777: unable to find the destination entry of a standby database in V$ARCHIVE_DEST
Warning: ORA-16728: consistency check for property RedoRoutes found ORA-16777 error
Warning: ORA-16777: unable to find the destination entry of a standby database in V$ARCHIVE_DEST
Warning: ORA-16728: consistency check for property DelayMins found ORA-16777 error
Warning: ORA-16777: unable to find the destination entry of a standby database in V$ARCHIVE_DEST
Warning: ORA-16728: consistency check for property Binding found ORA-16777 error
Warning: ORA-16777: unable to find the destination entry of a standby database in V$ARCHIVE_DEST
Warning: ORA-16728: consistency check for property MaxFailure found ORA-16777 error
Warning: ORA-16777: unable to find the destination entry of a standby database in V$ARCHIVE_DEST
Warning: ORA-16728: consistency check for property MaxConnections found ORA-16777 error
Warning: ORA-16777: unable to find the destination entry of a standby database in V$ARCHIVE_DEST
Warning: ORA-16728: consistency check for property ReopenSecs found ORA-16777 error
Warning: ORA-16777: unable to find the destination entry of a standby database in V$ARCHIVE_DEST
Warning: ORA-16728: consistency check for property RedoCompression found ORA-16777 error
Warning: ORA-16777: unable to find the destination entry of a standby database in V$ARCHIVE_DEST
Properties:
DGConnectIdentifier = 'prod'
ObserverConnectIdentifier = ''
LogXptMode = 'ASYNC'
RedoRoutes = '(LOCAL : prodfs SYNC alt=(stdby async fallback))'
DelayMins = '0'
Binding = 'optional'
MaxFailure = '0'
MaxConnections = '1'
ReopenSecs = '300'
NetTimeout = '30'
RedoCompression = 'DISABLE'
LogShipping = 'ON'
PreferredApplyInstance = ''
ApplyInstanceTimeout = '0'
ApplyLagThreshold = '0'
TransportLagThreshold = '0'
TransportDisconnectedThreshold = '30'
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)'
StaticConnectIdentifier(*)
StandbyArchiveLocation(*)
AlternateLocation(*)
LogArchiveTrace(*)
LogArchiveFormat(*)
TopWaitEvents(*)
(*) - Please check specific instance for the property value
Database Status:
ERROR
DGMGRL>
Reference
http://docs.oracle.com/database/121/SBYDB/create_fs.htm#SBYDB5416
