Updating OPatch and Running Pre-Check in Oracle 19c

In this article, I’ll guide you through updating the OPatch utility and performing a pre-check to ensure smooth patch application in Oracle 19c. We will be using the OPatch utility located in /u01/patch/patch_1924 to update to PSU 19.24.

1. Preparing the Environment

First, download the latest OPatch patch set (PSU 19.24 in this case) from Oracle Support and place it in the directory /u01/patch/patch_1924.

To make sure the patch files have the correct permissions, run:

# As root
chmod 777 -R /u01/patch/patch_1924

Warning: Be cautious when setting permissions recursively to 777. Only apply this to the specific patch directory.

2. Switching to the grid User

Next, switch to the grid user, who will handle the OPatch update:

su - grid

Navigate to the patch directory:

cd /u01/patch/patch_1924

3. Extracting the OPatch Archive

Inside the patch directory, unzip the OPatch archive:

unzip -q p6880880_190000_Linux-x86-64.zip

This creates a new OPatch folder with the updated utility files.

4. Updating the OPatch Directory in ORACLE_HOME

Oracle installations have an OPatch directory within $ORACLE_HOME. Our update process involves backing up the current OPatch directory and replacing it with the new version.

Navigate to your existing OPatch directory:

cd $ORACLE_HOME/OPatch
pwd
# Output should confirm your ORACLE_HOME OPatch directory, e.g., /u01/app/oracle/product/19.0.0/grid/OPatch
  1. Backup Current OPatch Files
    Create a backup folder inside OPatch, moving the old files there. If a folder named old already exists, consider renaming it or creating old2:
   mkdir old
   mv * old/
  1. Copy the New OPatch Files
    Now, copy the files from /u01/patch/patch_1924/OPatch to the $ORACLE_HOME/OPatch directory:
   cp -ra /u01/patch/patch_1924/OPatch/* ./

5. Verifying the OPatch Version

To confirm the OPatch update was successful, check the version:

./opatch version

Example Output:

OPatch Version: 12.2.0.1.44
OPatch succeeded.

6. Extracting Patches and Running the Pre-Check

Now, it’s time to unpack the actual patches and run the pre-check.

Extract the Patch Files

Go back to the patch directory:

cd /u01/patch/patch_1924
unzip -q p36582629_190000_Linux-x86-64.zip

Verify the new patch folder (36582629) was created:

ll -h

Run Conflict Pre-Check

Use the following command to check for conflicts in the patch:

$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /u01/patch/patch_1924/36582629/36582781 | tail -n5

Repeat this for each patch in the directory:

$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /u01/patch/patch_1924/36582629/36587798 | tail -n5
$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /u01/patch/patch_1924/36582629/36590554 | tail -n5
$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /u01/patch/patch_1924/36582629/36648174 | tail -n5
$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /u01/patch/patch_1924/36582629/36758186 | tail -n5

Each command should return “OPatch succeeded” to confirm no conflicts.

7. Running the Final Pre-Check as Root

Switch to the root user and export the necessary environment variables:

su - root

PATH=/sbin:/bin:/usr/sbin:/usr/bin:/u01/app/oracle/product/19.0.0/grid/bin:/u01/app/oracle/product/19.0.0/grid/OPatch; export PATH
ORACLE_SID=+ASM2; export ORACLE_SID
ORACLE_HOSTNAME=L17Oracle02; export ORACLE_HOSTNAME
LD_LIBRARY_PATH=/u01/app/oracle/product/19.0.0/grid/lib; export LD_LIBRARY_PATH
OH=/u01/app/oracle/product/19.0.0/grid; export OH
ORACLE_HOME=/u01/app/oracle/product/19.0.0/grid; export ORACLE_HOME

Change to the main patch directory and run the pre-check with the -analyze option, ensuring the patch is tested without applying it permanently:

cd /u01/patch/patch_1924/36582629
$ORACLE_HOME/OPatch/opatchauto apply /u01/patch/patch_1924/36582629 -oh /u01/app/oracle/product/19.0.0/grid -analyze

Expected Output:

OPatchAuto session is initiated...
Patch applicability verified successfully on home...
OPatchAuto successful.

Conclusion

Your OPatch utility is now updated, and you have successfully run pre-checks to ensure a smooth patching process in Oracle 19c. By following these steps, you minimize downtime and reduce the risk of errors during patching.

Leave a Reply

Your email address will not be published. Required fields are marked *