Oracle Database 19c onward, you can export/import the broker metadata configuration to a text file. This post outlines the steps to import or export the broker metadata configuration.
For the purpose of this post we aree using below example configuration:
Data Guard Configuration :Primary db_unique_name : prim_db Standby db_unique_name : stby_db
Exporting broker configuration file
1. First, login into the primary database using dgmgrl:
$ dgmgrl [LOGIN]/[PASSWORD]@prim_db
2. Now export the broker configuration file as “dg_config.xml”:
DGMGRL> export configuration to 'dg_config.xml'; Succeeded.
The export command will fail if a file of the same name already exists. For example:
DGMGRL> export configuration to 'dg_config.xml'; ORA-16571: Oracle Data Guard configuration file creation failure
3. Confirm if the broker configuration is exported to the trace directory:
$ ls -ltr [ADR_BASE]/rdbms/prim_db/[oracle_sid]/trace/dg_config.xml -rw-r--r-- 1 oracle oinstall 4707 July 05 04:23 dg_config.xml
Importing broker configuration file
1. Before importing the configuration file, you must remove the existing broker configuration. An error will occur if the broker configuration already exists. For example:
DGMGRL> import configuration from 'dg_config.xml'; ORA-16504: The Oracle Data Guard broker configuration already exists.
2. The specified file name must exist in the “trace” directory (ADR). Let us first remove the existing broker configuration.
$ dgmgrl [LOGIN]/[PASSWORD]@prim_db DGMGRL for Linux: Release 19.0.0.0.0 - Production on Sat Aug 17 07:59:23 2019 Version 19.3.0.0.0 Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved. Welcome to DGMGRL, type "help" for information. Connected to "prim_db" Connected as SYSDBA. DGMGRL> remove configuration; Removed configuration DGMGRL>
3. Now import the new configuration which is present in the trace directory. Also, enable the configuration once imported successfully.
DGMGRL> import configuration from 'dg_config.xml'; Succeeded. Run ENABLE CONFIGURATION to enable the imported configuration. DGMGRL> DGMGRL> enable configuration; Enabled. DGMGRL>
4. Verify the configuration.
DGMGRL> show configuration; Configuration - [CONFIGURE NAME] Protection Mode: MaxPerformance Members: prim_db - Primary database stby_db - Physical standby database Fast-Start Failover: Disabled Configuration Status: SUCCESS (status updated 7 seconds ago)