Prepare to Deploy the Topology

For Data Guard to work, the two databases in the different regions have to communicate. Therefore you need to set up a remote peering connection between the two regions in OCI through their respective DRGs. The DRGs are created by the OracleDB for Azure setup, so you only need to establish a remote peering connection between the existing DRGs.

Set Up the Network

To set up you network, perform the following steps

  1. Set up network connectivity for the Azure VM and OracleDB for Azure database systems.
    • Ensure you have the ssh private key for the Oracle DB system available on the Azure VM.
    • Test the connectivity between the Azure VMs and the OracleDB for Azure DB systems.
  2. Set up the network for database systems in OCI.
    1. First, navigate to the VCN details of the DB System in region 1, select Dynamic Routing Gateway Attachments, and then the DRG name to load the details of the DRG into region 1. Then, select Remote Peering Connection Attachments. In a second browser window, do exactly the same for region 2.
    2. Next, in both regions, select Create Remote Peering Connection to create an RPC.
    3. When both RPCs have been created, select the RPC name in region 1 and copy the OCID.
    4. In region 2, select the RPC name and select Establish Connection. Select the correct region name for region 1 (where we’re connecting to), and provide the OCID for the RPC in region 1, which you have copied in the previous step. A few moments after establishing the connection, the Peer Status should be “Peered”.
    5. Next, allow traffic between the VCNs in the two regions. Navigate to the VCN details and select the default security list. Select Add Ingress Rules to allow traffic from the opposite VCN’s CIDR range.
    6. Finally, connect from the VMs in Azure to the respective OCI Base DB Systems. Edit the tnsnames.ora file for both Base DB Systems to have a connection to the other database.
    7. Confirm that tnsping is working fine from both DB systems to the opposite database.

Set Up the Oracle Database for Azure DR Configuration

To set up the Oracle database for Azure DR configuration, you need to prepare both a primary and a secondary database, as described below.

Note:

Click Copy to save the command example to your clipboard for pasting into your command line. Be sure to replace any variables with values specific to your implementation.

Prepare the Primary Database

