Goal
You have to apply the quarterly patches to an OCI Base Database VM DB system with as little downtime as possible and a clean way back if something fails. The service manages the patching: you choose a patch, run a precheck, then apply it. The order matters and so does preparation, because a failed apply leaves you with an outage and a support request.
This runbook uses the OCI CLI so the steps can be scripted and logged. The same actions are available in the Console under the DB system's and database's Updates pages.
Order of operations
- Back up the database and confirm the backup succeeded.
- Precheck and apply the DB system patch, which updates Grid Infrastructure (Oracle Clusterware/ASM).
- Precheck and apply the database patch, which updates the Oracle home of each database.
- With Data Guard, patch the standby first, then the primary.
The Grid Infrastructure version must be the same as or higher than the database version you patch to, so DB system patching always comes first.
Warning
On a single-node VM DB system, both the DB system patch and the database patch restart the database, so you get downtime. On a 2-node RAC DB system, patches apply one node at a time (rolling), so services stay up only if the application connects through the SCAN with a service that runs on both nodes. Schedule a window either way.
Preparation
Set variables and check state
export DBS_ID=ocid1.dbsystem.oc1..example
export COMP_ID=ocid1.compartment.oc1..example
oci db system get --db-system-id "$DBS_ID" \
--query 'data.{state:"lifecycle-state",version:version,shape:shape,nodes:"node-count"}' --output table
oci db database list --compartment-id "$COMP_ID" --db-system-id "$DBS_ID" \
--query 'data[].{name:"db-name",id:id,state:"lifecycle-state"}' --output table
The DB system and the database must be AVAILABLE. Take note of the database OCID and export it as DB_ID.
Confirm network access to Object Storage
The patching tooling downloads patch bits from Oracle-managed Object Storage. A DB system in a private subnet needs a route to a service gateway with the "All services in Oracle Services Network" CIDR label (or a NAT gateway). Without one, prechecks fail with download or connectivity errors. Check the subnet's route table:
SUBNET_ID=$(oci db system get --db-system-id "$DBS_ID" --query 'data."subnet-id"' --raw-output)
RT_ID=$(oci network subnet get --subnet-id "$SUBNET_ID" --query 'data."route-table-id"' --raw-output)
oci network route-table get --rt-id "$RT_ID" --query 'data."route-rules"' --output table
Take a fresh backup
oci db backup create --database-id "$DB_ID" --display-name "pre-patch-$(date +%F)" \
--wait-for-state ACTIVE --wait-for-state FAILED
Don't continue unless the backup reaches ACTIVE. If automatic backups have been failing, fix that first (see the Base Database backup troubleshooting checklist).
Check host space
On each node, check free space where the patch tooling stages files and where the Oracle homes live:
df -h / /u01 /tmp
Low space on /u01 is a common precheck failure. Clean old trace files and diagnostic logs (adrci purge) before you start, not during the window.
Step 1: Patch the DB system (Grid Infrastructure)
List the patches available for the DB system:
oci db patch list by-db-system --db-system-id "$DBS_ID" --all \
--query 'data[].{id:id,version:version,desc:description,released:"time-released",actions:"available-actions",last:"last-action"}' \
--output table
Pick the version you plan to run (usually the latest release update you've already tested in non-production). Run the precheck:
export DBS_PATCH_ID=ocid1.dbpatch.oc1..example
oci db system patch --db-system-id "$DBS_ID" \
--patch-id "$DBS_PATCH_ID" --patch-action PRECHECK
The DB system goes to UPDATING while the precheck runs. Poll until it returns to AVAILABLE, then read the result from the patch history:
oci db system get --db-system-id "$DBS_ID" --query 'data."lifecycle-state"' --raw-output
oci db patch-history list by-db-system --db-system-id "$DBS_ID" \
--query 'data[].{patch:"patch-id",action:action,state:"lifecycle-state",details:"lifecycle-details",started:"time-started",ended:"time-ended"}' \
--output table
A precheck doesn't change the system and doesn't affect availability. Only apply once the latest PRECHECK entry shows SUCCEEDED:
oci db system patch --db-system-id "$DBS_ID" \
--patch-id "$DBS_PATCH_ID" --patch-action APPLY
Track it the same way. On 2-node RAC, check that both nodes and their instances come back before moving on:
oci db node list --compartment-id "$COMP_ID" --db-system-id "$DBS_ID" \
--query 'data[].{host:hostname,state:"lifecycle-state"}' --output table
Step 2: Patch the database
oci db patch list by-database --database-id "$DB_ID" --all \
--query 'data[].{id:id,version:version,desc:description,actions:"available-actions"}' --output table
export DB_PATCH_ID=ocid1.dbpatch.oc1..example
oci db database patch --database-id "$DB_ID" \
--patch-id "$DB_PATCH_ID" --patch-action PRECHECK
Check the result:
oci db patch-history list by-database --database-id "$DB_ID" \
--query 'data[].{action:action,state:"lifecycle-state",details:"lifecycle-details",ended:"time-ended"}' \
--output table
Then apply:
oci db database patch --database-id "$DB_ID" \
--patch-id "$DB_PATCH_ID" --patch-action APPLY
The apply also runs datapatch, which loads the SQL changes into the database. Confirm it on the database afterwards:
SELECT patch_id, action, status, description, action_time
FROM dba_registry_sqlpatch
ORDER BY action_time DESC
FETCH FIRST 5 ROWS ONLY;
SELECT comp_id, version_full, status FROM dba_registry WHERE status <> 'VALID';
The first query should show the new release update with STATUS = SUCCESS. The second should return no rows. If it lists components, recompile with @?/rdbms/admin/utlrp.sql and check again.
Alternative: move the database to a new DB home
Instead of patching an existing home in place, you can create a new database home at the target version (or from a custom database software image) and move the database to it. This is the cleaner choice when you carry one-off patches, or when you want to keep the old home for a fast fallback. Check your Console's Move to another home option and the CLI help for your version before you script it.
Data Guard
- Patch the standby DB system and database first, then the primary. Redo transport keeps working while the versions differ.
- Check apply lag on the standby after each step before you touch the primary.
- If you need the primary to stay open throughout, patch the standby, switch over, patch the old primary (now the standby), then switch back if you want the original roles.
When a precheck or apply fails
| Symptom | Likely cause | Fix |
|---|---|---|
| Precheck fails quickly with a download or connectivity error | No route to Object Storage | Add a service gateway route (All services CIDR label) or NAT gateway |
| Precheck fails on space | /u01 or / too full | Purge traces/logs, then run the precheck again |
| Database patch not listed | DB system (GI) still on an older version | Patch the DB system first |
Apply fails, DB system shows FAILED or NEEDS_ATTENTION | Error during the patch steps on the host | Read the lifecycle details and host logs, then open a support request before retrying |
Patch succeeded but dba_registry_sqlpatch shows no entry | datapatch didn't complete | Check the datapatch logs under $ORACLE_BASE/cfgtoollogs/sqlpatch and run it per Oracle Support guidance |
On the host, VM DB systems run the DCS agent, which records each patch job. Names vary by version; check your system:
sudo -s
dbcli list-jobs | tail -20
dbcli describe-job -i <job-id>
less /opt/oracle/dcs/log/dcs-agent.log
Caution
Don't apply OPatch patches by hand to a home the service manages unless Oracle Support tells you to. The service loses track of the home's version, and later patching through the Console or CLI can fail.
Prevent it next time
- Patch non-production one cycle ahead, and keep a record of the exact patch OCIDs and versions that passed.
- Run prechecks a few days before the window, so space and network problems surface while there's time to fix them.
- Alarm on failed automatic backups so the pre-patch backup is never the first one in weeks.
- Script the steps above with
--queryoutput written to a change log. That log gives you evidence for change records and a starting point if you have to call Oracle Support.
Get the weekly HubDatAI email
One email a week with everything new: posts, learning sessions and videos. Free, no spam, unsubscribe in one click. What you get