Skip to main content

Step-by-Step Guide to Set Up Data Guard Broker in Oracle

Step-by-Step Guide to Set Up Data Guard Broker in Oracle


Oracle Data Guard Broker is a distributed management framework that automates and centralizes the creation, configuration, and monitoring of a Data Guard configuration. It simplifies many of the tasks related to managing Data Guard.

This guide outlines the step-by-step process for setting up the Data Guard Broker in Oracle.

Pre-Requisites

Before setting up Data Guard Broker, ensure that:

  1. You have an Oracle Database environment configured with a primary and standby database.
  2. Data Guard is already configured and running between the primary and standby databases.
  3. Both the primary and standby databases are using Oracle Enterprise Edition.
  4. Oracle Net Services is configured to allow connectivity between the primary and standby systems.

Step 1: Enable Force Logging and Archive Log Mode on Primary

First, ensure that the primary database is in archive log mode and force logging is enabled:

  1. Log in to the primary database as SYSDBA:


    sqlplus / as sysdba
  2. Enable force logging:


    ALTER DATABASE FORCE LOGGING;
  3. Ensure the database is in ARCHIVELOG mode:


    ARCHIVE LOG LIST;

    If the database is not in archive log mode, put it in archive log mode:


    SHUTDOWN IMMEDIATE; STARTUP MOUNT; ALTER DATABASE ARCHIVELOG; ALTER DATABASE OPEN;

Step 2: Configure the Primary and Standby Database Parameters

You need to configure several initialization parameters on both the primary and standby databases to enable Data Guard Broker.

On the Primary Database:

  1. Set the DB_UNIQUE_NAME and LOG_ARCHIVE_CONFIG:


    ALTER SYSTEM SET LOG_ARCHIVE_CONFIG='DG_CONFIG=(primary_db, standby_db)' SCOPE=BOTH; ALTER SYSTEM SET DB_UNIQUE_NAME='primary_db' SCOPE=SPFILE;
  2. Set the LOG_ARCHIVE_DEST_2 parameter to point to the standby database:

    ALTER SYSTEM SET LOG_ARCHIVE_DEST_2='SERVICE=standby_db ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=standby_db' SCOPE=BOTH;

  3. Enable the Data Guard Broker:


    ALTER SYSTEM SET DG_BROKER_START=TRUE SCOPE=BOTH;
  4. Set the FAL_SERVER and FAL_CLIENT:


    ALTER SYSTEM SET FAL_SERVER='standby_db' SCOPE=BOTH; ALTER SYSTEM SET FAL_CLIENT='primary_db' SCOPE=BOTH;

On the Standby Database:

  1. Set the DB_UNIQUE_NAME and LOG_ARCHIVE_CONFIG:


    ALTER SYSTEM SET LOG_ARCHIVE_CONFIG='DG_CONFIG=(primary_db, standby_db)' SCOPE=BOTH; ALTER SYSTEM SET DB_UNIQUE_NAME='standby_db' SCOPE=SPFILE;
  2. Set the LOG_ARCHIVE_DEST_2 parameter to point to the primary database:


    ALTER SYSTEM SET LOG_ARCHIVE_DEST_2='SERVICE=primary_db ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=primary_db' SCOPE=BOTH;
  3. Enable the Data Guard Broker:


    ALTER SYSTEM SET DG_BROKER_START=TRUE SCOPE=BOTH;
  4. Set the FAL_SERVER and FAL_CLIENT:


    ALTER SYSTEM SET FAL_SERVER='primary_db' SCOPE=BOTH; ALTER SYSTEM SET FAL_CLIENT='standby_db' SCOPE=BOTH;

Step 3: Set Up Static Listener Entries

Make sure that the static listener entries are present on both the primary and standby databases to handle the Data Guard Broker connections.

  1. Open the listener.ora file on both primary and standby servers.

  2. Add a static listener entry for the databases. Example:


    (SID_DESC = (GLOBAL_DBNAME = primary_db_DGMGRL) (ORACLE_HOME = /u01/app/oracle/product/19.0.0/dbhome_1) (SID_NAME = primary_db) )
  3. Restart the listener:


    lsnrctl reload

Step 4: Create the Data Guard Configuration Using DGMGRL

Now that the initialization parameters are set, use the Data Guard Command-Line Interface (DGMGRL) to configure the Data Guard Broker.

  1. Connect to the primary database using DGMGRL:


    dgmgrl sys/password@primary_db
  2. Create a Data Guard configuration:


    CREATE CONFIGURATION 'DGConfig' AS PRIMARY DATABASE IS 'primary_db' CONNECT IDENTIFIER IS 'primary_db';
  3. Add the standby database to the configuration:


    ADD DATABASE 'standby_db' AS CONNECT IDENTIFIER IS 'standby_db';
  4. Enable the configuration:


    ENABLE CONFIGURATION;
  5. Verify the Data Guard configuration:


    SHOW CONFIGURATION;

