Zero Data Loss Over Long Distances: Adding a Data Guard Far Sync Instance in a Multicloud Configuration
Zero data loss with Data Guard means synchronous redo transport: a commit on the primary waits until the standby has received the redo. When the standby is in another cloud and another region, that wait is a network round trip of 10, 20 or more milliseconds, added to every commit. Most applications cannot afford it, so they settle for asynchronous transport and accept that a disaster can lose the last few seconds of transactions.
A Far Sync instance removes the trade-off. It is a small Oracle instance with no data files, placed close to the primary. The primary ships redo to it synchronously, over a short link, and the far sync instance forwards the redo to the distant standby asynchronously. If the primary is lost, the far sync instance still holds every committed transaction and passes it on during failover.
The Use Case
The primary runs on OCI in Frankfurt, and the disaster recovery standby runs on Azure in another region. Today redo transport is asynchronous, and the business wants zero data loss for a regional disaster without slowing the order-entry application. A far sync instance on a small VM in a second OCI availability domain, close to the primary, receives redo synchronously.
Environment used in this runbook
Primary: SALES_OCI, Oracle Database 19c (19.24) on an OCI VM in Frankfurt, availability domain 1
Far sync: SALES_FS, a far sync instance on a small OCI VM in Frankfurt, availability domain 2, same 19c home
Standby: SALES_AZURE, physical standby on an Azure VM in another region
Broker: Data Guard broker configuration sales_dg, currently MaxPerformance with ASYNC transport
Licence: Far Sync is a feature of the Active Data Guard option, an extra-cost licence for Enterprise Edition
How a Far Sync Instance Works
No data files. A far sync instance has a control file, standby redo logs and archived logs only. It never opens and never applies redo, so it needs little CPU, memory or storage.
Synchronous hop. The primary sends redo to the far sync instance with SYNC transport. Because they are close together, the commit wait is a fraction of a millisecond to a millisecond or two.
Asynchronous hop. The far sync instance forwards the redo to the standby with ASYNC transport, so the long link never delays a commit.
Zero data loss on failover. If the primary fails, the broker makes the standby collect the remaining redo from the far sync instance before it becomes primary.
Step 1: Measure the Round Trips
Start by proving the problem with numbers: the round trip from the primary to the standby, and to the host chosen for the far sync instance. tnsping reports the time for an Oracle Net round trip to each listener.
Shell |
# On the primary host, as oracle tnsping SALES_AZURE 5 | tail -5 tnsping SALES_FS 5 | tail -5 |
Expected output |
OK (24 msec)
OK (23 msec)
OK (25 msec)
OK (24 msec)
OK (23 msec)
OK (1 msec)
OK (0 msec)
OK (1 msec)
OK (1 msec)
OK (0 msec)What to expect: About 24 ms to the standby in Azure and under 1 ms to the far sync host in the next availability domain. Synchronous transport straight to Azure would add roughly 24 ms to every commit; through the far sync instance it adds about a millisecond. tnsping includes some overhead, so treat the numbers as an upper bound.
Step 2: Check the Current Configuration and the Standby Redo Logs
Far sync needs standby redo logs both on the far sync instance and on the standby. Check the broker configuration, then the standby redo logs on the standby: one more group per thread than the online redo log groups, each the same size as the online logs.
Shell |
dgmgrl / "show configuration" |
SQL |
-- On the standby SALES_AZURE SELECT thread#, COUNT(*) AS groups, MAX(bytes)/1024/1024 AS size_mb FROM v$standby_log GROUP BY thread#; |
Expected output |
THREAD# GROUPS SIZE_MB
---------- ---------- ----------
1 5 4096What to expect: A healthy configuration with two members, and five standby redo log groups of 4 GB on the standby for four online groups on the primary. If the standby has none, add them before going further (ALTER DATABASE ADD STANDBY LOGFILE THREAD 1 SIZE 4G), otherwise the standby cannot receive the forwarded redo in real time.
Step 3: Create the Far Sync Control File on the Primary
A far sync instance uses a special control file, created on the primary. Copy it to the far sync host together with the password file, which must be identical on every member of the configuration.
SQL |
-- On the primary SALES_OCI ALTER DATABASE CREATE FAR SYNC INSTANCE CONTROLFILE AS '/u01/stage/sales_fs.ctl'; |
Shell |
# Copy the control file and the password file to the far sync host scp /u01/stage/sales_fs.ctl oracle@sales-fs-1:/u02/oradata/SALES_FS/control01.ctl scp $ORACLE_HOME/dbs/orapwSALES oracle@sales-fs-1:$ORACLE_HOME/dbs/orapwSALES_FS |
What this does: The new control file describes the same database (same DBID and name) but marks it as a far sync instance. The password file copy lets redo transport authenticate in both directions. If the primary's password file is in ASM, extract it first with asmcmd pwcopy.
Step 4: Start the Far Sync Instance
On the far sync host, write a small parameter file, start the instance in mount mode, and add standby redo logs to it. The far sync instance needs the same number and size of standby redo logs as the standby.
Shell |
cat > $ORACLE_HOME/dbs/initSALES_FS.ora <<'EOF' db_name=SALES db_unique_name=SALES_FS control_files='/u02/oradata/SALES_FS/control01.ctl' db_recovery_file_dest='/u03/fra' db_recovery_file_dest_size=200G dg_broker_start=TRUE remote_login_passwordfile=EXCLUSIVE compatible='19.0.0' EOF
export ORACLE_SID=SALES_FS sqlplus -s / as sysdba <<'EOF' STARTUP MOUNT ALTER DATABASE ADD STANDBY LOGFILE THREAD 1 SIZE 4G; ALTER DATABASE ADD STANDBY LOGFILE THREAD 1 SIZE 4G; ALTER DATABASE ADD STANDBY LOGFILE THREAD 1 SIZE 4G; ALTER DATABASE ADD STANDBY LOGFILE THREAD 1 SIZE 4G; ALTER DATABASE ADD STANDBY LOGFILE THREAD 1 SIZE 4G; SELECT db_unique_name, database_role, open_mode FROM v$database; EOF |
Expected output |
ORACLE instance started.
Database mounted.
Database altered.
Database altered.
Database altered.
Database altered.
Database altered.
DB_UNIQUE_NAME DATABASE_ROLE OPEN_MODE
------------------------------ ---------------- --------------------
SALES_FS FAR SYNC MOUNTEDWhat to expect: The instance mounts with the role FAR SYNC. It never goes beyond MOUNTED. Register a static service for it in the listener (or use Grid Infrastructure on the far sync host), so the broker can restart it, and add a SALES_FS entry to tnsnames.ora on all three hosts.
Step 5: Add the Far Sync Instance to the Broker
Now tell the broker about the new member. Adding it does not change any redo routes yet, so nothing changes for the primary at this point.
Shell |
dgmgrl sys@SALES_OCI <<'EOF' ADD FAR_SYNC 'SALES_FS' AS CONNECT IDENTIFIER IS SALES_FS; SHOW FAR_SYNC 'SALES_FS'; EOF |
Expected output |
far sync instance "SALES_FS" added
Far Sync Instance - SALES_FS
Transport Lag: (unknown)
Instance(s):
SALES_FS
Far Sync Instance Status:
DISABLEDWhat to expect: The far sync instance is part of the configuration but DISABLED. The broker asks for the SYS password when it connects; it uses it to reach every member.
Step 6: Define the Redo Routes
RedoRoutes tells each member where to send redo, and how. The primary sends to the far sync instance synchronously; the far sync instance forwards to the Azure standby asynchronously. Add a fallback so that, if the far sync instance is down, the primary still ships to the standby directly.
Shell |
dgmgrl sys@SALES_OCI <<'EOF' EDIT DATABASE 'SALES_OCI' SET PROPERTY RedoRoutes = '(LOCAL : SALES_FS SYNC, (SALES_AZURE ASYNC FALLBACK))'; EDIT FAR_SYNC 'SALES_FS' SET PROPERTY RedoRoutes = '(SALES_OCI : SALES_AZURE ASYNC)'; ENABLE FAR_SYNC 'SALES_FS'; EOF |
Expected output |
Property "redoroutes" updated
Property "redoroutes" updated
Enabled.What this does: The first route is read "when SALES_OCI is primary (LOCAL), send redo to SALES_FS synchronously, and only if that is not possible, to SALES_AZURE asynchronously". The second route is read "on SALES_FS, redo coming from SALES_OCI goes to SALES_AZURE asynchronously". Enabling the far sync instance makes the primary start shipping to it.
Step 7: Raise the Protection Mode
With a synchronous destination in place, switch the configuration to Maximum Availability. In this mode the primary waits for the far sync instance to acknowledge each commit's redo, but keeps running if the far sync instance becomes unreachable.
Shell |
dgmgrl sys@SALES_OCI <<'EOF' EDIT CONFIGURATION SET PROTECTION MODE AS MaxAvailability; SHOW CONFIGURATION; EOF |
Expected output |
Succeeded.
Configuration - sales_dg
Protection Mode: MaxAvailability
Members:
SALES_OCI - Primary database
SALES_FS - Far sync instance
SALES_AZURE - Physical standby database
Fast-Start Failover: Disabled
Configuration Status:
SUCCESS (status updated 14 seconds ago)What to expect: MaxAvailability, and the members shown as a chain: the primary, then the far sync instance, then the standby behind it. If the status shows a warning such as ORA-16855 (transport lag), give it a minute and check again; the first redo is still being shipped.
Step 8: Verify the Transport on Each Hop
Check from the primary that the destination to the far sync instance is synchronous, and from the far sync instance that it forwards to the standby.
SQL |
-- On the primary COLUMN db_unique_name FORMAT A14
SELECT dest_id, db_unique_name, status, transmit_mode, affirm FROM v$archive_dest WHERE target = 'STANDBY' AND status <> 'INACTIVE'; |
Expected output |
DEST_ID DB_UNIQUE_NAME STATUS TRANSMIT_MOD AFF
---------- -------------- --------- ------------ ---
2 SALES_FS VALID PARALLELSYNC YESWhat to expect: One active standby destination, SALES_FS, with synchronous transport (PARALLELSYNC is what 19c shows for SYNC) and AFFIRM. The fallback destination to SALES_AZURE stays inactive until it is needed. Run the same query on the far sync instance: it shows SALES_AZURE as VALID with ASYNCHRONOUS transport.
Step 9: Measure the Effect on Commits
The point of the far sync instance is zero data loss without slow commits. Compare the commit wait before and after with the wait events that measure it: log file sync for the session's view, and SYNC Remote Write for the network part.
SQL |
-- On the primary, average waits since startup COLUMN event FORMAT A24
SELECT event, total_waits, ROUND(time_waited_micro / NULLIF(total_waits, 0) / 1000, 2) AS avg_ms FROM v$system_event WHERE event IN ('log file sync', 'SYNC Remote Write', 'log file parallel write') ORDER BY event; |
Expected output |
EVENT TOTAL_WAITS AVG_MS
------------------------ ----------- ----------
SYNC Remote Write 841206 0.71
log file parallel write 862114 0.42
log file sync 790553 1.38What to expect: The remote write to the far sync instance averages well under a millisecond, and log file sync (what users wait for at commit) stays around 1 to 2 ms. Synchronous transport straight to Azure would have put SYNC Remote Write near the 24 ms round trip measured in Step 1. Use AWR reports for before-and-after comparisons over the same workload, because these averages accumulate from instance startup.
Tip: The far sync instance is now in the commit path. Monitor it like a production database: alert on the instance being down, on its fast recovery area filling, and on its transport lag to the standby.
Step 10: Plan for the Reverse Direction
After a switchover to Azure, redo must flow back to OCI. Decide now how that works, and record it in RedoRoutes before you need it. The simplest choice is asynchronous transport from Azure straight to OCI; for zero data loss in both directions, add a second far sync instance near the standby.
Shell |
dgmgrl sys@SALES_OCI <<'EOF' EDIT DATABASE 'SALES_AZURE' SET PROPERTY RedoRoutes = '(LOCAL : SALES_OCI ASYNC)'; VALIDATE DATABASE 'SALES_AZURE'; EOF |
Expected output |
Property "redoroutes" updated
Database Role: Physical standby database
Primary Database: SALES_OCI
Ready for Switchover: Yes
Ready for Failover: Yes (Primary Running)What this does: When SALES_AZURE is primary, it sends redo directly and asynchronously to SALES_OCI. VALIDATE DATABASE confirms the standby is ready for a switchover and a failover. Test a switchover and switch back in a maintenance window before you rely on the configuration.
Summary
A far sync instance gives zero data loss to a distant standby without paying the long round trip on every commit. Measure the round trips, make sure the standby has standby redo logs, create the far sync control file on the primary, and start a mounted, file-less instance close to the primary with its own standby redo logs. Add it to the broker, route redo synchronously to it and asynchronously on to the standby, with a direct fallback, then raise the protection mode to MaxAvailability. Verify each hop and the commit wait events, and define the reverse routes before your first switchover. Remember that Far Sync is part of the Active Data Guard licence.
Comments