Viscosity's Blog

Oracle Database Appliance: Data Guard Configuration Using ODACLI

Written by Julio Ayapan | May 3, 2023 12:54:29 AM

Oracle Database Appliance (ODA) is a complete and ideal database platform for small, medium, and large-sized database implementations. It incorporates robust, time-tested Oracle technologies, including the world-leading Oracle Database, the best-selling Oracle Real Application Clusters (RAC) database option, Oracle Clusterware, and Oracle Automatic Storage Management (ASM). By integrating hardware and software, ODA eliminates the complexities inherent in non-integrated, manually assembled database solutions, reducing deployment time from weeks or months to just a few hours while preventing configuration and setup errors that often result in sub-optimal, hard-to-manage database environments.

 

Data Protection Using Oracle Data Guard

While the ODA is a highly available system by itself, a standby database environment can provide data protection and reduce planned and unplanned downtime in case the primary database environment becomes unavailable or corrupted. Therefore, a standby database has always been an integral component of Oracle Maximum Availability Architecture (MAA) to provide additional high availability and data protection for any mission-critical production system. With Oracle (MAA) Gold Tier best practices, the standby database can be synchronized with the primary database, thereby minimizing database downtime for planned maintenance activities, such as database upgrades and unplanned outages, such as data corruptions, database failures, cluster failures, power outage or natural disaster.

 

With ODA 19.8 Release and later, Oracle Data Guard is integrated with ODA. You can use ODACLI commands to quickly set up and manage Oracle Data Guard with another ODA.

 

Data Guard Configuration using ODACLI

In the following example, we will configure a Data Guard environment using two Oracle Database Appliance X8-2S and the command line utility ODACLI.

 

Topology:

 

  Primary ODA Standby ODA
ODA Version X8-2S     X8-2S
System Version 19.16.0.0.0 19.16.0.0.0
Database Version 19.8.0.0.200714  19.8.0.0.200714 
Hostname proddb1 stbydb1
Database Name ORCL ORCL
Database Unique Name ORCL ORCLDR
Instance Name ORCL ORCL
Grid Home /u01/app/19.0.0.0/grid /u01/app/19.0.0.0/grid
Oracle Home /u01/app/odaorahome/oracle/product/19.0.0.0/dbhome_3/ /u01/app/odaorahome/oracle/product/19.0.0.0/dbhome_3/
Database Storage ACFS ACFS
ARCHIVELOG mode Yes Yes
FORCE LOGGING mode Yes Yes

 


Now, let’s configure the Data Guard Environment using ODACLI.

 

  1. Configuring Remote database backup for the source database.
We will use an NFS backup location mounted on /backups in both ODAs.
# cat /etc/fstab:
 
10.90.12.51:/backups   /backups       nfs       _netdev,rw,bg,vers=3,rsize=65536,wsize=65536,hard,intr,nosuid

 

On Primary ODA, create a backup configuration for a non-TDE database.

# mkdir /backups/ORCLDR
# odacli create-backupconfig -d NFS -n nfs -cr -c /backups/ORCLDR -w 7
 

 

Creation will take a few seconds, then we can check the status using:

# odacli list-backupconfigs
 
ID                                   Name     RecoveryWindow CrosscheckEnabled BackupDestination
------------------------------------ -------- --------------- ----------------- -----------------
822f42c8-a999-4269-8fb9-1499ef78e2fd default     7               true           Disk
aab5839b-31f0-4987-8244-e78acb9d42e0 nfs         7                true           NFS
 
 
 

 

Once created, assign the backup configuration to the source database.

# odacli modify-database -in ORCL -bin nfs -bp
Enter RMAN backup encryption password:
Retype RMAN backup encryption password:
 
{
  "jobId" : "6798fad3-c744-444b-aa62-600445061128",
  "status" : "Created",
  "message" : "Modify database",
  "reports" : [ ],
  "createTimestamp" : "April 11, 2023 17:08:52 PM CDT",
  "resourceList" : [ {
     "resourceId" : "445c86c5-f829-4e6f-8c94-0bd3a5c39eba",
     "resourceType" : "DB",
     "resourceNewType" : null,
     "jobId" : "6798fad3-c744-444b-aa62-600445061128",
     "updatedTime" : "April 11, 2023 17:08:52 PM CDT"
  } ],
  "description" : "Modify database : ORCL",
  "updatedTime" : "April 11, 2023 17:08:52 PM CDT",
  "jobType" : ""
}

 

