Oracle Data Guard provides synchronous data replication to standby databases to ensure zero data loss in case of a disaster. In addition, the standby database can be used to offload RMAN backups, serve read-only and read-mostly workloads, and ensure high availability for planned maintenance.
This blog post provides the steps needed to patch Data Guard environments on Oracle Cloud with zero downtime. We define the scope of patching here as applying Release Updates (RUs), which are always RAC rolling and Standby-First installable.
Patching in Oracle Cloud
Cloud Tooling (Web Console, OCI CLI, APIs) provides automated procedures to patch your Oracle Databases. VM DB Systems are patched in-place, while Exadata Cloud Service databases are patched out-of-place by moving the database to another Oracle Home. For simplicity, we will refer to both as “patching” in this blog post.
Custom Database Software Images enables you to include one-off patches to the Release Update (RU) to apply them at once.
When you patch a standby database, the Cloud Tooling recognizes the database role and does not run datapatch. Datapatch requires the database to be open in read-write mode as it makes updates to the Data Dictionary.
We will consider different environments:
- Single instance primary and single instance standby databases.
- Oracle RAC primary and Oracle RAC standby databases.
Single Instance Databases
To ensure zero downtime, a role switch is required:
- Patch the standby database via Cloud Tooling. The Cloud Tooling recognizes the standby role, updates the Database Home (the Oracle Software binaries), but does not run datapatch.
- Initiate a switchover via Cloud Tooling. The standby with higher Database Home version becomes the primary. During switchover, applications usually encounter a brownout period of about 1-2 minutes when using Application Continuity.
- Patch the new standby via Cloud Tooling. The Cloud Tooling recognizes the standby role, updates the Database Home, but does not run datapatch. At this point, both primary and standby have the updated Database Home, but the Data Dictionary is not yet up to date. This is not an issue from the operating perspective. But bugs are not fixed and new features are not available until datapatch is run and the Data Dictionary is updated. There is no time limit to run datapatch, but you need to run it eventually.
- Run datapatch manually on the primary database. The Data Dictionary updates will be automatically replicated on the standby by the Redo Apply process.
- Optional: initiate a second switchover via Cloud Tooling to revert the roles to the initial configuration.
If you have a maintenance window anyway and can afford downtime during the patching process, then no role switches are needed:
- Patch the standby database via Cloud Tooling. The Cloud Tooling recognizes the standby role, updates the Database Home, but does not run datapatch.
- Patch the primary database via Cloud Tooling. The Cloud Tooling recognizes the primary role and runs datapatch. The Data Dictionary updates wil be automatically replicated on the standby by the Redo Apply process. While patching the primary, your database will not be available for applications.
Oracle RAC Databases
For Oracle RAC databases, there is no need for role switches to achieve zero downtime. The Database Homes are updated in a rolling manner, one node at a time, ensuring the database is available for applications through the remaining nodes. Finally, datapatch runs while the database is open in read-write mode and available for operations.
- Patch the standby database via Cloud Tooling. The Cloud Tooling will patch all nodes in a rolling manner, which still matters if you are using Active Data Guard for reporting purposes. The standby role will be recognized and no datapatch will be run.
- Patch the primary database via Cloud Tooling. The Cloud Tooling will patch all nodes in a rolling manner and eventually applies datapatch. The Data Dictionary updates wil be automatically replicated on the standby by the Redo Apply process.
Indeed, applications do not even suffer from a short brownout like with Data Guard switchover, as database services on Oracle RAC environments are instantly relocated to other nodes and continue serving application requests. Follow Oracle’s best practices for Application Continuity.
- It is recommended to run datapatch as soon as possible. However, it is not an issue to have the Database Homes with a higher version than Data Dictionary.
- For both single instance and Oracle RAC environments, ALWAYS patch the standby first. If you patch the primary first, the Cloud Tooling will run datapatch, and the Data Dictionary on the standby will get updated via the Redo Apply process, which leads to have a newer Data Dictionary than the Database Home on the standby site. You can still patch the standby afterwards, but if you encounter an outage on the primary in the meantime and need to switch over, you will run into issues and downtime until fixing the situation.
- Redo Apply is automatically disabled and re-enabled when Primary or Standby are patched.
Data Guard environments using single instance databases can be patched with zero downtime by patching the standby database first, switching over, and patching the new standby. This process requires running datapatch manually on the primary database.
Data Guard environments using Oracle RAC databases do not require a role switch to achieve zero downtime, as patches are applied in a rolling manner, one node at a time.
Keep in mind, whatever configuration you have, patch the STANDBY FIRST.
- Automate Patching and Upgrade your Cloud Databases using OCI CLI
- Using Custom Database Software Images to Create, Patch, and Upgrade your Cloud Databases
- Using OCI CLI and Custom Database Software Images to Create, Patch, and Upgrade your Exadata Cloud Databases
- How to reduce Patching Time for Oracle Databases in the Cloud
- Minimal Downtime Patching using Refreshable PDB Clones