A Step-by-Step Guide to Create and Enable Oracle Data Guard Far Sync

Introduction

After introducing Far Sync instances and discussing their benefits in previous blog posts, this blog post provides a step-by-step guide to building a Far Sync instance and adding it to an existing Data Guard configuration. Parameters and directory paths used here are examples to make the setup easy to understand. Choose appropriate parameters and directory structures for your production system following Oracle’s documentation.

The Data Guard broker supports Far Sync instance creation starting with Oracle Database version 21c.

The Environment

  • Primary database Ashburn_ad1 running on Oracle Cloud in the Ashburn region in Availability Domain 1.
  • Standby database London_ad1 running on Oracle Cloud in the London region.
  • A virtual machine in Ashburn region in Availability Domain 2 to host the Far Sync instance.

The current Data Guard configuration is as follows:

[oracle@hostiad ~]$ dgmgrl SYS as sysdba
DGMGRL> show configuration

Configuration - Ashburn_ad1_London_ad1

  Protection Mode: MaxPerformance
  Members:
  Ashburn_ad1    - Primary database
    London_ad1     - Physical standby database

Fast-Start Failover:  Disabled

Configuration Status:
SUCCESS   (status updated 57 seconds ago)

Far Sync Instance Creation

Step 1: Create a control file

Create a control file for the Far Sync instance from the primary database:

[oracle@hostiad ~]$ sqlplus / as sysdba
SQL> alter database create far sync instance controlfile as '/home/oracle/controlfs.ctl';

Database altered.

Copy the newly created control file to the Far Sync instance host:

## add the Far Sync instance host information to /etc/hosts of the primary system
10.20.0.85 hostfs.subnetpublic.vcniad.oraclevcn.com hostfs

## copy the control file to the Far Sync instance host
[oracle@hostiad ~]$ scp -p /home/oracle/controlfs.ctl oracle@hostfs:/u02/fs1/
controlfs.ctl                     100%   18MB 408.4MB/s   00:00

Step 2: Copy the Password File

Copy the password file of the primary database to the Far Sync instance host using the name of the Far Sync instance “orapwFS1′:

[oracle@hostiad ~]$ scp -p /u01/app/oracle/product/19.0.0/dbhome_1/dbs/orapwAshburn oracle@hostfs:/u01/app/oracle/product/19.0.0/dbhome_1/dbs/orapwFS1
orapwAshburn                     100% 2048     2.8MB/s   00:00

Step 3: Create a Parameter File

Create a parameter file for the Far Sync instance from the primary database and copy it to the Far Sync instance host:

[oracle@hostiad ~]$ sqlplus / as sysdba
SQL> create pfile='/home/oracle/init_fs.ora' from spfile;
File created.

## copy the control file to the Far Sync instance host
[oracle@hostiad ~]$ scp -p /home/oracle/init_fs.ora oracle@hostfs:/u02/fs1/
init_fs.ora                     100% 2374     3.0MB/s   00:00

Adjust the parameters to reflect your parameter values and directory paths for the Far Sync instance. Alternatively, you can start with a new parameter file on the Far Sync instance host, e.g.:

## create the directory structure
[oracle@hostfs fs1]$
mkdir /u02/fs1/audit/
mkdir /u02/fs1/coredump/
mkdir /u02/fs1/dg_broker/
mkdir /u02/fs1/diag/
mkdir /u02/fs1/fra/

## vi /u02/fs1/init_fs.ora
*.db_name='ASHBURN'
*.db_unique_name='FS1'
*.compatible='19.0.0'
*.control_files='/u02/fs1/controlfs.ctl'
*.diagnostic_dest='/u02/fs1/diag/'
*.core_dump_dest='/u02/fs1/coredump/'
*.audit_file_dest='/u02/fs1/audit/'
*.audit_trail='DB'
*.db_recovery_file_dest='/u02/fs1/fra/'
*.db_recovery_file_dest_size=250g
*.dg_broker_config_file1='/u02/fs1/dg_broker/fs1_01.dat'
*.dg_broker_config_file2='/u02/fs1/dg_broker/fs1_02.dat'
*.dg_broker_start=TRUE
*.dispatchers='(PROTOCOL=TCP) (SERVICE=FS1XDB)'
*.standby_file_management='AUTO'