We can check the status of the creation job by using odacli describe-job -i <jobId>

 

  1. Create a Level 0 database backup and keep archive logs.
# odacli create-backup -in ORCL -bt Regular-L0 -ka
{
   "jobId" : "cfbd7bc2-b053-402e-9f2b-546a5cd85227",
   "status" : "Created",
   "message" : "",
   "reports" : [ ],
   "createTimestamp" : "April 11, 2023 17:13:02 PM CDT",
   "resourceList" : [ ],
   "description" : "Create Regular-L0
Backup[TAG:auto][Db:ORCL] [NFS:/backups/ORCLDR/orabackups/PRODDB1-c/database/280636083/ORCL]",
   "updatedTime" : "April 11, 2023 17:13:02 PM CDT",
   "jobType" : null
}

 

Verify that the job completed successfully with odacli describe-job.

# odacli describe-job -i cfbd7bc2-b053-402e-9f2b-546a5cd85227
 
Job details
----------------------------------------------------------------
                    ID:   cfbd7bc2-b053-402e-9f2b-546a5cd85227
           Description: Create Regular-L0 Backup[TAG:auto][Db:ORCL][NFS:/backups/ORCLDR/orabackups/PRODDB1-c/database/280636083/ORCL]
                 Status: Running
               Created: April 11, 2023 5:13:02 PM CDT
               Message:
 
Task Name                         Start Time                       End Time                         Status
-------------------------------- -------------------------------- -------------------------------- ---------
Validate backup config            April 11, 2023 5:13:06 PM CDT    April 11, 2023 5:13:06 PM CDT    Success
NFS location existence validation April 11, 2023 5:13:06 PM CDT    April 11, 2023 5:13:07 PM CDT    Success
Recovery Window validation        April 11, 2023 5:13:07 PM CDT    April 11, 2023 5:13:10 PM CDT    Success
Archivelog deletion policy configuration
                                  April 11, 2023 5:13:10 PM CDT    April 11, 2023 5:13:13 PM CDT    Success
Database backup                   April 11, 2023 5:13:13 PM CDT    April 11, 2023 5:13:13 PM CDT    Running

 

  1. Identify the ID of the backup report that belongs to the L0 backup:
# odacli list-backupreports
 
Backup Report Id                           Database Resource Id                     Database DbId DB Name   DB Unique Name Backup Type Backup Tag     Create Time          Updated Time                         Status
---------------------------------------- ---------------------------------------- ------------- ---------- -------------- ------------ ------------ ----------------------------------- ----------------------------------- ------------
d0ad35d8-3d18-44c9-ac58-c830349800e2     445c86c5-f829-4e6f-8c94-0bd3a5c39eba     280636083     ORCL       ORCL         Regular-L0   auto         April 11, 2023
5:13:13 PM CDT       April 11, 2023 5:13:13 PM CDT       Configured

 

  1. Take a backup of the backup report into json format and copy it over to the standby machine.
# odacli describe-backupreport -i d0ad35d8-3d18-44c9-ac58-c830349800e2 > /backups/ORCLDR/backupreport_ORCL_20230411.json

 

  1. We will work on the standby side now. Double-check if the NFS was configured on the standby side.
  2. Restore the database as a standby on the target.

Identify the ID of the home in case an existing home would be used:

# odacli list-dbhomes
ID                                      Name                 DB Version                              
Home Location                                   Status
---------------------------------------- -------------------- ---------------------------------------- --------------------------------------------- ----------
791f2883-2f78-4607-8e37-01c94cea3c8c     OraDB11204_home5     11.2.0.3.3                                 /u01/app/oracle/product/11.2.0.4/dbhome_5     CONFIGURED
717b2d67-1d4b-4a22-b882-8e206bde475c     OraDB12201_home2     12.2.0.1.200714                           /u01/app/oracle/product/12.2.0.1/dbhome_2     CONFIGURED
c03244d8-841d-46a6-b7ba-4cedcf169168     OraDB11204_home4     11.2.0.4.170418                           /u01/app/oracle/product/11.2.0.4/dbhome_4    CONFIGURED
fa6d456a-2b19-4502-97ca-41ad6d3f32ab     OraDB19000_home1     19.8.0.0.200714                           /u01/app/oracle/product/19.0.0.0/dbhome_1     CONFIGURED
5cea89ef-8ec8-4b52-8107-713d018850ba     OraDB12201_home1     12.2.0.1.0                              /u01/app/oracle/product/12.2.0.1/dbhome_1     CONFIGURED
613eb07a-0fe4-49da-bc2e-d1b26182a12b     OraDB19000_home3     19.8.0.0.200714                           /u01/app/odaorahome/oracle/product/19.0.0.0/dbhome_3 CONFIGURED

 

