By Brian Fitzgerald
Introduction
Oracle Database 19c Data Guard broker has a new export/import feature. You can use export to backup your Data Guard configuration and you can use import to recreate your configuration.
Export
Issue a command such as:
DGMGRL> export configuration to 'dg.xml'; Succeeded.
Find your configuration file in diagnostic_dest
/u01/app/oracle/diag/rdbms/prim/PRIM/trace/dg.xml
You cannot specify a directory or a relative path.
DGMGRL> export configuration to '/home/oracle/dg.xml'; ORA-16540: invalid argument ORA-06512: at "SYS.DBMS_DRS", line 1947 ORA-06512: at line 1 DGMGRL> export configuration to '../trace/dg.xml'; ORA-16540: invalid argument ORA-06512: at "SYS.DBMS_DRS", line 1947 ORA-06512: at line 1
dgmgrl will not overwrite an existing file
DGMGRL> export configuration to 'dg.xml'; ORA-16571: Oracle Data Guard configuration file creation failure
You may export at the standby. The export file appears in the standby trace directory.
/u01/app/oracle/diag/rdbms/stby/STBY/trace/dg.xml
Contents
Refer, for example, to this link dg.xml. The export file contains:
- Identity and role of members
- Default, desired, and current state, including error number and timestamp
- System and member configuration parameters
Some parameters that are at the default value and have never been modified are not exported.
Only the error number is exported. The error text depends on localization.
Import
Here is how to use import.
If there is a configuration, disable and remove it. All members must be accessible.
DGMGRL> disable configuration Disabled. DGMGRL> remove configuration Removed configuration
Import and enable the configuration
DGMGRL> import configuration from 'dg.xml'; Succeeded. Run ENABLE CONFIGURATION to enable the imported configuration. DGMGRL> enable configuration Enabled.
Data Guard broker will not import over an existing configuration
DGMGRL> import configuration from 'dg.xml'; ORA-16504: The Oracle Data Guard broker configuration already exists.
Result:
You can change the export file before reimporting.
Before:
DGMGRL> show database verbose PRIM NetTimeout NetTimeout = '30'
File:
![]()
Result:
DGMGRL> remove configuration Removed configuration DGMGRL> import configuration from 'dg.xml'; Succeeded. Run ENABLE CONFIGURATION to enable the imported configuration. DGMGRL> show database verbose PRIM NetTimeout NetTimeout = '10'
You cannot split the Data Guard xml file into pieces and import them separately.
DGMGRL> import configuration from 'prim.xml'; Succeeded. Run ENABLE CONFIGURATION to enable the imported configuration. DGMGRL> import configuration from 'stby.xml'; ORA-16504: The Oracle Data Guard broker configuration already exists. DGMGRL>
You must import to the primary. If you attempt to import to the standby, this message will appear:
DGMGRL> import configuration from 'dg.xml'; ORA-16501: The Oracle Data Guard broker operation failed.
The trace file offers no clue about what could be the problem.
2019-10-18T11:19:37.866+00:00 IMPORT METADATA FROM /u01/app/oracle/diag/rdbms/stby/STBY/trace/dg.xml ORA-16501: The Data Guard broker failed to import metadata from /u01/app/oracle/diag/rdbms/stby/STBY/trace/dg.xml. IMPORT METADATA FROM /u01/app/oracle/diag/rdbms/stby/STBY/trace/dg.xml completed with error ORA-16501
Management of an unreachable member
If you remove a Data Guard configuration while a member is down, you will have an issue later if you try to import. The following administrative sequence that could lead up to the trouble:
DGMGRL> export configuration to 'dg.xml'; Succeeded.
Now, suppose the standby is down
DGMGRL> validate database STBY Error: ORA-1034: ORACLE not available Error: ORA-16625: cannot reach member "STBY" DGMGRL> disable configuration Disabled. DGMGRL> remove configuration Warning: ORA-16620: one or more members could not be reached for a remove operation Removed configuration DGMGRL> import configuration from 'dg.xml'; Succeeded. Run ENABLE CONFIGURATION to enable the imported configuration.
Now, if you enable even while the standby is up:
DGMGRL> enable configuration Enabled.
Error appears
Solution: On the standby disable the broker, remove the Data Guard Broker configuration files, and reenable the broker.
SQL> alter system set dg_broker_start=false; System altered.
[grid@ip-172-31-91-148 ~]$ asmcmd rm +DATA01/STBY/dr1orcl.dat [grid@ip-172-31-91-148 ~]$ asmcmd rm +RECO01/STBY/dr2orcl.dat
SQL> alter system set dg_broker_start=true; System altered.
Then, on the primary, disable, remove, import, and enable the configuration.
The problem scenario described here is not unique to import. The issue can occur any time a configuration is deleted while members are down.
Conclusion
dgmgrl export and import are useful for backing up and restoring the Data Guard configuration.