Start the Far Sync instance using the created pfile, create an spfile in Oracle Home, and restart the Far Sync instance in MOUNT mode:

[oracle@hostfs fs1]$ export ORACLE_HOME=/u01/app/oracle/product/19.0.0/dbhome_1/
[oracle@hostfs fs1]$ export ORACLE_SID=FS1
[oracle@hostfs fs1]$ sqlplus / as sysdba
Connected to an idle instance.
SQL> startup pfile='/u02/fs1/init_fs.ora' nomount;
ORACLE instance started.

SQL> create spfile='/u01/app/oracle/product/19.0.0/dbhome_1/dbs/spfileFS1.ora' from pfile='/u02/fs1/init_fs.ora';
File created.

SQL> shutdown immediate;
ORA-01507: database not mounted
ORACLE instance shut down.

SQL> startup mount;
ORACLE instance started.
Database mounted.

SQL> select name, db_unique_name, database_role, open_mode from v$database;
NAME      DB_UNIQUE_NAME                 DATABASE_ROLE    OPEN_MODE
--------- ------------------------------ ---------------- --------------------
ASHBURN   FS1                            FAR SYNC         MOUNTED

Step 4: Create a Database Listener

On the Far Sync instance host, create and start a database listener, e.g.:

[oracle@hostfs fs1]$ vi $ORACLE_HOME/network/admin/listener.ora
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = hostfs.subnetpublic.vcniad.oraclevcn.com)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

[oracle@hostfs fs1]$ lsnrctl start
[oracle@hostfs fs1]$ lsnrctl services
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=hostfs.subnetpublic.vcniad.oraclevcn.com)(PORT=1521)))
Services Summary...
Service "FS1" has 1 instance(s).
  Instance "FS1", status READY, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:1 refused:0 state:ready
         LOCAL SERVER
The command completed successfully

Far Sync Instance Configuration

Step 5: Add Primary and Standby TNS Entries to Far Sync Host

On the Far Sync instance host, add the TNS connection strings of the primary and standby databases to the tnsnames.ora file:

[oracle@hostfs ~]$ vi $ORACLE_HOME/network/admin/tnsnames.ora

ASHBURN_AD1=(DESCRIPTION=(SDU=65535)(SEND_BUF_SIZE=10485760)(RECV_BUF_SIZE=10485760)(ADDRESS=(PROTOCOL=TCP)(HOST=10.10.0.13)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=Ashburn_ad1.subnetpublic.vcnaid.oraclevcn.com)))

LONDON_AD1=(DESCRIPTION=(SDU=65535)(SEND_BUF_SIZE=10485760)(RECV_BUF_SIZE=10485760)(ADDRESS=(PROTOCOL=TCP)(HOST=10.20.0.81)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=London_ad1.subnetpublic.vcnlhr.oraclevcn.com)))

Step 6: Add Far Sync TNS Entry to Primary Host

On the primary host, add the Far Sync instance TNS connection string into the tnsname.ora:

[oracle@hostiad ~]$ vi $ORACLE_HOME/network/admin/tnsnames.ora

FS1 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = hostfs)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = FS1)
    )
  )

## test
[oracle@hostiad ~]$ sqlplus SYS@FS1 as sysdba
SQL> show parameter db_unique_name
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_unique_name                       string      FS1

Step 7: Add the Far Sync Instance to Data Guard Configuration

Use the Data Guard broker to add the Far Sync instance to the existing Data Guard configuration while connected to the primary database:

[oracle@hostiad ~]$ dgmgrl SYS as sysdba
DGMGRL> ADD FAR_SYNC FS1 AS CONNECT IDENTIFIER IS FS1;
far sync instance "fs1" added

DGMGRL> ENABLE FAR_SYNC FS1;
Enabled.

DGMGRL> show configuration

Configuration - Ashburn_ad1_London_ad1

  Protection Mode: MaxAvailability
  Members:
  Ashburn_ad1    - Primary database
    London_ad1     - Physical standby database
    fs1            - Far sync instance
      Warning: ORA-16789: standby redo logs configured incorrectly

Fast-Start Failover:  Disabled

Configuration Status:
WARNING   (status updated 11 seconds ago)

Step 8: Edit the Data Guard Configuration

Use the Data Guard broker’s RedoRoutes property to configure the primary database to transport the redo to the Far Sync instance in FastSync mode and the Far Sync instance to forward the redo to the standby database in ASYNC mode:

[oracle@hostiad ~]$ dgmgrl SYS as sysdba

DGMGRL> EDIT DATABASE 'Ashburn_ad1' SET PROPERTY RedoRoutes = '( LOCAL : ( FS1 FASTSYNC PRIORITY=1, London_ad1 ASYNC PRIORITY=2 ))';
Property "redoroutes" updated

DGMGRL> EDIT FAR_SYNC 'FS1' SET PROPERTY RedoRoutes = '( Ashburn_ad1 : London_ad1 ASYNC )';
Property "redoroutes" updated

DGMGRL> EDIT DATABASE 'London_ad1' SET PROPERTY RedoRoutes = '( LOCAL : Ashburn_ad1 ASYNC )';
Property "redoroutes" updated

The database log_archive_dest_n parameters for the primary, standby, and the Far Sync instance are now set accordingly. Check the parameters and compare them to the example in the documentation.

Step 9: Change the Protection Mode

Increase the protection mode of the Data Guard configuration to Maximum Availability:

DGMGRL> EDIT CONFIGURATION SET PROTECTION MODE AS MAXAVAILABILITY;
Succeeded.

Step 10: Check the configuration

Check the configuration again:

DGMGRL> show configuration

Configuration - Ashburn_ad1_London_ad1

  Protection Mode: MaxAvailability
  Members:
  Ashburn_ad1    - Primary database
    fs1            - Far sync instance
      London_ad1     - Physical standby database

Fast-Start Failover:  Disabled

Configuration Status:
SUCCESS   (status updated 57 seconds ago)

Query the roles on primary, standby, and the Far Sync instance:

SQL> select DB_UNIQUE_NAME, DEST_ROLE from V$DATAGUARD_CONFIG;

DB_UNIQUE_NAME                 DEST_ROLE
------------------------------ -----------------
London_ad1                     PHYSICAL STANDBY
Ashburn_ad1                    PRIMARY DATABASE
fs1                            FAR SYNC INSTANCE

Query the standby logs status on the Far Sync instance:

SQL> select group#,thread#,bytes,status from v$standby_log;

    GROUP#    THREAD#      BYTES STATUS
---------- ---------- ---------- ----------
         4          1 1073741824 UNASSIGNED
         5          1 1073741824 ACTIVE
         6          1 1073741824 UNASSIGNED
         7          1 1073741824 UNASSIGNED

Considerations

  • Create a further Far Sync instance in the remote region to ensure zero data loss without impact on application performance after role switches as described in this blog post.
  • Building Far Sync instances is not yet supported via Cloud Tooling in OCI. Consider building your Data Guard environment manually.
  • The Far Sync feature requires the Active Data Guard option license.

Conclusion

Creating a Far Sync instance is straightforward and can be done via the Data Guard broker starting from Oracle Database version 21c. Far Sync is a very lightweight instance. However, disk performance is critical as the Far Sync instance writes the received redo to disk before acknowledging back to the primary, which impacts the application performance.

Further Reading

Would you like to get notified when the next post is published?