Restore the database with the odacli irestore-database command.

 

# odacli irestore-database -r /backups/ORCLDR/backupreport_ORCL_20230411.json -u ORCLDR -ro STANDBY -bp -dh 613eb07a-0fe4-49da-bc2e-d1b26182a12b --backupLocation /backups/ORCLDR/
Enter SYS user password:
Retype SYS user password:
Enter RMAN backup encryption password:
Do you want to provide another RMAN backup encryption password? [y/n] (default 'n'):
{
   "jobId" : "e5d22c1e-1451-43ae-9465-08bd2d925714",
   "status" : "Created",
   "message" : null,
   "reports" : [ ],
   "createTimestamp" : "April 11, 2023 17:39:20 PM CDT",
   "resourceList" : [ ],
   "description" : "Database service recovery with db name: ORCL",
   "updatedTime" : "April 11, 2023 17:39:20 PM CDT",
   "jobType" : ""
}

 

Verify that the job completed successfully.

 

# odacli describe-job -i e5d22c1e-1451-43ae-9465-08bd2d925714
 
Job details
----------------------------------------------------------------
                     ID: e5d22c1e-1451-43ae-9465-08bd2d925714
           Description: Database service recovery with db name: ORCL
                 Status: Success
               Created: April 11, 2023 5:39:20 PM CDT
               Message:
 
