How do you patch Oracle Grid Infrastructure 19c (GI) when Oracle Data Guard protects your Oracle Database?
I had a talk with Ludovico Caldara, the product manager for Oracle Data Guard, about it:
To provide more details, I will use the following setup as an example:
- Data Guard setup with two databases.
- Each database is a 2-node RAC database.
- Sites are called copenhagen and aarhus.
Patching Oracle Grid Infrastructure Only
- Prepare new GI homes on all nodes in both sites (copenhagen and aarhus).
- Disable Fast-Start Failover (FSFO) for the reasons described below. You can leave the observer running.
- Start with the standby site, aarhus.
- Complete the patching process by switching to the new GI home in a rolling manner on all nodes at aarhus site.
- If you use Active Data Guard and have read-only sessions in your standby database, you should ensure that instances are properly drained before restarting the GI stack (via
root.sh
). - Proceed with the primary site, copenhagen.
- Complete the patching process by switching to the new GI home in a rolling manner on all nodes at copenhagen site.
- Be sure to handle draining properly to ensure there are no interuptions.
- Re-enable FSFO.
Later, when you want to patch the database, you can follow up the standby-first method described in Oracle Patch Assurance – Data Guard Standby-First Patch Apply (Doc ID 1265700.1). If the database patches you install are RAC Rolling Installable (like Release Updates), you should choose option 1 in phase 3 to avoid any downtime or brownout.
Alternative Approach
If you have many nodes in your cluster and an application that doesn’t behave well during draining, consider switching over to the standby site instead of patching the primary site in a rolling manner. When you switch over, there is only one interruption, whereas many interruptions in a rolling patch apply.
- Patch standby site, aarhus.
- Switch over to aarhus.
- Patch former primary, copenhagen.
What If You Want to Patch the Database At the Same Time?
Out-of-place SwitchGridHome
You get complete control over the process with Out-of-place SwitchGridHome. It is my preferred method. There are more commands to execute, but it doesn’t matter if you automate it.
Here is an overview of the process. You can use many of the commands from this blog post:
- Prepare new GI homes using
gridSetup
. Be sure to apply the needed patches. Do it on one node in both primary (copenhagen) and standby site (aarhus). The process will copy the new GI home to all other nodes in the cluster. Do not executeroot.sh
. - Prepare new database homes. Be sure to apply the needed patches. Here is an example. Do it on one node in both primary (copenhagen) and standby site (aarhus). The process will copy the new database home to all other nodes in the cluster. Remember to execute
root.sh
. - Disable FSFO.
- Start with the standby site, aarhus.
- Configure the standby database to start in the new database home:
$ $OLD_ORACLE_HOME/bin/srvctl modify database \ -db $STDBY_ORACLE_UNQNAME \ -oraclehome $NEW_ORACLE_HOME
- If you use Active Data Guard and have read-only sessions connected, drain the instance.
- Switch to the new GI home using
gridSetup.sh -switchGridHome ...
androot.sh
.root.sh
restarts the entire GI stack. When it restarts the database, the database instance runs in the new database home.- Repeat the process on all nodes in the standby site (aarhus).
- Proceed with the primary site, copenhagen.
- Configure the primary database to start in the new database home:
$ $OLD_ORACLE_HOME/bin/srvctl modify database \ -db $PRMY_ORACLE_UNQNAME \ -oraclehome $NEW_ORACLE_HOME
- Be sure to drain the instance.
- Switch to the new GI home using
gridSetup.sh -switchGridHome ...
androot.sh
.root.sh
restarts the entire GI stack. When it restarts the database, the database instance runs in the new database home.- Repeat the process on all nodes in the primary site (copenhagen).
- Execute
datapatch -verbose
on one of the primary database instances to finish the patch apply. - Re-enable FSFO.
Out-of-place OPatchAuto
Out-of-place OPatchAuto is a convenient way of patching because it also automates the database operations. However, I still recommend using Out-of-place SwitchGridHome method because it gives you more control over draining.
Here is an overview of the process:
- Deploy new GI and database homes using
opatchauto apply ... -prepare-clone
. Do it on all nodes in both primary (copenhagen) and standby site (aarhus). Since you want to patch GI and database homes, you should omit the-oh
parameter. - Disable FSFO.
- Start with the standby site, aarhus.
- Complete patching of all nodes in the standby site (aarhus) using
opatchauto apply -switch-clone
.- When OPatchAuto completes the switch on a node, it takes down the entire GI stack on that node, including database instance.
- GI restarts using the new GI home. But the database instance still run on the old database home.
- On the last node, after the GI stack has been restarted, all database instances restart again to switch to the new database home. This means that each database instance will restart two times.
- Proceed with the primary site, copenhagen.
- Complete patching of all nodes in the primary site (copenhagen) using
opatchauto apply -switch-clone
.- The procedure is the same as on the standby site.
- In addition, OPatchAuto executes Datapatch to complete the database patching.
- Re-enable FSFO.
Fast-Start Failover
When you perform maintenance operations, like patching, consider what to do about Fast-Start Failover (FSFO).
If you have one standby database
- Single instance standby I recommend disabling FSFO. If something happens to the primary database while you are patching the standby site, you don’t want to switch over or fail over automatically. Since the standby site is being patched, the standby database might restart shortly. You should evaluate the situation and determine what to do rather than relying on FSFO handling it.
- RAC standby I recommend disabling FSFO for the same reasons as above. Now, you could argue that the standby database is up all the time if you perform rolling patching. That’s correct, but nodes are being restarted as part of the patching process, and services are being relocated. Having sessions switching over or failing over while you are in the middle of a rolling patch apply is a little delicate situation. Technically, it works; the Oracle stack can handle it. But I prefer to evaluate the situation before switching or failing over. Unless you have a super-cool application that can transparently handle it.
Nevertheless, leaving FSFO enabled when you patch GI or a database is fully supported.
If you have more standby databases
I recommend keeping FSFO enabled if you have multiple standby databases.
When you patch one standby database, you can set FastStartFailoverTarget
to the other standby database. When patching completes, you can set FastStartFailoverTarget
to the first standby database and continue patching the second standby database. This keeps your primary database protected at all times.
The Easy Way
As shown above, you can patch Oracle Grid Infrastructure even when you have Oracle Data Guard configured. But why not take the easy way and use Oracle Fleet Patching and Provisioning (FPP)?
FPP automatically detects the presence of Data Guard and executes the commands in the appropriate order, including invoking Datapatch when needed.
If you need to know more, you can reach out to Philippe Fierens, product manager for FPP. He is always willing to get you started.
Happy Patching
Appendix
Other Blog Posts in This Series
- Introduction
- How to Patch Oracle Grid Infrastructure 19c Using In-Place OPatchAuto
- How to Patch Oracle Grid Infrastructure 19c Using Out-Of-Place OPatchAuto
- How to Patch Oracle Grid Infrastructure 19c Using Out-Of-Place SwitchGridHome
- How to Patch Oracle Grid Infrastructure 19c and Oracle Data Guard Using Standby-First
- How to Patch Oracle Grid Infrastructure 19c Using Zero Downtime Oracle Grid Infrastructure Patching
- Which Method Should I Choose When Patching Oracle Grid Infrastructure 19c
- How to Avoid Interruptions When You Patch Oracle Grid Infrastructure 19c
- Patching Oracle Grid Infrastructure And Oracle Data Guard
- Use Cluster Verification Utility (cluvfy) and Avoid Surprises
- A Word about Zero Downtime Oracle Grid Infrastructure Patching
- Why You Need to Use Oracle Fleet Patching and Provisioning
- My Best Advice on Patching Oracle Grid Infrastructure
- Pro Tips