To prepare the primary database, you need to configure static listeners, update the tnsnames.ora file, and configure various database settings and parameters.

  1. From the SQL> prompt, to verify the following information:
    • Check database flashback is enabled
    • Check force database logging is enabled
    • Check database is in archive log mode
    • Check database is in open mode
    • Check database is in primary database role
    run this command:
    select log_mode, FORCE_LOGGING, FLASHBACK_ON, OPEN_MODE, DATABASE_ROLE from v$database ;
    The output should look similar to this:
    LOG_MODE              FORCE_LOGGING               FLASHBACK_ON               OPEN_MODE                 DATABASE_ROLE
    ----------------      ------------------------   ----------------------     --------------------        -----------------------
    ARCHIVELOG            YES                         YES                        READ WRITE                  PRIMARY
  2. Check automatic standby file management is set to auto by running this command:
    show parameter standby_file_management
    The output should look similar to this:
    NAME                                          TYPE          VALUE
    ------------------------------------          -----------  ----------
    standby_file_management                       string       AUTO
  3. Set the broker configuration files:
    show parameter dg_broker_config_file1;
    The output should look similar to this:
    NAME                                          TYPE          VALUE
    ------------------------------------         ----------- ------------------------------
    dg_broker_config_file1                        string        /u01/app/oracle/product/19.0.0.0/dbhome_1/dbs/dr1dbuks_898_lhr.dat
    

    Then enter this command:

    show parameter dg_broker_config_file2;
    The output should look similar to this:
    
    NAME                                                     TYPE          VALUE
    ------------------------------------         ----------- ------------------------------
    dg_broker_config_file2                             string          /u01/app/oracle/product/19.0.0.0/dbhome_1/dbs/dr2dbuks_898_lhr.dat
  4. Enable the Data Guard broker:
    show parameter dg_broker_start
    The output should look similar to this:
    NAME                                             TYPE         VALUE
    ------------------------------------            ----------- --------------
    dg_broker_start                                  boolean      FALSE
    Then enter these commands:
    alter system set dg_broker_start=true scope=both;
    
    show parameter dg_broker_start
    The output should look similar to this:
    NAME                                             TYPE        VALUE
    ------------------------------------            ----------- --------------
    dg_broker_start                                  boolean     TRUE
  5. From the command prompt (for example, [oracle@ldbuksdr ]$), note the listerner status:
    lsnrctl status
  6. Note database configuration details:
    srvctl config database -d db_unique_name
  7. Note the tns entries:
    cat $ORACLE_HOME/network/admin/tnsnames.ora
  8. Note sqlnet.ora output:
    cat $ORACLE_HOME/network/admin/sqlnet.ora
  9. Copy the Password File to the standby DB system in the /tmp location by entering these commands:
    cd .ssh
    scp -i private_key /tmp/orapw<sid> opc@ip_standby_vm:/tmp/orapwsid   
  10. Locate and copy the wallet files to the standby DB system in the /tmp location:
    select CON_ID, WRL_PARAMETER, WRL_TYPE, STATUS, WALLET_TYPE from V$ENCRYPTION_WALLET;
    The output should look similar to this:
    CON_ID         WRL_PARAMETER                                                                      STATUS       WALLET_TYPE
    ----------    ------------------------------------------------------------------------------     ------------  ------------ ----------------------------
    1              /opt/oracle/dcs/commonstore/wallets/dbuks_898_lhr/tde/                             OPEN          AUTOLOGIN
    2                                                                                                 OPEN          AUTOLOGIN
    3                                                                                                 OPEN          AUTOLOGIN
    
    Then enter:
    cd /opt/oracle/dcs/commonstore/wallets/db_unique_name/tde
    ls -ltra
    
    You should see something like this:
    -rw------- 1 oracle asmadmin  5467 Jun 19 18:59 ewallet.p12
    -rw------- 1 oracle asmadmin  5512 Jun 19 18:59 cwallet.sso
    
    Then enter these commands (where db_unique_name is the unique name of the wallet's database):
    
    [oracle@ ~]$ cp /opt/oracle/dcs/commonstore/wallets/db_unique_name/tde/ewallet.p12/tmp/cwallet.p12
    cp /opt/oracle/dcs/commonstore/wallets/db_unique_name/tde/cwallet.sso/tmp/cwallet.sso
    chmod 777 /tmp/ewallet.p12
    chmod 777 /tmp/cwallet.sso
    scp -i private_key /tmp/ewallet.p12 opc@ip_standby_vm:/tmp/ewallet.p12
    scp -i private_key /tmp/cwallet.sso opc@ip_standby_vm:/tmp/cwallet.sso.
  11. Configure the static listener.
    A static listener is required for the initial instantiation of the standby database. When a database is down, a static listener enables a remote connection to an instance, enabling you to use Oracle Data Guard to start the instance. Be sure there are no line breaks or white spaces in the listener.ora files.

    On the primary database, append the SID_LIST_LISTENER file in the listener.ora file to include the database unique name, Oracle Home, and the Oracle System Identifier (SID) of the primary database.

    lsnrctl status 
    vi listener.ora 
    Add the following entry to listener.ora, where:
    • DB_UNIQUE_NAME is the unique name of the primary database.
    • ORACLE_HOME is the local Oracle home of the primary database.
    • ORACLE SID is the SID of the primary database.
    SID_LIST_LISTENER=(SID_LIST=(SID_DESC=(GLOBAL_DBNAME=DB_UNIQUE_NAME)(ORACLE_HOME=ORACLE_HOME) 
    (SID_NAME = ORACLE SID)))
    The entry should look similar to the following (your entries for GLOBAL_DBNAME, ORACLE_HOME, and SID_NAME will vary):
    SID_LIST_LISTENER=(SID_LIST=(SID_DESC=(GLOBAL_DBNAME=dbuks_898_lhr.odsp129521.cvcn.oraclevcn.com)
    (ORACLE_HOME=/u01/app/oracle/product/19.0.0.0/dbhome_1)(SID_NAME=dbuks)))
    Reload the listener and check its status.
    lsnrctl reload
    lsnrctl status
  12. Configure tns entries.
    You need entries for each database in both the primary and standby tnsnames.ora files to ensure proper redo transport. IP addresses are used since there is no DNS between the databases to resolve server names to IP addresses. Use the following example, replacing values relevant to the configuration. Oracle Real Application Clusters (Oracle RAC) configurations cannot resolve the scan listener name; therefore, you must use an address list to define all nodes. Those will be added later, the initial instance should only list one IP address in the tns entries to ensure that Oracle Recovery Manager (RMAN) is always connecting to the same nodes.
    [oracle@~]$ cd $ORACLE_HOME/network/admin 
    [oracle@~]$ vi tnsnames.ora
    The entry in the tnsnames.ora file should look similar to the following:
    DBUKS_R2J_AMS=(DESCRIPTION=(SDU=65536)(RECV_BUF_SIZE=134217728)(SEND_BUF_SIZE=134217728)(ADDRESS_LIST=(FAILOVER=on)(CONNECT_TIMEOUT=3)
    (RETRY_COUNT=3)(ADDRESS=(PROTOCOL=TCP)(HOST=10.91.0.177)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)
    (SERVICE_NAME=dbuks_r2j_ams.odsp083156.cvcn.oraclevcn.com)(UR=A))) 
    
    DBUKS_898_LHR=(DESCRIPTION=(SDU=65535)(RECV_BUF_SIZE=134217728)(SEND_BUF_SIZE=134217728)(ADDRESS_LIST=(FAILOVER=on)(CONNECT_TIMEOUT=3)
    (RETRY_COUNT=3)(ADDRESS=(PROTOCOL=TCP)(HOST=10.90.0.246)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)
    (SERVICE_NAME=dbuks_898_lhr.odsp129521.cvcn.oraclevcn.com)(UR=A)))

Prepare the Standby Database

Next, perpare the standby database.

  1. Manually delete the database created by Oracle Database for Azure tooling.
    Before deleting the standby database, save the current db_unique_name and note the wallet location as that will be used later. The following query provides details for the wallet location.
    1. From the sqlplus command prompt, enter::
      select * from V$ENCRYPTION_WALLET; 
    2. Next, prepare rm_dbfiles.sql script to remove database related files:
      srvctl config database -d db_unique_name
    3. Run the following script to shut down the database that you're building as a standby and remove the database files:
      vi rm_dbfiles.sql 
      set heading off linesize 999 pagesize 0 feedback off trimspool on 
      spool /home/oracle/demo/files.lst 
      select 'asmcmd rm '||name from v$datafile union all select 'asmcmd rm '||name from v$tempfile union all select 'asmcmd rm '||member from v$logfile; 
      spool off 
      create pfile='/home/oracle/demo/ORACLE_UNQNAME.pfile' from spfile; 
      exit
      
    4. Then go to the sqlplus prompt as the system DBA:
      sqlplus "/ as sysdba"
      And run these commands:
      @rm_dbfiles.sql
      exit
    5. Next, grant permission to read, write and execute (where db_unique_name is the unique name of the affected database):
      chmod 777 files.lst
      srvctl stop database -d db_unique_name
    6. Save and execute the script :
      ./files.lst 
    All files for the starter database have now been removed.
  2. Copy the password file and wallet files received in /tmp from primary database to the respective locations on the standby database DB system.
    1. Copy the database password file and the wallet files received in /tmp from primary to the respective locations on the standby database DB system (where orapwsid is the SID passsword):
      sudo cp /tmp/orapwsid $ORACLE_HOME/dbs/orapwsid 
      For example:
      sudo ls -ltra /u01/app/oracle/product/19.0.0.0/dbhome_1/dbs/orapwdbuks 
      The output should look similar to the following:
      
      -rw-r-----1 oracle oinstall 2048 Jul3 13:42 /u01/app/oracle/product/19.0.0.0/dbhome_1/dbs/orapwdbuks
    2. Verify that the md5sum output of password file matches on Primary and Standby (where orapwsid is the SID passsword):
      md5sum /u01/app/oracle/product/19.0.0.0/dbhome_1/dbs/orapwsid 
      The output for the primary database should look similar to the following (where the orapwsid is orapwdbuks):
      
      b3895fa6357471f80c6e0f4ac16fdc23 /u01/app/oracle/product/19.0.0.0/dbhome_1/dbs/orapwdbuks 
      
      And for the standby database:
      
      b3895fa6357471f80c6e0f4ac16fdc23 /u01/app/oracle/product/19.0.0.0/dbhome_1/dbs/orapwdbuks
    3. Remove existing wallet files and copy wallet files from /tmp to the TDE location (where db_unique_name is the unique name of the affected database):
      [oracle@ ~]$ cd /opt/oracle/dcs/commonstore/wallets/db_unique_name/tde/
      rm ewallet.p12 cwallet.sso
      sudo cp /tmp/ewallet.p12 /opt/oracle/dcs/commonstore/wallets/db_unique_name/tde/ewallet.p12
      sudo cp /tmp/cwallet.sso /opt/oracle/dcs/commonstore/wallets/db_unique_name/tde/cwallet.ss
      chown oracle:asmadmin /opt/oracle/dcs/commonstore/wallets/db_unique_name/tde/ewallet.p12
      sudo chown oracle:asmadmin /opt/oracle/dcs/commonstore/wallets/db_unique_name/tde/cwallet.sso
  3. Configure static listener:
    1. On the standby database in OCI, append the SID_LIST_LISTENER file to include the database unique name, Oracle Home of OCI, and the Oracle System Identifier (SID) of the primary database.
      lsnrctl status
      vi listener.ora
    2. Add the following entry to the listener.ora file, where:
      • DB_UNIQUE_NAME is the name of the primary database.
      • ORACLE_HOME is the local Oracle home of the primary database.
      • ORACLE SID is the SID of the primary database.
       SID_LIST_LISTENER=(SID_LIST=(SID_DESC=(GLOBAL_DBNAME=DB_UNIQUE_NAME)(ORACLE_HOME=ORACLE_HOME) 
      (SID_NAME = ORACLE_SID)))
      For example, the entry should look similar to the following:
      SID_LIST_LISTENER=(SID_LIST=(SID_DESC=(GLOBAL_DBNAME= dbuks_r2j_ams. odsp083156.cvcn.oraclevcn.com)
      (ORACLE_HOME=/u01/app/oracle/product/19.0.0.0/dbhome_1)(SID_NAME=dbuks))) 
    3. Reload listener and check status:
      lsnrctl reload 
      lsnrctl status
  4. Configure the tns entries:
    cd $ORACLE_HOME/network/admin
    vi tnsnames.ora
    The entry in the tnsnames.ora file should look similar to the following:
     DBUKS_R2J_AMS=(DESCRIPTION=(SDU=65536)(RECV_BUF_SIZE=134217728)(SEND_BUF_SIZE=134217728)(ADDRESS_LIST=(FAILOVER=on)(CONNECT_TIMEOUT=3)
    (RETRY_COUNT=3)(ADDRESS=(PROTOCOL=TCP)(HOST=10.91.0.177)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)
    (SERVICE_NAME=dbuks_r2j_ams.odsp083156.cvcn.oraclevcn.com)(UR=A))) 
    
    DBUKS_898_LHR=(DESCRIPTION=(SDU=65535)(RECV_BUF_SIZE=134217728)(SEND_BUF_SIZE=134217728)(ADDRESS_LIST=(FAILOVER=on)(CONNECT_TIMEOUT=3)
    (RETRY_COUNT=3)(ADDRESS=(PROTOCOL=TCP)(HOST=10.90.0.246)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)
    (SERVICE_NAME=dbuks_898_lhr.odsp129521.cvcn.oraclevcn.com)(UR=A)))