Oracle Data Guard to OCI: Build a Standby in the Cloud and Switch Over
Updated: Oct 24
A Data Guard migration is the least dramatic way to move an Oracle database into the cloud: you build a standby in OCI, let it catch up, and switch over in a window measured in minutes. The old primary becomes your standby, so the way back is a second switchover. This is the procedure for a self-managed 19c Enterprise Edition database moving from an on-premises Linux server to an OCI Base Database Service system.
Before you start
Same major version and the same Release Update on both sides, Enterprise Edition, and the same platform family (Linux x86-64 at both ends here).
Network: FastConnect or a site-to-site VPN, port 1521 open in both directions, and host names resolvable on both ends.
Create the target database through the OCI console first, with the same DB name and character set. A database the console created is one the OCI control plane manages for backups and patching; a database that appears on the VM by itself is not.
Oracle Zero Downtime Migration automates everything below for exactly this case. The manual steps are worth knowing because they are what ZDM does, and what you fall back on when it cannot run.
Step 1: prepare the primary
SQL |
-- Force logging and archivelog are prerequisites for a physical standby ALTER DATABASE FORCE LOGGING; SELECT log_mode, force_logging FROM v$database;
-- Standby redo logs: one more group than online redo logs, same size, per thread ALTER DATABASE ADD STANDBY LOGFILE THREAD 1 GROUP 11 SIZE 1G; ALTER DATABASE ADD STANDBY LOGFILE THREAD 1 GROUP 12 SIZE 1G; ALTER DATABASE ADD STANDBY LOGFILE THREAD 1 GROUP 13 SIZE 1G; ALTER DATABASE ADD STANDBY LOGFILE THREAD 1 GROUP 14 SIZE 1G;
-- Redo transport to OCI ALTER SYSTEM SET log_archive_config = 'DG_CONFIG=(prod_onprem,prod_oci)'; ALTER SYSTEM SET log_archive_dest_2 = 'SERVICE=prod_oci ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=prod_oci'; ALTER SYSTEM SET log_archive_dest_state_2 = 'ENABLE'; ALTER SYSTEM SET fal_server = 'prod_oci'; ALTER SYSTEM SET standby_file_management = 'AUTO'; |
Add TNS entries for prod_onprem and prod_oci on both servers, copy the password file from the primary to the OCI host, and add a static listener entry for the standby so the broker and RMAN can connect while it is mounted.
Step 2: duplicate the database into OCI
On the OCI host, start the target instance in NOMOUNT with a minimal parameter file (db_name, db_unique_name = prod_oci, memory and file-name conversion parameters), then run the duplicate from the on-premises side over the network.
RMAN |
rman TARGET sys/password@prod_onprem AUXILIARY sys/password@prod_oci
RUN { ALLOCATE CHANNEL p1 DEVICE TYPE DISK; ALLOCATE CHANNEL p2 DEVICE TYPE DISK; ALLOCATE AUXILIARY CHANNEL a1 DEVICE TYPE DISK; ALLOCATE AUXILIARY CHANNEL a2 DEVICE TYPE DISK; DUPLICATE TARGET DATABASE FOR STANDBY FROM ACTIVE DATABASE DORECOVER SPFILE SET db_unique_name = 'prod_oci' SET fal_server = 'prod_onprem' SET log_archive_config = 'DG_CONFIG=(prod_onprem,prod_oci)' SET log_archive_dest_2 = 'SERVICE=prod_onprem ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=prod_onprem' SET db_create_file_dest = '+DATA' SET db_recovery_file_dest = '+RECO' NOFILENAMECHECK; } |
Duplicate time is governed by the size of the database and the bandwidth of the link. Large databases are often seeded from a backup copied to OCI Object Storage instead of over the wire; the end state is the same.
Step 3: put the broker in charge
SQL |
-- On both databases ALTER SYSTEM SET dg_broker_start = TRUE;
-- From DGMGRL, connected to the primary CREATE CONFIGURATION dg_oci AS PRIMARY DATABASE IS prod_onprem CONNECT IDENTIFIER IS prod_onprem; ADD DATABASE prod_oci AS CONNECT IDENTIFIER IS prod_oci MAINTAINED AS PHYSICAL; ENABLE CONFIGURATION; SHOW CONFIGURATION; SHOW DATABASE prod_oci; -- Transport Lag and Apply Lag should settle at 0 seconds |
Leave it running for a few days. Watch the apply lag under real load and let the standby prove that the link and the OCI storage keep up before you book the window.
Step 4: rehearse the application against OCI
Convert the standby to a snapshot standby, point a test copy of the application at it, and run the critical transactions. The standby keeps receiving redo while you test; converting it back discards the test changes and resumes apply.
SQL |
CONVERT DATABASE prod_oci TO SNAPSHOT STANDBY; -- run the application tests against prod_oci CONVERT DATABASE prod_oci TO PHYSICAL STANDBY; VALIDATE DATABASE prod_oci; -- look for Ready for Switchover: Yes |
Step 5: switch over
SQL |
-- In the window, with the application stopped SWITCHOVER TO prod_oci; SHOW CONFIGURATION; |
The command drains the last redo, converts the primary to a standby, and opens prod_oci as the new primary. The outage is the switchover itself, typically a minute or two, plus the application restart. Repoint connection strings, or better, update the TNS and service definitions you prepared earlier and let the application reconnect.
After the switchover
The on-premises database is now a standby receiving redo from OCI. Keep it until sign-off; it is your fallback, and afterwards it can stay as a disaster-recovery site or be decommissioned.
Register the new primary with the OCI backup service and confirm the first backup completes.
Reconfigure anything host-specific: scheduler jobs with OS paths, directory objects, external tables, database links.
Re-measure performance against the baseline you took on premises before anyone concludes the cloud is slower.
The same move on other clouds
This procedure is identical for a self-managed Oracle database on a virtual machine in AWS, Azure or Google Cloud, and for the Exadata-based services under Oracle Database@Azure and Oracle Database@Google Cloud, where Zero Downtime Migration is again the tool of choice. It does not apply to Amazon RDS for Oracle: RDS manages its own replicas and does not let you add an RDS instance as a standby of an on-premises primary, so a move into RDS is a Data Pump or GoldenGate job.
Soro Consulting plans and runs Data Guard migrations into OCI, AWS, Azure and Google Cloud. Book a consultation to talk it through.
Comments