Home / OCI

OCIRunbookAdvanced

Cross-region Data Guard for OCI Base Database: setup, switchover and failover

Create a cross-region standby for a Base Database Service DB system using the OCI-managed Data Guard association, check transport and apply lag, and perform switchover, failover and reinstate.

Deepak Bhardwaj2 min read

Applies toOCI Base Database Service (VM DB systems), Oracle Database 19c / 23ai Enterprise Edition

1. Prerequisites

  • Primary DB system in Mumbai; a remote peering path (DRG RPC) to the Hyderabad VCN.
  • Port 1521 open both ways between the database subnets (NSGs/security lists).
  • Same database edition and compatible versions; enough storage in the standby shape.

2. Create the association

Console → DB system → Database → Data Guard associations → Add standby → peer region Hyderabad, new DB system (or existing), protection mode, transport type.

Protection mode Transport Typical use
Maximum Performance ASYNC Cross-region (default, no commit latency impact)
Maximum Availability SYNC / FASTSYNC Same region or low-latency peers
oci db data-guard-association list --database-id <primary-db-ocid> --output table

3. Check lag

-- on the standby
SELECT name, value, time_computed FROM v$dataguard_stats WHERE name IN ('transport lag', 'apply lag');
SELECT process, status, sequence# FROM v$managed_standby WHERE process LIKE 'MRP%';

Or with the broker:

dgmgrl / "show configuration"
dgmgrl / "show database 'SALES_hyd'"

Alert if apply lag exceeds your RPO.

4. Switchover (planned, no data loss)

oci db data-guard-association switchover --database-id <primary-db-ocid> \
  --data-guard-association-id <dga-ocid> --database-admin-password '<sys-password>'

Roles swap; apps must reconnect to the new primary (see connection strings below).

5. Failover (disaster)

oci db data-guard-association failover --database-id <standby-db-ocid> \
  --data-guard-association-id <dga-ocid> --database-admin-password '<sys-password>'

With ASYNC transport, transactions not yet shipped are lost. When the old primary is back, reinstate it as the new standby (needs Flashback Database, enabled by default on OCI DB systems):

oci db data-guard-association reinstate --database-id <old-primary-db-ocid> \
  --data-guard-association-id <dga-ocid> --database-admin-password '<sys-password>'

6. Connection strings that follow the primary

Create a role-based service started only on the primary, and list both hosts:

(DESCRIPTION=(CONNECT_TIMEOUT=90)(RETRY_COUNT=30)(RETRY_DELAY=3)(FAILOVER=ON)
 (ADDRESS_LIST=(LOAD_BALANCE=OFF)
  (ADDRESS=(PROTOCOL=TCP)(HOST=sales-mum.db.vcn.oraclevcn.com)(PORT=1521))
  (ADDRESS=(PROTOCOL=TCP)(HOST=sales-hyd.db.vcn.oraclevcn.com)(PORT=1521)))
 (CONNECT_DATA=(SERVICE_NAME=sales_rw.db.vcn.oraclevcn.com)))
srvctl add service -db SALES_mum -service sales_rw -role PRIMARY -pdb SALESPDB

7. Use the standby

Active Data Guard (licensed option; included in EE Extreme Performance on OCI) lets you open the standby read-only for reporting and offloads backups.

Tip

Practise switchover twice a year with real application traffic. The database part usually takes minutes; finding the forgotten hard-coded hostname takes hours.