Step 5: Verify the Data Guard Setup

You can verify that the Data Guard Broker is working properly by using DGMGRL commands.

  1. Check the configuration status:


    SHOW CONFIGURATION;

    This command should return the status of both the primary and standby databases. If everything is correct, the status should be "SUCCESS".

  2. Check the primary and standby database status:


    SHOW DATABASE 'primary_db'; SHOW DATABASE 'standby_db';

    The status of each database should show "SUCCESS" and "ONLINE" as the role.

Step 6: Switchover and Failover Using Data Guard Broker

After setting up Data Guard Broker, you can easily perform switchover and failover operations using the DGMGRL command-line utility.

Switchover

To perform a switchover from the primary to the standby database:

  1. Connect to DGMGRL:


    dgmgrl sys/password@primary_db
  2. Issue the switchover command:


    SWITCHOVER TO 'standby_db';
  3. Verify the switchover status:


    SHOW CONFIGURATION;

    After the switchover, the former standby database becomes the primary database, and the former primary database becomes the standby.

Failover

To perform a failover to the standby database (in case of a primary database failure):

  1. Connect to DGMGRL:


    dgmgrl sys/password@standby_db
  2. Issue the failover command:


    FAILOVER TO 'standby_db';
  3. Verify the failover status:


    SHOW CONFIGURATION;

    After the failover, the standby database takes over as the primary database.

Step 7: Monitoring and Managing Data Guard with Broker

  1. Monitor the configuration:


    SHOW CONFIGURATION VERBOSE;

    This will give you detailed information about the Data Guard configuration.

  2. Check log gaps:

    You can check for log transport and apply lag between the primary and standby databases.


    SHOW DATABASE 'standby_db' STATUSREPORT;
  3. Disable or enable specific databases:

    To disable a database:


    DISABLE DATABASE 'standby_db';

    To enable it again:


    ENABLE DATABASE 'standby_db';
  4. Remove a database from the configuration (e.g., for maintenance):


    REMOVE DATABASE 'standby_db';






Please do like and subscribe to my youtube channel: https://www.youtube.com/@foalabs If you like this post please follow,share and comment

Comments

Popular posts from this blog

WebLogic migration to OCI using WDT tool

WebLogic migration to OCI using WDT tool Oracle WebLogic Deploy Tool (WDT) is an open-source project designed to simplify and streamline the management of Oracle WebLogic Server domains. With WDT, you can export configuration and application files from one WebLogic Server domain and import them into another, making it a highly effective tool for tasks like migrating on-premises WebLogic configurations to Oracle Cloud. This blog outlines a detailed step-by-step process for using WDT to migrate WebLogic resources and configurations. Supported WLS versions Why Use WDT for Migration? When moving Oracle WebLogic resources from an on-premises environment to Oracle Cloud (or another WebLogic Server), WDT provides an efficient and reliable approach to: Discover and export domain configurations and application binaries. Create reusable models and archives for deployment in a target domain. Key Pre-Requisites Source System: An Oracle WebLogic Server with pre-configured resources such as: Applica...

How to Validate TDE Wallet Password in Oracle Database

How to Validate TDE Wallet Password in Oracle Database Validating the Transparent Data Encryption (TDE) wallet password is crucial, especially when ensuring that the password is correct without using the OPEN or CLOSE commands in the database. This blog post explains a straightforward method to validate the TDE password using the mkstore utility. Steps to Validate TDE Wallet Password Follow these steps to validate the TDE wallet password: Step 1: Copy the Keystore/Wallet File Navigate to your existing TDE wallet directory. Copy only the ewallet.p12 file to a new directory. If a cwallet.sso file exists, do not copy it . The absence of cwallet.sso ensures that the wallet does not use auto-login, forcing the utility to prompt for the password. Step 2: Validate Using mkstore Use the mkstore utility to check the contents of the wallet file. The mkstore utility will prompt you for the TDE wallet password, allowing you to validate its correctness. Command Syntax To display the conten...

Rename a PDB in Oracle Database Multitenant Architecture in TDE and Non TDE Environment

Rename a PDB in Oracle Database Multitenant Architecture I am sharing a step-by-step guide to help you rename a PDB. This approach uses SQL commands. Without TDE or encryption Wallet Initial Check Check the Current Database Name and Open Mode: SQL > SELECT NAME, OPEN_MODE FROM V$DATABASE; NAME OPEN_MODE --------- -------------------- BEECDB READ WRITE List Current PDBs: SQL > SHOW PDBS; CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 FUAT READ WRITE NO We need to RENAME FUAT to BEE  Steps to Rename the PDB Step 1: Export ORACLE_SID Set the Oracle SID to the Container Database (CDB): export ORACLE_SID=BEECDB Step 2: Verify Target PDB Name Availability If the target PDB name is different from the current PDB name, ensure no service exists with the target PDB name. Run SQL to Check Exi...