Oracle Database 19c RU Patching Step-by-Step Guide
Oracle databases require regular patching to ensure optimal performance and security. In this guide, we will walk through the patching process for an Oracle 19c database using the OPatch utility.
1. Downloading and Transferring Patch Files
The first step in patching is to download the required patches from Oracle Support. We are going to apply patch 19.25, and once the patch is downloaded, you can use the secure copy (SCP) command to transfer the patch files from your local machine to the Oracle server
scp -pr ./p6880880_190000_Linux-x86-64.zip ./p36912597_190000_Linux-x86-64.zip root@discovery:/u02/patch/
2. Set Permissions for the Patch Directory
Once the patch files are copied to the server, change the ownership and permissions for the patch directory so that the Oracle user can access them.
[root@discovery u02]# chown -R oracle:oinstall patch/
[root@discovery u02]# chmod -R 775 patch/
3. Verify OPatch Version
Login as the Oracle user and verify the current version of Opatch utility.
[root@discovery u02]# su - oracle
[oracle@discovery ~]$ cd /u01/app/oracle/product/19.0.0/dbhome_1/OPatch/
[oracle@discovery OPatch]$ ./opatch version
[oracle@discovery OPatch]$ ./opatch version
OPatch Version: 12.2.0.1.17
OPatch succeeded.
4.Upgrade OPatch Directory
Download the latest Opatch p6880880_190000_Linux-x86-64.zip, Before upgrade opatch directory, it’s recommended to backup the current OPatch directory.
[oracle@discovery dbhome_1]$ mv OPatch OPatch_bkp
This will create a backup of the existing OPatch directory. Next, unzip the opatch files into the Oracle home directory.
[oracle@discovery patch]$ unzip p6880880_190000_Linux-x86-64.zip -d /u01/app/oracle/product/19.0.0/dbhome_1/
After unzipping the opatch, verify the opatch version.
cd /u01/app/oracle/product/19.0.0/dbhome_1/OPatch
[oracle@discovery OPatch]$ ./opatch version
OPatch Version: 12.2.0.1.44
OPatch succeeded.
5.Unzip the Patch
Similarly, unzip the patch file:
[oracle@discovery patch]$ unzip p36912597_190000_Linux-x86-64.zip
6.Shutdown the Database:
Shutdown the database. This can be done using the following command:
sqlplus / as sysdba
shutdown immediate;
Once the database has successfully shut down, exit sqlplus.
Backup Oracle Home and oraInventory:
Backup the ORACLE_HOME and oraInventory directories using the tar command. Below are the commands:
cd /u01/app/oracle/product/19.0.0
[oracle@discovery 19.0.0]$ tar -pcvf /u02/backup_dbhome_1.tar dbhome_1
[oracle@discovery u02]$ cd /u01/app/
[oracle@discovery app]$ tar -pcvf /u02/backup_oraInventory.tar oraInventory
This creates backups of the Oracle home and inventory, ensuring that you can restore the environment if anything goes wrong.
7.Prerequisite Check: CheckConflictAgainstOHWithDetail
This check verifies if the patch you’re applying conflicts with the current Oracle Home. It essentially checks whether there are any conflicting patches
[oracle@discovery ~]$ /u01/app/oracle/product/19.0.0/dbhome_1/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /u02/patch/36912597
Oracle Interim Patch Installer version 12.2.0.1.44
Copyright (c) 2024, Oracle Corporation. All rights reserved.
PREREQ session
Oracle Home : /u01/app/oracle/product/19.0.0/dbhome_1
Central Inventory : /u01/app/oraInventory
from : /u01/app/oracle/product/19.0.0/dbhome_1/oraInst.loc
OPatch version : 12.2.0.1.44
OUI version : 12.2.0.7.0
Log file location : /u01/app/oracle/product/19.0.0/dbhome_1/cfgtoollogs/opatch/opatch2024-11-16_12-32-39PM_1.log
Invoking prereq "checkconflictagainstohwithdetail"
Prereq "checkConflictAgainstOHWithDetail" passed.
OPatch succeeded.
Prerequisite Check: CheckActiveFilesAndExecutables
This check verifies if there are any active files or executables that may prevent the patch from being applied. It checks for processes or files in use by the Oracle instance that need to be stopped before applying the patch.
[oracle@discovery ~]$ /u01/app/oracle/product/19.0.0/dbhome_1/OPatch/opatch prereq CheckActiveFilesAndExecutables -phBaseDir /u02/patch/36912597
Oracle Interim Patch Installer version 12.2.0.1.44
Copyright (c) 2024, Oracle Corporation. All rights reserved.
PREREQ session
Oracle Home : /u01/app/oracle/product/19.0.0/dbhome_1
Central Inventory : /u01/app/oraInventory
from : /u01/app/oracle/product/19.0.0/dbhome_1/oraInst.loc
OPatch version : 12.2.0.1.44
OUI version : 12.2.0.7.0
Log file location : /u01/app/oracle/product/19.0.0/dbhome_1/cfgtoollogs/opatch/opatch2024-11-18_08-53-07AM_1.log
Invoking prereq "checkactivefilesandexecutables"
Prereq "checkActiveFilesAndExecutables" for patch 36912597 passed.
OPatch succeeded.
8.Apply the Patch Using OPatch Utility
Once the precheck is successfully completed without any errors, proceed with applying the patch using the OPatch utility.
[oracle@discovery ~]$ /u01/app/oracle/product/19.0.0/dbhome_1/OPatch/opatch apply -oh /u01/app/oracle/product/19.0.0/dbhome_1 -silent -local /u02/patch/36912597
- The -oh flag specifies the Oracle Home directory.
- The -silent flag ensures that the process runs without user interaction.
- The -local flag applies the patch locally on the system.
Patching output: Applying a patch using the OPatch utility on an Oracle Database
[oracle@discovery ~]$ /u01/app/oracle/product/19.0.0/dbhome_1/OPatch/opatch apply -oh /u01/app/oracle/product/19.0.0/dbhome_1 -silent -local /u02/patch/36912597
Oracle Interim Patch Installer version 12.2.0.1.44
Copyright (c) 2024, Oracle Corporation. All rights reserved.
Oracle Home : /u01/app/oracle/product/19.0.0/dbhome_1
Central Inventory : /u01/app/oraInventory
from : /u01/app/oracle/product/19.0.0/dbhome_1/oraInst.loc
OPatch version : 12.2.0.1.44
OUI version : 12.2.0.7.0
Log file location : /u01/app/oracle/product/19.0.0/dbhome_1/cfgtoollogs/opatch/opatch2024-11-18_08-55-38AM_1.log
Verifying environment and performing prerequisite checks...
--------------------------------------------------------------------------------
Start OOP by Prereq process.
Launch OOP...
Oracle Interim Patch Installer version 12.2.0.1.44
Copyright (c) 2024, Oracle Corporation. All rights reserved.
Oracle Home : /u01/app/oracle/product/19.0.0/dbhome_1
Central Inventory : /u01/app/oraInventory
from : /u01/app/oracle/product/19.0.0/dbhome_1/oraInst.loc
OPatch version : 12.2.0.1.44
OUI version : 12.2.0.7.0
Log file location : /u01/app/oracle/product/19.0.0/dbhome_1/cfgtoollogs/opatch/opatch2024-11-18_08-56-15AM_1.log
Verifying environment and performing prerequisite checks...
OPatch continues with these patches: 36912597
Do you want to proceed? [y|n]
Y (auto-answered by -silent)
User Responded with: Y
All checks passed.
Please shutdown Oracle instances running out of this ORACLE_HOME on the local system.
(Oracle Home = '/u01/app/oracle/product/19.0.0/dbhome_1')
Is the local system ready for patching? [y|n]
Y (auto-answered by -silent)
User Responded with: Y
Backing up files...
Applying interim patch '36912597' to OH '/u01/app/oracle/product/19.0.0/dbhome_1'
ApplySession: Optional component(s) [ oracle.network.gsm, 19.0.0.0.0 ] , [ oracle.crypto.rsf, 19.0.0.0.0 ] , [ oracle.pg4appc, 19.0.0.0.0 ] , [ oracle.pg4mq, 19.0.0.0.0 ] , [ oracle.precomp.companion, 19.0.0.0.0 ] , [ oracle.rdbms.ic, 19.0.0.0.0 ] , [ oracle.rdbms.tg4db2, 19.0.0.0.0 ] , [ oracle.tfa, 19.0.0.0.0 ] , [ oracle.sdo.companion, 19.0.0.0.0 ] , [ oracle.net.cman, 19.0.0.0.0 ] , [ oracle.oid.client, 19.0.0.0.0 ] , [ oracle.xdk.companion, 19.0.0.0.0 ] , [ oracle.options.olap.api, 19.0.0.0.0 ] , [ oracle.ons.eons.bwcompat, 19.0.0.0.0 ] , [ oracle.rdbms.tg4msql, 19.0.0.0.0 ] , [ oracle.network.cman, 19.0.0.0.0 ] , [ oracle.rdbms.tg4tera, 19.0.0.0.0 ] , [ oracle.rdbms.tg4ifmx, 19.0.0.0.0 ] , [ oracle.rdbms.tg4sybs, 19.0.0.0.0 ] , [ oracle.ldap.ztk, 19.0.0.0.0 ] , [ oracle.ons.cclient, 19.0.0.0.0 ] , [ oracle.options.olap, 19.0.0.0.0 ] , [ oracle.jdk, 1.8.0.191.0 ] , [ oracle.jdk, 1.8.0.391.11 ] not present in the Oracle Home or a higher version is found.
Patching component oracle.rdbms, 19.0.0.0.0...
Patching component oracle.rdbms.util, 19.0.0.0.0...
Patching component oracle.rdbms.rsf, 19.0.0.0.0...
Patching component oracle.assistants.acf, 19.0.0.0.0...
Patching component oracle.assistants.deconfig, 19.0.0.0.0...
Patching component oracle.assistants.server, 19.0.0.0.0...
Patching component oracle.blaslapack, 19.0.0.0.0...
Patching component oracle.buildtools.rsf, 19.0.0.0.0...
Patching component oracle.ctx, 19.0.0.0.0...
Patching component oracle.dbdev, 19.0.0.0.0...
Patching component oracle.dbjava.ic, 19.0.0.0.0...
Patching component oracle.dbjava.jdbc, 19.0.0.0.0...
Patching component oracle.dbjava.ucp, 19.0.0.0.0...
Patching component oracle.duma, 19.0.0.0.0...
Patching component oracle.javavm.client, 19.0.0.0.0...
Patching component oracle.ldap.owm, 19.0.0.0.0...
Patching component oracle.ldap.rsf, 19.0.0.0.0...
Patching component oracle.ldap.security.osdt, 19.0.0.0.0...
Patching component oracle.marvel, 19.0.0.0.0...
Patching component oracle.network.rsf, 19.0.0.0.0...
Patching component oracle.odbc.ic, 19.0.0.0.0...
Patching component oracle.ons, 19.0.0.0.0...
Patching component oracle.ons.ic, 19.0.0.0.0...
Patching component oracle.oracore.rsf, 19.0.0.0.0...
Patching component oracle.perlint, 5.28.1.0.0...
Patching component oracle.precomp.common.core, 19.0.0.0.0...
Patching component oracle.precomp.rsf, 19.0.0.0.0...
Patching component oracle.rdbms.crs, 19.0.0.0.0...
Patching component oracle.rdbms.dbscripts, 19.0.0.0.0...
Patching component oracle.rdbms.deconfig, 19.0.0.0.0...
Patching component oracle.rdbms.oci, 19.0.0.0.0...
Patching component oracle.rdbms.rsf.ic, 19.0.0.0.0...
Patching component oracle.rdbms.scheduler, 19.0.0.0.0...
Patching component oracle.rhp.db, 19.0.0.0.0...
Patching component oracle.rsf, 19.0.0.0.0...
Patching component oracle.sdo, 19.0.0.0.0...
Patching component oracle.sdo.locator.jrf, 19.0.0.0.0...
Patching component oracle.sqlplus, 19.0.0.0.0...
Patching component oracle.sqlplus.ic, 19.0.0.0.0...
Patching component oracle.wwg.plsql, 19.0.0.0.0...
Patching component oracle.xdk.rsf, 19.0.0.0.0...
Patching component oracle.javavm.server, 19.0.0.0.0...
Patching component oracle.xdk.xquery, 19.0.0.0.0...
Patching component oracle.ctx.rsf, 19.0.0.0.0...
Patching component oracle.ovm, 19.0.0.0.0...
Patching component oracle.oraolap, 19.0.0.0.0...
Patching component oracle.nlsrtl.rsf.lbuilder, 19.0.0.0.0...
Patching component oracle.rdbms.rat, 19.0.0.0.0...
Patching component oracle.ldap.rsf.ic, 19.0.0.0.0...
Patching component oracle.rdbms.dv, 19.0.0.0.0...
Patching component oracle.xdk, 19.0.0.0.0...
Patching component oracle.mgw.common, 19.0.0.0.0...
Patching component oracle.ldap.client, 19.0.0.0.0...
Patching component oracle.install.deinstalltool, 19.0.0.0.0...
Patching component oracle.rdbms.rman, 19.0.0.0.0...
Patching component oracle.oraolap.api, 19.0.0.0.0...
Patching component oracle.dbtoolslistener, 19.0.0.0.0...
Patching component oracle.rdbms.drdaas, 19.0.0.0.0...
Patching component oracle.rdbms.hs_common, 19.0.0.0.0...
Patching component oracle.rdbms.lbac, 19.0.0.0.0...
Patching component oracle.sdo.locator, 19.0.0.0.0...
Patching component oracle.rdbms.dm, 19.0.0.0.0...
Patching component oracle.ldap.ssl, 19.0.0.0.0...
Patching component oracle.xdk.parser.java, 19.0.0.0.0...
Patching component oracle.odbc, 19.0.0.0.0...
Patching component oracle.network.listener, 19.0.0.0.0...
Patching component oracle.ctx.atg, 19.0.0.0.0...
Patching component oracle.rdbms.install.common, 19.0.0.0.0...
Patching component oracle.rdbms.hsodbc, 19.0.0.0.0...
Patching component oracle.network.aso, 19.0.0.0.0...
Patching component oracle.rdbms.locator, 19.0.0.0.0...
Patching component oracle.rdbms.install.plugins, 19.0.0.0.0...
Patching component oracle.nlsrtl.rsf, 19.0.0.0.0...
Patching component oracle.nlsrtl.rsf.core, 19.0.0.0.0...
Patching component oracle.nlsrtl.rsf.ic, 19.0.0.0.0...
Patching component oracle.oraolap.dbscripts, 19.0.0.0.0...
Patching component oracle.network.client, 19.0.0.0.0...
Patching component oracle.precomp.common, 19.0.0.0.0...
Patching component oracle.precomp.lang, 19.0.0.0.0...
Patching component oracle.jdk, 1.8.0.201.0...
Patch 36912597 successfully applied.
Sub-set patch [29517242] has become inactive due to the application of a super-set patch [36912597].
Please refer to Doc ID 2161861.1 for any possible further required actions.
Log file location: /u01/app/oracle/product/19.0.0/dbhome_1/cfgtoollogs/opatch/opatch2024-11-18_08-56-15AM_1.log
OPatch succeeded.
Patching component oracle.jdk, 1.8.0.201.0...
Patch 36912597 successfully applied.
Sub-set patch [29517242] has become inactive due to the application of a super-set patch [36912597].
Please refer to Doc ID 2161861.1 for any possible further required actions.
Log file location: /u01/app/oracle/product/19.0.0/dbhome_1/cfgtoollogs/opatch/opatch2024-11-18_08-56-15AM_1.log
9. Verify the Patch Application
After the patch is successfully applied, verify that the patch was installed correctly.
[oracle@discovery OPatch]$ ./opatch lsinv | grep "applied"
Patch 36912597 : applied on Mon Nov 18 08:59:18 GMT 2024
10. Post Step Datapatch
Start the Oracle database. The following commands and output show the startup process
[oracle@discovery OPatch]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Mon Nov 18 09:17:10 2024
Version 19.25.0.0.0
Copyright (c) 1982, 2024, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 1577057464 bytes
Fixed Size 9178296 bytes
Variable Size 419430400 bytes
Database Buffers 1140850688 bytes
Redo Buffers 7598080 bytes
Database mounted.
Database opened.
SQL> select open_mode,database_role from v$database;
OPEN_MODE DATABASE_ROLE
-------------------- ----------------
READ WRITE PRIMARY
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 ORCL_PDB MOUNTED
SQL> alter pluggable database ORCL_PDB open;
Pluggable database altered.
Run datapatch with the verbose Flag: Running it with the verbose flag will give you detailed output during the execution.
[oracle@discovery ~]$ ./datapatch -verbose
datapatch verbose output
[oracle@discovery OPatch]$ ./datapatch -verbose
SQL Patching tool version 19.25.0.0.0 Production on Mon Nov 18 09:23:33 2024
Copyright (c) 2012, 2024, Oracle. All rights reserved.
Log file for this invocation: /u01/app/oracle/cfgtoollogs/sqlpatch/sqlpatch_797504_2024_11_18_09_23_33/sqlpatch_invocation.log
Connecting to database...OK
Gathering database info...
done
Note: Datapatch will only apply or rollback SQL fixes for PDBs
that are in an open state, no patches will be applied to closed PDBs.
Please refer to Note: Datapatch: Database 12c Post Patch SQL Automation
(Doc ID 1585822.1)
Bootstrapping registry and package to current versions...done
Determining current state...done
Current state of interim SQL patches:
No interim patches found
Current state of release update SQL patches:
Binary registry:
19.25.0.0.0 Release_Update 241010184253: Installed
PDB CDB$ROOT:
Applied 19.3.0.0.0 Release_Update 190410122720 successfully on 04-JUL-24 11.23.40.419345 AM
PDB ORCL_PDB:
Applied 19.3.0.0.0 Release_Update 190410122720 successfully on 04-JUL-24 11.28.32.532288 AM
PDB PDB$SEED:
Applied 19.3.0.0.0 Release_Update 190410122720 successfully on 04-JUL-24 11.28.32.532288 AM
Adding patches to installation queue and performing prereq checks...done
Installation queue:
For the following PDBs: CDB$ROOT PDB$SEED ORCL_PDB
No interim patches need to be rolled back
Patch 36912597 (Database Release Update : 19.25.0.0.241015 (36912597)):
Apply from 19.3.0.0.0 Release_Update 190410122720 to 19.25.0.0.0 Release_Update 241010184253
No interim patches need to be applied
Installing patches...
Patch installation complete. Total patches installed: 3
Validating logfiles...done
Patch 36912597 apply (pdb CDB$ROOT): SUCCESS
logfile: /u01/app/oracle/cfgtoollogs/sqlpatch/36912597/25871884/36912597_apply_ORCL_CDBROOT_2024Nov18_09_26_59.log (no errors)
Patch 36912597 apply (pdb PDB$SEED): SUCCESS
logfile: /u01/app/oracle/cfgtoollogs/sqlpatch/36912597/25871884/36912597_apply_ORCL_PDBSEED_2024Nov18_09_32_54.log (no errors)
Patch 36912597 apply (pdb ORCL_PDB): SUCCESS
logfile: /u01/app/oracle/cfgtoollogs/sqlpatch/36912597/25871884/36912597_apply_ORCL_ORCL_PDB_2024Nov18_09_32_56.log (no errors)
Automatic recompilation incomplete; run utlrp.sql to revalidate.
PDBs: ORCL_PDB PDB$SEED
SQL Patching tool complete on Mon Nov 18 09:41:09 2024
Recompile Invalid Objects
During patching, some database objects might become invalid. Recompile any invalid objects in the database
[oracle@discovery OPatch]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Mon Nov 18 09:44:13 2024
Version 19.25.0.0.0
Copyright (c) 1982, 2024, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.25.0.0.0
SQL> select open_mode,database_role,name from v$database;
OPEN_MODE DATABASE_ROLE NAME
-------------------- ---------------- ---------
READ WRITE PRIMARY ORCL
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 ORCL_PDB READ WRITE NO
SQL> @?/rdbms/admin/utlrp.sql
Session altered.
TIMESTAMP
--------------------------------------------------------------------------------
COMP_TIMESTAMP UTLRP_BGN 2024-11-18 09:45:16
DOC> The following PL/SQL block invokes UTL_RECOMP to recompile invalid
DOC> objects in the database. Recompilation time is proportional to the
DOC> number of invalid objects in the database, so this command may take
DOC> a long time to execute on a database with a large number of invalid
DOC> objects.
DOC>
DOC> Use the following queries to track recompilation progress:
DOC>
DOC> 1. Query returning the number of invalid objects remaining. This
DOC> number should decrease with time.
DOC> SELECT COUNT(*) FROM obj$ WHERE status IN (4, 5, 6);
DOC>
DOC> 2. Query returning the number of objects compiled so far. This number
DOC> should increase with time.
DOC> SELECT COUNT(*) FROM UTL_RECOMP_COMPILED;
DOC>
DOC> This script automatically chooses serial or parallel recompilation
DOC> based on the number of CPUs available (parameter cpu_count) multiplied
DOC> by the number of threads per CPU (parameter parallel_threads_per_cpu).
DOC> On RAC, this number is added across all RAC nodes.
DOC>
DOC> UTL_RECOMP uses DBMS_SCHEDULER to create jobs for parallel
DOC> recompilation. Jobs are created without instance affinity so that they
DOC> can migrate across RAC nodes. Use the following queries to verify
DOC> whether UTL_RECOMP jobs are being created and run correctly:
DOC>
DOC> 1. Query showing jobs created by UTL_RECOMP
DOC> SELECT job_name FROM dba_scheduler_jobs
DOC> WHERE job_name like 'UTL_RECOMP_SLAVE_%';
DOC>
DOC> 2. Query showing UTL_RECOMP jobs that are running
DOC> SELECT job_name FROM dba_scheduler_running_jobs
DOC> WHERE job_name like 'UTL_RECOMP_SLAVE_%';
DOC>#
PL/SQL procedure successfully completed.
TIMESTAMP
--------------------------------------------------------------------------------
COMP_TIMESTAMP UTLRP_END 2024-11-18 09:45:24
DOC> The following query reports the number of invalid objects.
DOC>
DOC> If the number is higher than expected, please examine the error
DOC> messages reported with each object (using SHOW ERRORS) to see if they
DOC> point to system misconfiguration or resource constraints that must be
DOC> fixed before attempting to recompile these objects.
DOC>#
OBJECTS WITH ERRORS
-------------------
0
DOC> The following query reports the number of exceptions caught during
DOC> recompilation. If this number is non-zero, please query the error
DOC> messages in the table UTL_RECOMP_ERRORS to see if any of these errors
DOC> are due to misconfiguration or resource constraints that must be
DOC> fixed before objects can compile successfully.
DOC> Note: Typical compilation errors (due to coding errors) are not
DOC> logged into this table: they go into DBA_ERRORS instead.
DOC>#
ERRORS DURING RECOMPILATION
---------------------------
0
Function created.
PL/SQL procedure successfully completed.
Function dropped.
PL/SQL procedure successfully completed.
SQL>
The patch installation was successful and Oracle 19c database should now be running with the updated patch version (19.25.0.0.0).
Alert: The information provided on this website is for educational purposes only. It has been tested internally, but there is no guarantee it will work in every environment. It is strongly recommended to first test the process in a non-production environment, such as a User Acceptance Testing (UAT) setup. This allows you to verify configurations, identify any issues, and ensure a smooth transition to production, minimizing the risk of disruptions in your live environment. Always conduct thorough testing before applying changes to production systems.
I hope you found this blog helpful! We’d love to hear about your experiences or any questions you might have, so please share your thoughts in the comments. Your feedback is greatly appreciated. Stay tuned for more tips and advanced topics on managing Oracle Database!
