Automating Database Role Transitions in a Manual Data Guard with OCI Full Stack DR
Introduction
When you create any of the supported DR plans using OCI Full Stack DR, OCI Full Stack DR provides built-in modules for the Oracle Database PaaS listed below, as long as Data Guard was set up using the Cloud automation available from those services.
Oracle Base DB
Oracle Exadata DB on dedicated infrastructure
Customers might use Oracle Base DB or Oracle Exadata DB on dedicated infrastructure with manual data configuration for various use cases, such as multiple standbys or Fast-Start Failover (FSFO).Customers sometimes run Oracle Database in OCI Standard Compute VMs with Data Guard. To integrate these types of Oracle Databases with Full Stack DR, you can customize the DR plans with user-defined plan groups and manage database role changes using scripts or OCI functions.
In this blog, I will show you how to use Full Stack DR to automate role changes for databases where Data Guard is manually configured on a Base DB system.
Architecture
For simplicity, all the resources used in this blog are in the same region across two Availability Domains in the Ashburn region. This should also work for cross-region Data Guard. I have used the Base DB system for Oracle DB. Ideally, as part of Full Stack DR plans, you will have recovery steps for Compute, Storage, Database, Applications, etc. This blog covers only the Oracle DB recovery steps.
Availability Domain 1:
Base DB System: adghol-qtv-iad (DB Unique name) ( Primary DB)
Compute VM: oel8-1 (VM to host scripts)
Availability Domain 2:
Base DB System : adghol-3px-iad (DB Unique name) (Standby DB)
Compute VM: oel8-2 (VM to host scripts)
Regional:
- DR Protection Group (DRPG) : DB-AD1 and DB-AD2
Pre-requisites:
Oracle Data Guard has been manually set up between the two Base DB systems. Ensure the databases have the correct roles. For additional details, refer to Oracle Data Guard documentation.
We will use oel8-1 and oel8-2 for running the scripts. Make sure to prepare the VMs to use the run command feature. For more details, refer Full Stack DR run command.
Install the Oracle Client on both VMs, oel8-1 and oel8-2. This will help connect to the database through TNS. Update the necessary security lists to allow the VMs to connect to the database.
Create scripts for performing the DB role reversal using DGMGRL commands. I have placed the
"changedbrole.sh"
script in the /home/opc/dbscripts folder on both VMs.Example: For Switchover from AD1 to AD2, run
/home/opc/dbscripts/changedbrole.sh switchover adghol_qtv_iad adghol_3px_iad
You can use any script, as long as you can handle the DB role changes.
- Ensure the script works correctly for operations like switchover, failover, converting to snapshot standby, and converting to physical standby.
Integration with Full Stack DR
Create DRPG's DB-AD1 and DB-AD2 in the Ashburn region. Assign DB-AD1 as the Primary role and DB-AD2 as the Standby role.
Add "oel8-1" to DB-AD1 (DRPG) as a non-moving member and "oel8-2" to DB-AD2 (DRPG) as a non-moving member. Since we have configured Data Guard manually, there is no need to add Oracle Database as a member.
Create DR plans in DB-AD2 DRPG. Full Stack DR lets you create a Stop drill plan only after completing the Start drill. Initially, you won't see all four plan types, but I created the Stop drill plan once the Start drill plan was done.
Customize the DR plans with user-defined plan groups using the
"changedbrole.sh"
script. Here, I have added a user-defined plan group for the switchover plan with the script details.
Similarly, I added the necessary user-defined plan groups for the respective plans.
DR Plan type | DR plans | Script |
Switchover | DB Switchover-AD1-AD2 | /home/opc/dbscripts/changedbrole.sh switchover adghol_qtv_iad adghol_3px_iad |
Failover | DB Failover-AD1-AD2 | /home/opc/dbscripts/changedbrole.sh failover adghol_qtv_iad adghol_3px_iad |
Start drill | DB StartDrill (Snapshot Standby)-AD1-AD2 | /home/opc/dbscripts/changedbrole.sh convert_to_snapshot adghol_qtv_iad adghol_3px_iad |
Stop drill | DB StopDrill ( Physical Standby)-AD1-AD2 | /home/opc/dbscripts/changedbrole.sh convert_to_physical adghol_qtv_iad adghol_3px_iad |
- Test all the DR plans and verify their successful execution.
If you execute a failover plan, you need to reinstate the failed primary database (
adghol_qtv_iad
) as soon as it becomes available. This must be done outside of the Full Stack DR plan.
Similarly, I have created all four types of DR plans in the other DB-AD1 (DRPG). Full Stack DR allows creating plans in the DRPG with a Standby role, so make sure to create the plans accordingly.
-
Customize the DR plans with user-defined plan groups using the
dbrolechange.sh
script. Here, I have added a user-defined plan group for the switchover plan with the script details.Similarly, I have added the necessary user-defined plan groups for each respective plan.
DR Plan type | DR plans | Script |
Switchover | DB Switchover-AD2-AD1 | /home/opc/dbscripts/changedbrole.sh switchover adghol_3px_iad adghol_qtv_iad |
Failover | DB Failover-AD2-AD1 | /home/opc/dbscripts/changedbrole.sh failover adghol_3px_iad adghol_qtv_iad |
Start drill | DB StartDrill (Snapshot Standby)-AD2-AD1 | /home/opc/dbscripts/changedbrole.sh convert_to_snapshot adghol_3px_iad adghol_qtv_iad |
Stop drill | DB StopDrill ( Physical Standby)-AD2-AD1 | /home/opc/dbscripts/changedbrole.sh convert_to_physical adghol_3px_iad adghol_qtv_iad |
- Test all the DR plans and verify their successful execution.
If you execute a failover plan, you need to reinstate the failed primary database (
adghol_3px_iad
) as soon as it becomes available. This must be done outside of the Full Stack DR plan.
- Considering you now have all four plan types available in both DB-AD1 and DB-AD2 DRPGs, the plans will become active or inactive depending on the DRPG role. The Primary DRPG will have plans in an inactive state, while the Standby DRPG will have plans in an active state.
Drill plans will become active during the drill plan execution.
Conclusion:
In conclusion, we have learned how to automate Oracle Database roles with Full Stack DR for Oracle Databases using manual Data Guard configuration. This can greatly improve the efficiency and reliability of your disaster recovery plans. By following the outlined steps, you can easily integrate manually configured Data Guard setups into Full Stack DR, ensuring smooth role transitions and strong protection for your Oracle databases and your Full Stack.
Additional Resources:
Subscribe to my newsletter
Read articles from Suraj Ramesh directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Suraj Ramesh
Suraj Ramesh
I work as a Product Manager at Oracle. I am a member of the Oracle Database High Availability (HA), Scalability & Maximum Availability Architecture (MAA) Product Management team in Oracle. The team is part of the product development of the core database technologies. I focus on Oracle Cloud Infrastructure Full Stack Disaster Recovery and Oracle Database Online Redefinition. My interests are Databases, Cloud Infrastructure, Cloud Automation, and Disaster Recovery.