25 On-Premises MAA Platinum: Oracle GoldenGate Microservices Architecture Integrated with Active Data Guard
The combination and integration of Oracle GoldenGate Microservices and Oracle Data Guard enables you to achieve an MAA Platinum service-level configuration that achieves zero or near zero downtime for all planned and unplanned outages.
Follow these configuration best practices to enable Oracle GoldenGate Microservices replication using a database that is protected by a Data Guard standby, to transparently and seamlessly work following an Oracle Data Guard role transition, no matter which Data Guard protection mode is configured (Maximum Performance, Maximum Availability, or Maximum Protection).
Topics:
- Prerequisites
- Task 1: Configure the Standby Database for Oracle GoldenGate
- Task 2: Modify the Primary Database Service
- Task 3: Create the Standby Database Service
- Task 4: Configure DBFS on the Standby Cluster Nodes
- Task 5: Install Oracle GoldenGate Software
- Task 6: Create Oracle GoldenGate Deployment Directories
- Task 7: Configure the Standby NGINX Reverse Proxy
- Task 8: Configure Oracle Clusterware
- Task 9: Create Oracle Net TNS Aliases for Oracle GoldenGate Database Connections
- Task 10: Configure Oracle GoldenGate Processes
- Example Distribution Path Target Change Script
Prerequisites
Be sure to complete the following prerequisites before performing any tasks for on-premises MAA Platinum architecture configuration.
-
As a prerequisite for MAA Platinum on-premises, have Oracle GoldenGate configured as detailed in On-Premises: Oracle GoldenGate Microservices Architecture with Oracle Real Application Clusters Configuration Best Practices.
-
The Database File System (DBFS) is required for critical Oracle GoldenGate files when integrating with Data Guard.
-
The Oracle Data Guard standby database should also be configured and operational before continuing.
The following are software requirements that the MAA Platinum configuration is based on:
-
Oracle Grid Infrastructure 19c or later
Oracle Grid Infrastructure provides the necessary components needed to manage high availability for any business-critical applications. Using Oracle Clusterware (a component of Oracle Grid Infrastructure) network, database, and Oracle GoldenGate resources can be managed to provide availability in the event of a failure.
-
Oracle Grid Infrastructure Agent version 10.2 or later
The Oracle Grid Infrastructure Agent leverages the Oracle Grid Infrastructure components to provide integration between Oracle GoldenGate and its dependent resources, such as the database, network, and file system. The agent also integrates Oracle GoldenGate with Oracle Data Guard so that Oracle GoldenGate is restarted on the new primary database following a role transition.
-
Oracle Database 19c or later
See My Oracle Support Document 2193391.1 for a full list of recommended Oracle Database patches when using Oracle GoldenGate.
-
Oracle GoldenGate Microservices version 21c or later
Oracle GoldenGate 21c introduces unified build support so a single software installation supports capturing and applying replicated data to multiple major Oracle Database versions (11g Release 2 to 21c). This is possible because an Oracle GoldenGate installation includes the required Oracle Database client libraries without requiring a separate database
ORACLE_HOME
installation. -
Oracle DBFS to protect and replicate critical Oracle GoldenGate files
The Oracle Database File System (DBFS) is the only MAA-validated and recommended file system for an Oracle Data Guard and Oracle GoldenGate configuration, because it allows the storage of the required Oracle GoldenGate files, such as the checkpoint and trail files, to be located inside the same database that is protected with Oracle Data Guard, ensuring consistency between the Oracle GoldenGate files and the database in a seamless fashion.
When the prerequisites are met, follow the configuration best practices in the Tasks that follow. These tasks should be performed to ensure the seamless integration of Oracle GoldenGate Microservices with Oracle Data Guard, which in turn ensures that GoldenGate continues running after any Data Guard role transition.
Task 1: Configure the Standby Database for Oracle GoldenGate
The standby database initialization parameters should match those of the primary database.
See Task 1: Configure the Oracle Database for Oracle GoldenGate for details. This includes the following parameters:
-
ENABLE_GOLDENGATE_REPLICATION=TRUE
-
For Oracle GoldenGate source databases, enable
FORCE LOGGING
mode and enable minimal supplemental logging. - If a GoldenGate source database, or running integrated Replicat (parallel or
non-parallel), configure the
STREAMS_POOL_SIZE
.
Task 2: Modify the Primary Database Service
On the primary database server, modify the existing database service that was created as part of the original Oracle GoldenGate on Oracle RAC configuration.
Set the service role to PRIMARY
, so that the service is only be
started when the database becomes the Data Guard primary database role after a role
transition.
As the oracle
user, modify the service using the following
command:
$ srvctl modify service -db dbName -service service_name
-role PRIMARY
If your database is part of a multitenant environment, remember to modify both the multitenant container database (CDB) and pluggable database (PDB) services.
Task 3: Create the Standby Database Service
On the standby cluster, a database service is required for the standby database so that the Oracle Grid Infrastructure Agent automatically starts the Oracle GoldenGate deployment when the database is opened with the primary role.
When a source database is in a multitenant environment, a separate service is required for the root container database (CDB) and the pluggable database (PDB) that contains the schema being replicated. For a multitenant environment target database, a single service is required for the PDB.
Create the service using the following command, as the oracle
user,
the same way the service was created on the primary cluster.
$ srvctl add service -db dbName -service service_name
-preferred instance_1 -available instance_2, instance_3 etc.
-pdb pdbName -role PRIMARY
It is recommended that you use the same service name as was specified on the primary
cluster. The service must be created as a singleton service, using the
–preferred
option, because the application Virtual IP address
(VIP), DBFS, and Oracle GoldenGate run on the cluster node where the service is
running.
If the database is not in a multitenant environment, or the database is a target
database for Oracle GoldenGate, omit the -pdb
parameter.
Task 4: Configure DBFS on the Standby Cluster Nodes
The Database File System (DBFS) is the only recommended solution when configuring Oracle GoldenGate with Oracle Data Guard.
The DBFS user, tablespace, and file system in the database was previously created in the primary database, as detailed in Task 4: Set Up a File System on Oracle RAC.
The remaining configuration steps are required on all nodes of the standby cluster where Oracle GoldenGate may run.
Task 5: Install Oracle GoldenGate Software
Install the Oracle GoldenGate software locally on all nodes in the standby cluster that will be part of the Oracle GoldenGate configuration.
Download the Oracle GoldenGate 21c software, or later version, at this location:
http://www.oracle.com/technetwork/middleware/goldengate/downloads/index.html
Task 6: Create Oracle GoldenGate Deployment Directories
The Oracle GoldenGate Service Manager and deployment are already created on the primary cluster, as required by the prerequisites, but certain directories and symbolic links need to be configured on the standby cluster nodes.
These directories and symbolic links were created on the primary cluster, in the tasks you performed as part of On-Premises: Oracle GoldenGate Microservices Architecture with Oracle Real Application Clusters Configuration Best Practices.
Now you create the following directories and symbolic links on the all Oracle RAC nodes on the standby cluster as follows.
Task 7: Configure the Standby NGINX Reverse Proxy
Follow these steps to configure the standby NGINX reverse proxy.
Task 8: Configure Oracle Clusterware
For more information about the Oracle Grid Infrastructure Bundled Agent, see http://www.oracle.com/technetwork/database/database-technologies/clusterware/downloads/xag-agents-downloads-3636484.html
Task 9: Create Oracle Net TNS Aliases for Oracle GoldenGate Database Connections
The same TNS aliases created on the primary cluster for the primary database using the IPC protocol must be created with the same alias names on each node of the standby cluster, using the IPC communication protocol as specified in Task 9: Create Oracle Net TNS Alias for Oracle GoldenGate Database Connections.
The location of tnsnames.ora
used by the Oracle GoldenGate
deployment must be the same on the standby cluster nodes as it is on
the primary cluster.
Use the following query REST API call to query the TNS_ADMIN
location on the primary cluster.
$ curl -s -u OGG_admin_username
https://vip_name/services/v2/deployments/deployment_name
-XGET|python -m json.tool|grep TNS_ADMIN -A1
You will be prompted to enter the Oracle GoldenGate Service Manager administrator user password.
For example:
$ curl -s -u oggadmin https://dc1north01-vip1/services/v2/deployments/ggnorth
-XGET|python -m json.tool|grep TNS_ADMIN -A1
"name": "TNS_ADMIN",
"value": "/u01/goldengate/network/admin"
Make sure the tnsnames.ora
is located in this
same directory on all standby cluster nodes.
Example TNS alias for the GoldenGate database:
ggnorth_pdb =
(DESCRIPTION =
(SDU = 2097152)
(ADDRESS = (PROTOCOL = IPC)(KEY=LISTENER))
(CONNECT_DATA =
(SERVICE_NAME = oggserv_pdb.example.com)
)
)
Task 10: Configure Oracle GoldenGate Processes
In addition to the guidance provided in Task 10: Configure Oracle GoldenGate Processes, follow the recommendations provided below for Extract, Distribution Paths, and Replicats.
Extract Configuration on the Primary Cluster
For GoldenGate Extract processes using Data Guard configurations that are using redo transport Maximum Performance or Maximum Availability modes, the following parameter must be added to the Extract process parameter file on the primary cluster to avoid losing transactions and resulting in logical data inconsistencies:
TRANLOGOPTIONS HANDLEDLFAILOVER
This parameter prevents Extract from extracting transaction data from redo that has not yet been applied to the Data Guard standby database. This is crucial to preventing Oracle GoldenGate from replicating data to a target database that does not exist in the source standby database.
If this parameter is not specified, after a data loss failover of the source database it is possible to have data in the target database that is not present in the source database, leading to logical data inconsistencies.
By default, after 60 seconds, a warning message will be written to the Extract report file when the Extract is stalled due to not being able to query the standby database applied SCN information. For example:
WARNING OGG-02721 Extract has been waiting for the standby database for 60
seconds.
The amount of time before the warning message is written to Extract report file can
be adjusted using the Extract parameter TRANLOGOPTIONS HANDLEDLFAILOVER
STANDBY_WARNING
.
If the Extract is still not able to query the standby database applied SCN information after 30 minutes (default), the Extract process will abend, logging the following message in the Extract report file:
ERROR OGG-02722 Extract abended waiting for 1,800 seconds for the standby
database to be accessible or caught up with the primary database.
If the standby database becomes available before the 30 default timeout expires, Extract continues mining data from the source database and reports the following message to the report file:
INFO OGG-02723 Extract resumed from stalled state and started processing
LCRs.
The timeout value of 30 minutes can be adjusted using the Extract parameter
TRANLOGOPTIONS HANDLEDLFAILOVER STANDBY_ABEND
value
, where value is the number
of seconds the standby is unavailable before abending.
If the standby database will be unavailable for a prolonged duration, such as during
a planned maintenance outage, and you wish Extract to continue extracting data from
the primary database, remove the TRANLOGOPTIONS HANDLEDLFAILOVER
parameter from the Extract parameter file and restart Extract. Remember to set the
parameter after the standby becomes available.
Note:
If extracting from a primary database continues while the standby is unavailable, a data loss failover could result after the standby becomes available, and not all the primary redo was applied before a failover. The GoldenGate target database will contain data that does not exist in the source database.
See Oracle GoldenGate Reference Guide for more information about the
TRANLOGOPTIONS HANDLEDLFAILOVER
parameters at https://docs.oracle.com/en/middleware/goldengate/core/21.3/reference/reference-oracle-goldengate.pdf.
If the Extract process has been assigned an auto restart profile, as documented in Task 11: Configure Autostart of Extract and Replicat Processes, after a Data Guard role transition, the Extract process will automatically restart. Extract will continue to mine redo data from the new primary database, ignoring the current state of the new standby database, until a default 5 minute timeout period expires. After this time, if the standby is not available Extract will abend with the following errors:
INFO OGG-25053 Timeout waiting for 300 seconds for standby database
reinstatement. Now enforcing HANDLEDLFAILOVER.
ERROR OGG-06219 Unable to extract data from the Logmining server
OGG$CAP_EXT1.
ERROR OGG-02078 Extract encountered a fatal error in a processing thread and
is abending.
Extract will continue to automatically restart, based on the Oracle GoldenGate
Microservices auto restart profile, and failing due to reaching the
HANDLEDLFAILOVER
timeout, until the number retries is reached
or the new standby database becomes available.
During the timeout period following a database role transition, the
HANDLEDLFAILOVER
parameter is automatically suspended, so data
will be replicated to the Oracle GoldenGate replica database without consideration
of the source standby database not being kept up to date. The timeout period for the
standby database to start up before Extract abends can be adjusted using the Extract
parameter TRANLOGOPTIONS DLFAILOVER_TIMEOUT
.
It is recommended that you leave DLFAILOVER_TIMEOUT
at the default
of 5 minutes, to allow the old primary to convert to a standby. If the new standby
database will be unavailable for an extended period of time or completely gone, then
in order for Extract to start and remain running, you must remove the
HANDLEDLFAILOVER
parameter from the Extract parameter file.
After removing the parameter, Extract no longer waits until redo has been applied to
the standby database before extracting the data.
During the time it takes for the standby database to come back online and apply all the redo from the primary
database, there will be data divergence between it and the Oracle GoldenGate replica
database. This will be resolved once the standby database is up to date. At which
point, add the HANDLEDLFAILOVER
parameter back into the integrated
Extract process parameter file, and then stop and restart the Extract.
When Oracle Data Guard is configured with fast-start failover, such that the broker can automatically fail over to a standby database in the event of loss of the primary database, you must specify an additional integrated Extract parameter shown below.
TRANLOGOPTIONS FAILOVERTARGETDESTID n
This parameter identifies which standby database the Oracle GoldenGate Extract process must remain behind, with regards to not extracting redo data that has not yet been applied to the standby database.
To determine the correct value for FAILOVERTARGETDESTID
, use the
LOG_ARCHIVE_DEST_N
parameter from the
GoldenGate source database which is used for sending redo to the source standby
database. For example, if LOG_ARCHIVE_DEST_2
points to the standby
database, then use a value of 2.
For example:
SQL> show parameters log_archive_dest
NAME TYPE VALUE
--------------------- -------- ---------------------------------------------------
log_archive_dest_1 string location=USE_DB_RECOVERY_FILE_DEST,
valid_for=(ALL_LOGFILES, ALL_ROLES)
log_archive_dest_2 string service="ggnorths", SYNC AFFIRM delay=0
optional compression=disable max_failure=0 reopen=300
db_unique_name="GGNORTHS" net_timeout=30,
valid_for=(online_logfile,all_roles)
In this example, the Extract parameter would be set to the following:
TRANLOGOPTIONS FAILOVERTARGETDESTID 2
To add the parameters to the Extract parameter file, use the Oracle GoldenGate Administration Server to select display the Extract details
- "On the Administration Service tab, select the Actions menu for the Extract and choose Details."
-
In the Extract details view select the Parameters tab, and then select the pencil icon to edit the current parameter file
- Add the
TRANLOGOPTIONS
parameters and select Apply to save the changes.
For the new parameters to take effect, the Extract process needs to be stopped and restarted, which can be done using the Administration Server.
More information about the Extract TRANLOGOPTIONS
parameters
mentioned above, can be found in the Reference for Oracle GoldenGate at https://docs.oracle.com/en/middleware/goldengate/core/21.3/reference/tranlogoptions.html#GUID-B6ADFEC9-10E6-456D-9477-088513E113AF.
Distribution Path Configuration on the Primary and Standby Cluster
When the target database of an Oracle GoldenGate environment, where the Receiver Server runs, is protected with Oracle Data Guard, there is an important consideration that must be given to any Distribution Paths that are sending trail files to the Receiver Server. When the Receiver Server moves to a different cluster after an Oracle Data Guard role transition, any distribution paths must be altered to reflect the new target cluster address.
You can automatically change the distribution paths using a database role transition trigger in the target database on the Receiver Server cluster.
If the primary and standby cluster VIPs use different root CA certificates, the standby certificate will need to be added to the source deployment Service Manager, as detailed in On-Premises: Oracle GoldenGate Microservices Architecture with Oracle Real Application Clusters Configuration Best Practices.
Follow the instructions below to create a database role transition trigger to modify the distribution path target address when the receiver server moves between the primary and standby cluster, during target database Data Guard role transitions.
-
Create a shell script to modify the distribution paths.
Example Distribution Path Target Change Script contains an example shell script that can be used to modify a distribution path target address. Refer to the example script comments for setting appropriate variable values.
The script should be placed in the same local directory on all Oracle RAC nodes of the primary and standby database clusters. Set the script file permissions to 6751.
For example:
$ chmod 6751 /u01/oracle/goldengate/scripts/change_path_target.sh
The example shell script uses REST API calls to access the GoldenGate distribution path. In order to make the REST API calls secure, it is recommended that you include the GoldenGate deployment administrator user name and password in a configuration file (
access.cfg
), as shown here.$ cat /u01/oracle/goldengate/scripts/access.cfg user = "oggadmin:<password>"
The
access.cfg
file is also referenced in the database role transition trigger below. -
Create a
DBMS_SCHEDULER
job.Creating a
DBMS_SCHEDULER
job is required to run an operating system shell script from within PL/SQL. Create the scheduler job as a SYSDBA user in the root container database (CDB).For example:
SQL> exec dbms_scheduler.drop_job('gg_change_path_target'); SQL> exec dbms_scheduler.create_job(job_name=>'gg_change_path_target', job_type=>'EXECUTABLE', number_of_arguments => 6, job_action=>'/u01/oracle/goldengate/scripts/change_path_target.sh', enabled=>FALSE);
To run an external job, you must set the
run_user
andrun_group
parameters in the$ORACLE_HOME/rdbms/admin/externaljob.ora
file to the Oracle database operating system user and group.For example:
Therun_user = oracle run_group = oinstall
extrernaljob.ora
must be configured on all Oracle RAC nodes of the primary and standby database clusters. -
Create the database role transition trigger.
Create a role transition trigger on the GoldenGate target database that will fire when a standby database becomes a primary database, changing the distribution path target address, using the following example.
CREATE OR REPLACE TRIGGER gg_change_path AFTER db_role_change ON DATABASE declare role varchar2(30); hostname varchar2(64); begin select database_role into role from v$database; select host_name into hostname from v$instance; DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE('gg_change_path_target',1,'source_primary_cluster_VIP'); DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE('gg_change_path_target',2,'source_standby_cluster_VIP'); DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE('gg_change_path_target',4,'dist_path_name'); DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE('gg_change_path_target',5,'deployment_name'); DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE('gg_change_path_target',6, '<dir/access.cfg>'); if role = 'PRIMARY' and hostname like 'primary_target_cluster_name%' then DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE('gg_change_path_target',3,'primary_target_cluster_VIP:443'); elsif role = 'PRIMARY' then DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE('gg_change_path_target',3,'standby_target_cluster_VIP:443'); end if; DBMS_SCHEDULER.RUN_JOB(job_name=>'gg_change_path_target'); end; /
After creating the database trigger, switch the log file on the primary database to ensure the code is propagated to the standby database using the following command:
SQL> alter system switch all logfile;
Replicat Configuration on the Primary Cluster
As documented in On-Premises: Oracle GoldenGate Microservices Architecture with Oracle Real Application Clusters Configuration Best Practices, a checkpoint table in the target database is required for all Oracle GoldenGate Replicat processes. There are no other configuration requirements for Replicat when configured with Oracle Data Guard.
Example Distribution Path Target Change Script
The following example script can be used to change a source GoldenGate deployment distribution path target address to reflect the new location of the receiver server after a Data Guard role transition. This example assumes the source GoldenGate deployment is configured in an MAA architecture with Data Guard, such that the distribution server can relocate between a primary and standby cluster.
#!/bin/bash
# change_path_target.sh - changes the target host of a GG Distribution Path when the target
# moves between primary/standby clusters.
# Example usage:
# ./change_path_target.sh <primary source VIP>:443 <standby source VIP>:443 <path target VIP> <path name> <deployment name> <credentials file>
SOURCE1=$1 # PRIMARY Distribution Server VIP
SOURCE2=$2 # STANDBY Distribution Server VIP
TARGET=$3 # Distribution path target VIP
DPATH=$4 # Distribution path name
DEP=$5 # Deployment name
ACCESS=$6 # access.cfg file containing the deployment credentials. Example contents:
# user = "oggadmin:<password>"
CONNECT=0
#echo "#${i} - `date`:"
LOGFILE=/tmp/ogg_dpatch_change.txt
result=$(curl -si -K $ACCESS https://$SOURCE1/$DEP/distsrvr/services/v2/sources/$DPATH -X GET| grep HTTP | awk '{print $2}')
# Will return NULL of nginx not running, 502 if cannot contact server, 200 if contact to server good, and others (404) for other bad reasons:
if [[ -z $result || $result -ne 200 ]]; then # Managed to access the Distr Server
echo "`date` - Couldn't contact Distribution Server at $SOURCE1 Deployment $DEP ****" >> $LOGFILE
else # Try the other source host:
echo "`date` - Got status of Distribution Server at $SOURCE1 Deployment $DEP ***" >> $LOGFILE
SOURCE=$SOURCE1
CONNECT=1
fi
if [ $CONNECT -eq 1 ]; then
# For secure NGINX patch destination (wss)
PAYLOAD='{"target":{"uri":"wss://'${TARGET}'/services/ggnorth/v2/targets?trail=bb"}}'
curl -s -K $ACCESS https://$SOURCE/$DEP/distsrvr/services/v2/sources/$DPATH -X PATCH --data '{"status": "stopped"}'
# Set new target for path:
curl -s -K $ACCESS https://$SOURCE/$DEP/distsrvr/services/v2/sources/$DPATH -X PATCH --data "$PAYLOAD"
echo "`date` - Set path $DPATH on $SOURCE deployment $DEP:" >> $LOGFILE
curl -s -K $ACCESS https://$SOURCE/$DEP/distsrvr/services/v2/sources/$DPATH -X GET | python -m json.tool | grep uri >> $LOGFILE
curl -s -K $ACCESS https://$SOURCE/$DEP/distsrvr/services/v2/sources/$DPATH -X PATCH --data '{"status": "running"}'
exit 0
else
echo "`date` - ERROR: COULDN'T CHANGE DISTRIBUTION PATH ($DPATH) in Deployement $DEP at $SOURCE! ***" >> $LOGFILE
fi
# If here, means we couldn't connect to either Distribution Servers
exit 1