Oracle Database Administration Training series – Day 13
Patching and Upgrading Oracle Database
Patching and upgrading an Oracle Database are essential activities for maintaining a secure, stable,
and high-performing database environment. Here’s a detailed breakdown of both processes with
practical scenarios.
1. Patching Oracle Database
Oracle provides regular patches to fix bugs, address security vulnerabilities, and enhance database
features. These patches are applied using tools like opatch and opatchauto.
Types of Patches
1. One-off Patches: Target specific issues.
2. Patch Set Updates (PSUs): Includes critical fixes and security updates.
3. Release Updates (RUs): Includes functional enhancements, fixes, and security patches.
4. Release Update Revisions (RURs): Address regressions in previous RUs.
5. Critical Patch Updates (CPUs): Quarterly updates focusing on security vulnerabilities.
Patching Using OPatch
OPatch is a command-line utility used to apply one-off patches or bundle patches.
1. Pre-requisites:
o Ensure the database software is compatible with the patch.
o Download the patch from Oracle Support.
o Check the OPatch version compatibility:
$ $ORACLE_HOME/OPatch/opatch version
2. Steps to Apply a Patch:
o Stop the Database Services:
$ srvctl stop database -d <DB_NAME>
o Validate Patch Compatibility:
$ $ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -
phBaseDir <PATCH_DIR>
o Apply the Patch:
$ $ORACLE_HOME/OPatch/opatch apply
o Verify Patch Application:
1
$ $ORACLE_HOME/OPatch/opatch lsinventory
o Restart the Database Services:
$ srvctl start database -d <DB_NAME>
Patching Using OPatchAuto
OPatchAuto automates the patching of Oracle Grid Infrastructure (GI) and databases.
1. Pre-requisites:
o Ensure root user permissions.
o Download the GI patch.
2. Steps to Apply a Patch:
o Run opatchauto as root:
$ $ORACLE_HOME/OPatch/opatchauto apply /path/to/patch
Scenario: Patching a MODIAirline Booking System
• Problem: Airline customers report slower response times during ticket booking.
• Root Cause: A known Oracle bug causing suboptimal query performance.
• Solution:
o Download and apply a one-off patch addressing the bug using opatch.
o Validate that the issue is resolved by running performance tests post-patching.
2. Upgrading Oracle Database
Upgrading involves transitioning to a newer database version to leverage new features and improve
performance.
Upgrade Paths
• Direct upgrades are supported from:
o 12c (12.1.0.2, 12.2.0.1) to 19c.
o Older versions require an intermediate upgrade.
Steps to Upgrade Oracle Database (12c to 19c)
1. Pre-upgrade Steps:
o Check Compatibility: Use the Database Pre-Upgrade Tool:
2
$ORACLE_HOME/jdk/bin/java -jar preupgrd.jar
o Backup the Database: Perform a full RMAN backup:
RMAN> BACKUP DATABASE PLUS ARCHIVELOG;
o Gather Statistics:
EXEC DBMS_STATS.GATHER_DICTIONARY_STATS;
o Disable Invalid Objects: Resolve invalid objects using utlrp.sql.
2. Perform the Upgrade:
o Install 19c Software: Install the Oracle 19c binaries in a new Oracle Home directory.
o Run DBUA (Database Upgrade Assistant):
$ORACLE_HOME/bin/dbua
Follow the GUI prompts to upgrade the database.
o Manually Upgrade Using Command Line:
STARTUP UPGRADE;
@?/rdbms/admin/catctl.pl -n 4 -d . catupgrd.sql
3. Post-upgrade Steps:
o Recompile Objects:
@$ORACLE_HOME/rdbms/admin/utlrp.sql
o Update Compatibility:
ALTER SYSTEM SET COMPATIBLE = '19.0.0';
o Test the Database: Validate using application-specific queries and performance
benchmarks.
Scenario: Upgrading MODI Airline Ticketing System
• Problem: An airline's booking system uses Oracle 12c, which is nearing the end of support.
• Solution:
o Upgrade the database to 19c to ensure continued support, better security, and
improved query performance.
o Perform the upgrade during a planned maintenance window to minimize
disruptions.
3
Real-Time Challenges and Solutions
1. Challenge: Network Interruption During Patch Download
Solution: Use a secure and reliable download method, and verify the checksum of the
downloaded patch.
2. Challenge: Patch Conflicts
Solution: Use OPatch conflict check and resolve conflicts by consulting Oracle Support.
3. Challenge: Slow Performance After Upgrade
Solution:
o Gather statistics using DBMS_STATS.
o Use AWR to identify slow queries and resolve them with SQL Tuning Advisor.
4. Challenge: Incompatibility Issues with Applications
Solution:
o Test the application in a staging environment before applying patches or upgrades.
o Address compatibility issues by updating application code if necessary.
Best Practices
1. For Patching:
o Always test patches in a non-production environment.
o Schedule patches during low-traffic periods.
o Maintain backups before patching.
2. For Upgrading:
o Use a staging environment to validate application behavior on the upgraded
database.
o Keep detailed rollback plans in case the upgrade fails.
o Document the process for audit and compliance purposes.
By following these detailed steps and addressing potential challenges, you can ensure a smooth
patching or upgrading process for Oracle Databases.