Oracle Data Guard on 26ai in a Home Lab: Standby Build, Switchover, Failover and Reinstate

Alhamdulillah. With 26ai and APEX running in my home lab, the next piece was Data Guard. This post covers building a physical standby from a cloned VM, setting up the Broker, and then testing three things: a planned switchover, a failover after the primary is powered off without warning, and reinstating the old primary with Flashback. Hostnames, IP addresses and passwords are masked.

Lab environment

ItemPrimaryStandby
Hostlabhost26labhost26-sb
DB_NAME / SIDCDB26CDB26
DB_UNIQUE_NAMECDB26CDB26_SB
PDBPDB26 (with APEX 26.2)PDB26
Software26ai EE 23.26.1, Oracle Linux 9, VirtualBoxSame (full VM clone)

Results first

TestElapsedData loss
RMAN active duplicate for standby~7 min–
Switchover to standby~26 secNone
Switchover back~28 secNone
Failover after primary power-off~55 secNone
Reinstate old primary (Flashback)~39 sec–
Switchover back to original roles~40 secNone

Step 1: Clone the VM

Instead of a second software install, I shut down the primary VM, took a snapshot and made a full clone in VirtualBox. That gives the standby the same Oracle Home, the same directory layout and the same password file, so the SYS passwords already match for redo transport. Two settings matter in the clone wizard: Generate new MAC addresses for all network adapters, and Full clone.

Step 2: Give the clone its own identity

I booted the clone with the primary still off, so the copied IP could never clash. As root on the clone:

systemctl disable --now ords oracle-cdb26
hostnamectl set-hostname labhost26-sb
nmcli con mod enp0s8 ipv4.addresses <standby-ip>/24
nmcli con up enp0s8

Disabling the services copied from the primary is important. A standby that opens itself as a primary after a reboot is the last thing you want. Both hosts got each other in /etc/hosts, and the database files that came with the clone were cleared so the duplicate starts clean.

Step 3: Prepare the primary

The lab database started in NOARCHIVELOG with no force logging and no Flashback:

ALTER SYSTEM SET db_recovery_file_dest_size=20G SCOPE=BOTH;
ALTER SYSTEM SET db_recovery_file_dest='/u01/app/oracle/fra' SCOPE=BOTH;
SHUTDOWN IMMEDIATE
STARTUP MOUNT
ALTER DATABASE ARCHIVELOG;
ALTER DATABASE OPEN;
ALTER DATABASE FORCE LOGGING;
ALTER DATABASE FLASHBACK ON;
ALTER SYSTEM SET standby_file_management=AUTO SCOPE=BOTH;
ALTER SYSTEM SET log_archive_config='DG_CONFIG=(CDB26,CDB26_SB)' SCOPE=BOTH;

Flashback is the setting that pays off later. Without it, the reinstate in Step 9 would have been a full rebuild of the old primary.

Standby redo logs, one more group than the three 200 MB online groups:

ALTER DATABASE ADD STANDBY LOGFILE GROUP 11 '/u01/oradata/CDB26/srl11.log' SIZE 200M;
ALTER DATABASE ADD STANDBY LOGFILE GROUP 12 '/u01/oradata/CDB26/srl12.log' SIZE 200M;
ALTER DATABASE ADD STANDBY LOGFILE GROUP 13 '/u01/oradata/CDB26/srl13.log' SIZE 200M;
ALTER DATABASE ADD STANDBY LOGFILE GROUP 14 '/u01/oradata/CDB26/srl14.log' SIZE 200M;

Step 4: Listener and TNS

The Broker restarts instances during role changes, so each listener needs a static <db_unique_name>_DGMGRL entry. On the primary:

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = CDB26_DGMGRL)
      (ORACLE_HOME = /u01/app/oracle/product/26ai/dbhome_1)
      (SID_NAME = CDB26)))

The standby listener has two static entries, CDB26_SB (needed while the instance is only in NOMOUNT for the duplicate) and CDB26_SB_DGMGRL, both pointing to SID CDB26. In tnsnames.ora, the standby alias carries (UR = A) so RMAN can connect to the NOMOUNT auxiliary:

CDB26_SB =
  (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = labhost26-sb.localdomain)(PORT = 1521))
    (CONNECT_DATA = (SERVER = DEDICATED)(SERVICE_NAME = CDB26_SB)(UR = A)))

Step 5: RMAN active duplicate

On the standby, a minimal pfile and NOMOUNT:

db_name=CDB26
db_unique_name=CDB26_SB
enable_pluggable_database=true
sga_target=2G
STARTUP NOMOUNT PFILE='/tmp/initCDB26_SB.ora'

Then from the primary:

connect target sys/<sys_password>@CDB26
connect auxiliary sys/<sys_password>@CDB26_SB
run {
  allocate channel p1 type disk;
  allocate channel p2 type disk;
  allocate auxiliary channel s1 type disk;
  allocate auxiliary channel s2 type disk;
  duplicate target database for standby from active database
    spfile
      set db_unique_name='CDB26_SB'
      set local_listener='LISTENER_CDB26'
      set fal_server='CDB26'
      set log_archive_config='DG_CONFIG=(CDB26,CDB26_SB)'
    nofilenamecheck;
}

It finished in about 7 minutes. The only warnings were RMAN-05158 about file names, which are expected with NOFILENAMECHECK when both hosts use the same paths.

Step 6: Data Guard Broker

ALTER SYSTEM SET dg_broker_start=TRUE SCOPE=BOTH;

On both databases, then from dgmgrl on the primary:

CREATE CONFIGURATION dg_lab AS PRIMARY DATABASE IS CDB26 CONNECT IDENTIFIER IS CDB26;
ADD DATABASE CDB26_SB AS CONNECT IDENTIFIER IS CDB26_SB;
ENABLE CONFIGURATION;
SHOW CONFIGURATION;

One difference from older notes: in 26ai, adding MAINTAINED AS PHYSICAL to ADD DATABASE gave a syntax error. Without it, the standby is physical by default.

Configuration - dg_lab

  Protection Mode: MaxPerformance
  Members:
  CDB26    - Primary database
    cdb26_sb - Physical standby database

Fast-Start Failover:  Disabled

Configuration Status:
SUCCESS

VALIDATE DATABASE reported “not ready” right after enabling, while the lag still showed Unknown. A minute later it was clean, with transport and apply lag both at 0.

Step 7: Switchover and back

To follow data through the role changes, I used a small table in PDB26:

CREATE TABLE lab_apex.dg_test (created_at DATE, note VARCHAR2(12));
INSERT INTO lab_apex.dg_test VALUES (SYSDATE, 'from primary');
COMMIT;
SWITCHOVER TO CDB26_SB;

About 26 seconds. With the standby host now primary, I started ORDS there and opened the APEX sample app. I generated 100 transactions on the new primary and then switched back with SWITCHOVER TO CDB26; (about 28 seconds). On the original primary the dashboard showed 5,300 transactions, including the 100 created while the roles were reversed.

Step 8: Failover after pulling the plug

A switchover is planned and both databases take part. A failover is for when the primary is simply gone. To test that, I inserted a marker row, forced a log switch, and then used VirtualBox Power Off on the primary VM, with no shutdown at all.

ALTER SESSION SET CONTAINER = PDB26;
INSERT INTO lab_apex.dg_test VALUES (SYSDATE, 'pre-failover');
COMMIT;
ALTER SESSION SET CONTAINER = CDB$ROOT;
ALTER SYSTEM ARCHIVE LOG CURRENT;

(My first try used the note ‘before failover’ and hit ORA-12899. The column is only 12 characters.)

From dgmgrl on the standby:

  CDB26    - Primary database
    Error: ORA-16662: Network timeout when contacting a member.

DGMGRL> FAILOVER TO CDB26_SB;
2026-11-20T18:39:16  Performing failover NOW, please wait...
2026-11-20T18:40:11  Failover succeeded, new primary is "cdb26_sb".

  cdb26_sb - Primary database
    CDB26    - Physical standby database (disabled)
      ORA-16661: The standby database must be reinstated.

About 55 seconds. The new primary was already open READ WRITE with PDB26 open, and the marker row was there:

CREATED_AT         NOTE
------------------ ---------------
20-NOV-26 16:48:53 from primary
20-NOV-26 18:33:34 pre-failover

No data lost. Before bringing the old primary back, I added one more row, 'post-fail', on the new primary. That row should only reach the old host if the reinstate works.

Step 9: Reinstate the old primary

When I powered the old primary back on, its startup service ran, but the database stayed MOUNTED and still called itself PRIMARY. The Broker blocks it from opening, which prevents two primaries. From the new primary:

DGMGRL> REINSTATE DATABASE CDB26;
2026-11-20T18:46:37  Reinstating database "cdb26", please wait...
2026-11-20T18:47:16  Reinstatement of database "cdb26" succeeded

39 seconds. Flashback took CDB26 back to the failover point and converted it into a physical standby. A minute later SHOW DATABASE CDB26 showed APPLY-ON with transport and apply lag both at 0.

Step 10: Back to the original roles

DGMGRL> SWITCHOVER TO CDB26;
Performing switchover NOW, please wait...
New primary database "CDB26" is opening...
Operation requires start up of instance "CDB26" on database "cdb26_sb"
Starting instance "CDB26"...
Database mounted.
Switchover succeeded, new primary is "cdb26"

Straight after, SHOW CONFIGURATION reported ORA-16810 for the standby. That was only the standby instance coming back up; after a minute it returned to SUCCESS. The final check on the original primary:

CREATED_AT         NOTE
------------------ ---------------
20-NOV-26 16:48:53 from primary
20-NOV-26 18:33:34 pre-failover
20-NOV-26 18:42:31 post-fail

The row written during the outage is on the original primary, so the reinstated database caught up correctly.

Was anything automatic?

No. Fast-Start Failover was disabled, so each role change was a command I ran. The only automatic part was the Broker keeping the failed primary mounted. With Fast-Start Failover and an observer, the Broker would detect the dead primary and fail over by itself. That is the next thing to try in this lab.

Lessons learned

  • A full VM clone with new MAC addresses is a quick way to get a matching standby host. Boot it alone first and change the hostname and IP.
  • Disable the database and ORDS auto-start services on the standby.
  • Static _DGMGRL listener entries are needed for the Broker to restart instances during role changes.
  • (UR = A) in the standby TNS alias lets RMAN connect to a NOMOUNT instance.
  • Enable Flashback on both sides before you need it. It turned the reinstate into a 39-second step.
  • In 26ai, leave out MAINTAINED AS PHYSICAL in ADD DATABASE.
  • Snapshot both VMs together after each milestone. With Data Guard, restoring only one side breaks the pair.

ما شاء الله, the lab now has a 26ai primary and physical standby that have been through planned and unplanned role changes without losing a row. A full step-by-step PDF with screenshots is shared on my LinkedIn.


Discover more from Syed Anwar Ahmed – Oracle DBA Blog

Subscribe to get the latest posts sent to your email.

Comments

Leave a Reply

Discover more from Syed Anwar Ahmed – Oracle DBA Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading