High availability and disaster recovery are critical components of any enterprise database environment. Oracle Data Guard provides robust features to ensure data protection and business continuity. In this post, we'll walk through the practical steps to perform a switchover and failover in an Oracle 19c Data Guard setup, highlighting the differences between the two and when to use each.
Switchover
A switchover is a planned role reversal between the primary and standby databases. It is done without data loss and is typically used during maintenance or upgrades.
Failover
A failover is an unplanned transition of the standby database into the primary role due to a failure or disaster affecting the original primary database and it can lead to some data loss.
After failover, the old primary can’t be used unless reinstated or recreated.
How-To Switchover
Precheck:
The most critical indicator for switchover is that the configuration reports "Ready for Switchover: Yes".
[oracle@server-graz dbs]$ dgmgrl sys/*****
DGMGRL for Linux: Release 19.0.0.0.0 - Production on Sun Jun 15 19:12:37 2025
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
Welcome to DGMGRL, type "help" for information.
Connected to "graz"
Connected as SYSDBA.
DGMGRL> show configuration;
Configuration - stbyconf
Protection Mode: MaxPerformance
Members:
graz - Primary database
salzburg - Physical standby database
Fast-Start Failover: Disabled
Configuration Status:
SUCCESS (status updated 45 seconds ago)
DGMGRL> validate network configuration for all;
Connecting to instance "graz" on database "graz" ...
Connected to "graz"
Checking connectivity from instance "graz" on database "graz to instance "salzburg" on database "salzburg"...
Succeeded.
Connecting to instance "salzburg" on database "salzburg" ...
Connected to "salzburg"
Checking connectivity from instance "salzburg" on database "salzburg to instance "graz" on database "graz"...
Succeeded.
Oracle Clusterware is not configured on database "graz".
Connecting to database "graz" using static connect identifier "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=server-graz)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=graz_DGMGRL)(INSTANCE_NAME=graz)(SERVER=DEDICATED)(STATIC_SERVICE=TRUE)))" ...
Succeeded.
The static connect identifier allows for a connection to database "graz".
Oracle Clusterware is not configured on database "salzburg".
Connecting to database "salzburg" using static connect identifier "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.56.20)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=salzburg_DGMGRL)(INSTANCE_NAME=salzburg)(SERVER=DEDICATED)(STATIC_SERVICE=TRUE)))" ...
Succeeded.
The static connect identifier allows for a connection to database "salzburg".
DGMGRL> validate database verbose salzburg;
Database Role: Physical standby database
Primary Database: graz
Ready for Switchover: Yes <<<<<IMPORTANT!!!!!!
Ready for Failover: Yes (Primary Running)
Flashback Database Status:
graz : On
salzburg: On
Capacity Information:
Database Instances Threads
graz 1 1
salzburg 1 1
Managed by Clusterware:
graz : YES
salzburg: YES
Temporary Tablespace File Information:
graz TEMP Files: 1
salzburg TEMP Files: 1
Data file Online Move in Progress:
graz: No
salzburg: No
Standby Apply-Related Information:
Apply State: Running
Apply Lag: 0 seconds (computed 1 second ago)
Apply Delay: 0 minutes
Transport-Related Information:
Transport On: Yes
Gap Status: No Gap
Transport Lag: 0 seconds (computed 1 second ago)
Transport Status: Success
Log Files Cleared:
graz Standby Redo Log Files: Cleared
salzburg Online Redo Log Files: Cleared
salzburg Standby Redo Log Files: Available
Current Log File Groups Configuration:
Thread # Online Redo Log Groups Standby Redo Log Groups Status
(graz) (salzburg)
1 3 4 Sufficient SRLs
Future Log File Groups Configuration:
Thread # Online Redo Log Groups Standby Redo Log Groups Status
(salzburg) (graz)
1 3 4 Sufficient SRLs
Current Configuration Log File Sizes:
Thread # Smallest Online Redo Smallest Standby Redo
Log File Size Log File Size
(graz) (salzburg)
1 200 MBytes 200 MBytes
Future Configuration Log File Sizes:
Thread # Smallest Online Redo Smallest Standby Redo
Log File Size Log File Size
(salzburg) (graz)
1 200 MBytes 200 MBytes
Apply-Related Property Settings:
Property graz Value salzburg Value
DelayMins 0 0
ApplyParallel AUTO AUTO
ApplyInstances 0 0
Transport-Related Property Settings:
Property graz Value salzburg Value
LogShipping ON ON
LogXptMode ASYNC ASYNC
Dependency
DelayMins 0 0
Binding optional optional
MaxFailure 0 0
ReopenSecs 300 300
NetTimeout 30 30
RedoCompression DISABLE DISABLE
DGMGRL>
How-To Switchover
DGMGRL> show configuration;
Configuration - stbyconf
Protection Mode: MaxPerformance
Members:
graz - Primary database
salzburg - Physical standby database
Fast-Start Failover: Disabled
Configuration Status:
SUCCESS (status updated 35 seconds ago)
DGMGRL> switchover to salzburg;
Performing switchover NOW, please wait...
Operation requires a connection to database "salzburg"
Connecting ...
Connected to "salzburg"
Connected as SYSDBA.
New primary database "salzburg" is opening...
Oracle Clusterware is restarting database "graz" ...
Connected to "graz"
Connected to "graz"
Switchover succeeded, new primary is "salzburg"
DGMGRL> show configuration;
Configuration - stbyconf
Protection Mode: MaxPerformance
Members:
salzburg - Primary database
graz - Physical standby database
Fast-Start Failover: Disabled
Configuration Status:
SUCCESS (status updated 52 seconds ago)
How-To Failover
Failover operations are initiated on the standby database. So, log in to the standby host and execute the failover from there.
[oracle@server-salzburg dbs]$ dgmgrl sys/******
DGMGRL for Linux: Release 19.0.0.0.0 - Production on Sun Jun 15 20:53:05 2025
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
Welcome to DGMGRL, type "help" for information.
Connected to "salzburg"
Connected as SYSDBA.
DGMGRL> show configuration;
Configuration - stbyconf
Protection Mode: MaxPerformance
Members:
graz - Primary database
salzburg - Physical standby database
Fast-Start Failover: Disabled
Configuration Status:
SUCCESS (status updated 49 seconds ago)
DGMGRL> failover to salzburg;
Performing failover NOW, please wait...
Failover succeeded, new primary is "salzburg"
DGMGRL> show configuration;
Configuration - stbyconf
Protection Mode: MaxPerformance
Members:
salzburg - Primary database
graz - Physical standby database (disabled)
ORA-16661: the standby database needs to be reinstated
Fast-Start Failover: Disabled
Configuration Status:
SUCCESS (status updated 53 seconds ago)Reinstating or Duplicating a Standby after Failover
Since a failover was performed, the DGMGRL output clearly indicates that the original primary database needs to be reinstated. This is only possible if Flashback Database was enabled prior to the failover. If flashback was not enabled, the only option is to recreate the standby by duplicating the database. After that, a switchover must be performed to restore the original configuration—Graz as the primary and Salzburg as the standby.
Execute the commands on the new primary (salzburg)
DGMGRL> show configuration;
Configuration - stbyconf
Protection Mode: MaxPerformance
Members:
salzburg - Primary database
graz - Physical standby database (disabled)
ORA-16661: the standby database needs to be reinstated
Fast-Start Failover: Disabled
Configuration Status:
SUCCESS (status updated 1 second ago)
DGMGRL> reinstate database graz;
Reinstating database "graz", please wait...
Oracle Clusterware is restarting database "graz" ...
Connected to "graz"
Connected to "graz"
Continuing to reinstate database "graz" ...
Reinstatement of database "graz" succeeded
Final check
We now have a high availability environment once again, with the only difference being that salzburg is the primary and graz is the standby. If desired, we can perform a switchover to restore the original configuration.
DGMGRL> show configuration;
Configuration - stbyconf
Protection Mode: MaxPerformance
Members:
salzburg - Primary database
graz - Physical standby database
Fast-Start Failover: Disabled
Configuration Status:
SUCCESS (status updated 45 seconds ago)
Comments
Post a Comment