Task Name                                Start Time              End Time            Status
--------------------------------------- ----------------------------------- ----------------------------------- ----------
Check if cluster ware is running       April 11, 2023 5:39:26 PM CDT    April 11, 2023 5:39:26 PM CDT         Success
Creating DbStorage for DbRestore       April 11, 2023 5:39:26 PM CDT    April 11, 2023 5:40:35 PM CDT       Success
Validating DiskSpace for DATA          April 11, 2023 5:39:26 PM CDT    April 11, 2023 5:39:27 PM CDT       Success
Setting up ssh equivalance             April 11, 2023 5:39:27 PM CDT    April 11, 2023 5:39:27 PM CDT       Success
Creating volume datIMDEV               April 11, 2023 5:39:27 PM CDT    April 11, 2023 5:39:44 PM CDT      Success
Creating volume rdoIMDEV               April 11, 2023 5:39:44 PM CDT    April 11, 2023 5:40:00 PM CDT       Success
Creating ACFS filesystem for DATA      April 11, 2023 5:40:00 PM CDT    April 11, 2023 5:40:18 PM CDT       Success
Creating ACFS filesystem for RECO      April 11, 2023 5:40:18 PM CDT    April 11, 2023 5:40:35 PM CDT       Success
Audit directory creation               April 11, 2023 5:40:35 PM CDT    April 11, 2023 5:40:35 PM CDT         Success
Create pfile for Auxiliary Instance    April 11, 2023 5:40:36 PM CDT    April 11, 2023 5:40:36 PM CDT       Success
Modifying Storage Dir Ownership        April 11, 2023 5:40:36 PM CDT    April 11, 2023 5:40:36 PM CDT       Success
Rman duplicate                         April 11, 2023 5:40:36 PM CDT    April 11, 2023 5:45:54 PM CDT       Success
Creating pfile from spfile             April 11, 2023 5:45:54 PM CDT    April 11, 2023 5:45:55 PM CDT       Success
Set PFile Ownership                    April 11, 2023 5:45:55 PM CDT    April 11, 2023 5:45:55 PM CDT       Success
Customize Db Parameters                April 11, 2023 5:45:55 PM CDT    April 11, 2023 5:45:56 PM CDT       Success
Shutdown And Start database            April 11, 2023 5:45:56 PM CDT    April 11, 2023 5:46:32 PM CDT       Success
Create spfile for restore db           April 11, 2023 5:46:32 PM CDT    April 11, 2023 5:46:33 PM CDT       Success
Set PFile Ownership                    April 11, 2023 5:46:33 PM CDT    April 11, 2023 5:46:33 PM CDT         Success
Shutdown And Mount database            April 11, 2023 5:46:33 PM CDT    April 11, 2023 5:47:11 PM CDT       Success
Register Database taskflow             April 11, 2023 5:47:23 PM CDT    April 11, 2023 5:50:07 PM CDT       Success
Create SPFile in shared loc            April 11, 2023 5:47:23 PM CDT    April 11, 2023 5:47:39 PM CDT       Success
Delete Local Spfile                    April 11, 2023 5:47:39 PM CDT    April 11, 2023 5:47:39 PM CDT       Success
Register DB with clusterware           April 11, 2023 5:47:39 PM CDT    April 11, 2023 5:48:20 PM CDT       Success
Set SysPassword and Create PwFile      April 11, 2023 5:48:20 PM CDT    April 11, 2023 5:48:23 PM CDT       Success
Enable block change tracking           April 11, 2023 5:48:23 PM CDT    April 11, 2023 5:48:35 PM CDT       Success
Creating pfile                         April 11, 2023 5:48:35 PM CDT    April 11, 2023 5:48:36 PM CDT       Success
Updating db env                        April 11, 2023 5:48:36 PM CDT    April 11, 2023 5:48:36 PM CDT       Success
Enable DbSizing Template               April 11, 2023 5:48:36 PM CDT    April 11, 2023 5:49:21 PM CDT       Success
Create tns entry                       April 11, 2023 5:49:21 PM CDT    April 11, 2023 5:49:21 PM CDT       Success
Running datapatch                      April 11, 2023 5:49:21 PM CDT    April 11, 2023 5:49:24 PM CDT       Success
Set CPU pool                           April 11, 2023 5:49:24 PM CDT    April 11, 2023 5:49:24 PM CDT       Success
Reset Associated Networks              April 11, 2023 5:50:07 PM CDT    April 11, 2023 5:50:14 PM CDT         Success
Set log_archive_dest for Database      April 11, 2023 5:50:14 PM CDT    April 11, 2023 5:50:19 PM CDT         Success
Copy Pwfile to Shared Storage          April 11, 2023 5:50:20 PM CDT    April 11, 2023 5:50:22 PM CDT         Success

 

Verify that the new database is in “CONFIGURED” status.

 

# odacli list-databases
 
ID                                       DB Name   DB Type DB Version          
CDB       Class   Shape     Storage   Status       DbHomeID
---------------------------------------- ---------- -------- -------------------- ---------- -------- -------- ---------- ------------ ----------------------------------------
39d93a30-2e69-4cb2-9f74-5dba5a750766     ORCL       SI       19.8.0.0.200714     false     OLTP       odb1     ACFS       CONFIGURED   613eb07a-0fe4-49da-bc2e-d1b26182a12b

 

Now, we will return to the ODA primary node.

 

  1. Configure Data Guard from the primary ODA’s first node.

Prerequisites:

  1. Listener port(s) and port 7070 must be open to create Oracle Data Guard between two ODAs.
  2. Configuring Data Guard would require a 19.15 ODA version when either primary or standby database (or both) were configured on a DBSystem(s).
# odacli configure-dataguard
Standby site address: stbydb1
BUI username for Standby site. If Multi-user Access is disabled on Standby site, enter 'oda-admin'; otherwise, enter the name of the user who has irestored the Standby database (default: oda-admin):
BUI password for Standby site:
root@stbydb1's password:
Database name for Data Guard configuration: ORCL
Primary database SYS password: ************************************************************************************
Data Guard default settings
Primary site network for Data Guard configuration: Public-network
Standby site network for Data Guard configuration: Public-network
Primary database listener port: 1521
Standby database listener port: 1521
Transport type: ASYNC
Protection mode: MAX_PERFORMANCE
Data Guard configuration name: orcl_orcldr
Active Data Guard: disabled
Do you want to edit this Data Guard configuration? (Y/N, default:N): y ************************************************************************************
Primary site network for Data Guard configuration [Public-network] (default: Public-network):
Standby site network for Data Guard configuration [Public-network] (default: Public-network):
Primary database listener port (default: 1521):
Standby database listener port (default: 1521):
Transport type [ASYNC, FASTSYNC, SYNC] (default: ASYNC):
Protection mode [MAX_PROTECTION, MAX_PERFORMANCE, MAX_AVAILABILITY] (default: MAX_PERFORMANCE):
Data Guard configuration name (default: orcl_orcldr):
Enable Active Data Guard? (Y/N, default:N): n
Standby database's SYS password will be set to Primary database's after Data Guard configuration. Ignore warning and proceed with Data Guard configuration? (Y/N, default:N): y ************************************************************************************Configure Data Guard orcl_orcldr started ************************************************************************************
Step 1: Validate Data Guard configuration request (Primary site)
Description: Validate DG Config Creation for db ORCL
Job ID: 1cdcc4d9-f869-49ed-90a7-651a0a76db03
Started April 11, 2023 18:02:17 PM CET Validate create Data Guard configuration request
Finished April 11, 2023 18:02:21 PM CET ************************************************************************************
Step 2: Validate Data Guard configuration request (Standby site)
Description: Validate DG Config Creation for db ORCL
Job ID: c9dcb3fc-90d7-495e-860d-d3fdd421aad0
Started April 11, 2023 18:02:22 PM CET
Validate create Data Guard configuration request
Finished April 11, 2023 18:02:27 PM CET ************************************************************************************ Step 3: Download password file from Primary database (Primary site)
Description: Download orapwd file from Primary database
Started April 11, 2023 18:02:27 PM CET
Prepare orapwd file for Primary database ORCL
Finished April 11, 2023 18:02:32 PM CET ************************************************************************************
Step 4: Upload password file to Standby database (Standby site)
Description: Upload orapwd file to Standby database
Started April 11, 2023 18:02:32 PM CET
Write orapwd file to Standby database ORCL
Finished April 11, 2023 18:02:43 PM CET ************************************************************************************ Step 5: Configure Primary database (Primary site)
Description: DG Config service for db hun – ConfigurePrimary
Job ID: ed2e490d-f3e4-40b5-adee-ec5a31c6cdc6
Started April 11, 2023 18:02:44 PM CET
Configure host DNS on primary env Configure Data Guard Tns on primary env
Enable Data Guard related Db parameters for primary env
Enable force logging and archivelog mode in primary env
Enable FlashBack
Configure network parameters for local listener on primary env
Restart listener on primary env
Create services for primary db
Finished April 11, 2023 18:05:46 PM CET ************************************************************************************ Step 6: Configure Standby database (Standby site)
Description: DG Config service for db ORCL – ConfigureStandby
Job ID: 989931fb-c7ec-4f36-9e8e-7cbe932af96c
Started April 11, 2023 18:05:47 PM CET
Configure Data Guard Tns on standby env
Configure host DNS on standby env
Clear Data Guard related Db parameters for standby env
Enable Data Guard related Db parameters for standby env
Enable force logging and archivelog mode in standby env
Populate standby database metadata
Configure network parameters for local listener on standby env
Reset Db sizing and hidden parameters for ODA best practice
Restart Listener on standby env
Create services for standby db
Finished April 11, 2023 18:07:27 PM CET ************************************************************************************
Step 7: Configure and enable Data Guard (Primary site)
Description: DG Config service for db ORCL – ConfigureDg
Job ID: 0616ad61-a6fe-4e33-b9a9-f0ea1698022f
Started April 11, 2023 18:07:28 PM CET
Config and enable Data Guard
Post check Data Guard configuration
Finished April 11, 2023 18:08:03 PM CET ************************************************************************************ Step 8: Enable Flashback (Standby site)
Description: DG Config service for db ORCL – EnableFlashback
Job ID: 1104e7ab-de51-4477-9a03-0cc37fc0431f
Started April 11, 2023 18:08:04 PM CET
Enable FlashBack
Finished April 11, 2023 18:11:55 PM CET ************************************************************************************
Step 9: Re-enable Data Guard (Primary site)
Description: DG Config service for db ORCL – ReenableDg
Job ID: 6aea76eb-e51a-4517-ae85-ba6b108804a4
Started April 11, 2023 18:11:56 PM CET
Re-enable Data Guard if inconsistent properties found
Post check Data Guard configuration
Finished April 11, 2023 18:12:53 PM CET ************************************************************************************ Step 10: Create Data Guard status (Primary site)
Description: DG Status operation for db ORCL – NewDgconfig
Job ID: df82b9d3-9a7e-4545-888f-29d678879870
Started April 11, 2023 18:12:53 PM CET
Create Data Guard status
Finished April 11, 2023 18:13:00 PM CET ************************************************************************************ Step 11: Create Data Guard status (Standby site)
Description: DG Status operation for db ORCL – NewDgconfig
Job ID: 9a70c3b8-5edb-406e-99e8-e03c44000d03
Started April 11, 2023 18:13:01 PM CET
Create Data Guard status
Finished April 11, 2023 18:13:08 PM CET ************************************************************************************ Configure Data Guard orcl_orcldr completed ************************************************************************************

 

In the interactive CLI configuration steps, the parameters are as follows:

  • The standby site address is the IP address or hostname of the standby host. Provide the fully qualified domain name and hostname if the primary and the standby systems are in the same domain and DNS is configured.
  • Select Oracle Data Guard protection modes to meet availability, performance, and data protection requirements. Oracle Data Guard Protection Modes are Maximum Availability, Maximum Performance, and Maximum Protection. The log transport modes are ASYNC, SYNC, and FASTSYNC.
  • You can select the following combinations of protection modes and transport types:
Protection Mode/
Transport Type
ASYNC FASTSYNC SYNC
MAXPERFORMANCE Y Y Y
MAXAVAILABILITY N Y Y
MAXPROTECTION N N Y

 

 

“odacli list-dataguardstatus” can help you to verify the status of the current Data Guard configuration.

 

# odacli list-dataguardstatus Updated about 2 second(s) ago ID Name Database Name
Role Protection Mode Apply Lag Transport Lag Apply Rate Status --------------------
-------------------- -------------------------------- -------------------- --------
-- ------------------ --------------- --------------- --------------- ---- be217130-633b-4eef-a4b7-3192028b853c orcl_orcldr ORCL PRIMARY MAX_PERFORMANCE 0 seconds 0 seconds 14.00 KByte/s CONFIGURED

 

The same configuration is visible from Data Guard broker:

 

DGMGRL> show configuration verbose;

 

Configuration – orcl_orcldr

 

  Protection Mode: MaxPerformance

  Members:

  ORCL     - Primary database

    ORCLDR - Physical standby database

 

  Properties:

    FastStartFailoverThreshold     = '30'

    OperationTimeout               = '30'

    TraceLevel                     = 'USER'

    FastStartFailoverLagLimit       = '30'

    CommunicationTimeout           = '180'

    ObserverReconnect               = '0'

    FastStartFailoverAutoReinstate = 'TRUE'

    FastStartFailoverPmyShutdown   = 'TRUE'

    BystandersFollowRoleChange     = 'ALL'

    ObserverOverride               = 'FALSE'

    ExternalDestination1           = ''

    ExternalDestination2           = ''

    PrimaryLostWriteAction         = 'CONTINUE'

    ConfigurationWideServiceName   = 'ORCL_CFG'

 

Fast-Start Failover: Disabled

 

Configuration Status:

SUCCESS

 

We have successfully configured a basic Data Guard environment, where most of the standby creation steps are automated using ODACLI commands only.

 

We can also perform operations as “Switchover” and “Failover” using ODACLI:

 

To Switchover, execute from any of either server:

# odacli switchover-dataguard -i <Data Guard ID> -u <Standby db name>

 

To Failover, execute from the standby server:

# odacli failover-dataguard -i <Data Guard ID> -u <Primary db name>

 

Consider some prerequisites for Oracle Data Guard Configuration on ODA 19.14+:

  • Oracle recommends running the primary and the standby databases on separate ODA hardware, so ensure that you have at least two separate ODA machines.
  • Oracle recommends that the primary and standby systems have the same ODA configuration, if possible. The databases must have a similar configuration for database shape, version, memory, networking, and storage (both must have either Oracle ASM or Oracle ACFS storage) to avoid unpredictability with the database switch roles.
  • The primary and standby systems must be the same ODA release and on ODA release 19.8 or later. The recommended version is 19.14 due to critical bug fixes.
  • If you have customized the operating system, ensure that the environments on both machines are identical.