What is the difference between Prepatch and Postpatch in Oracle Patching !!
3 min readHey Folks !!
In Oracle patching, the terms prepatch and postpatch refer to specific sets of tasks or procedures that need to be performed before and after applying a patch to an Oracle database or software environment.
prepatch.sh is executed once each ORACLE_HOME, but there are two different scripts, one for the CRS_HOME and the other for the RDBMS ORACLE_HOME. There are some tasks that need to be completed before applying the patch. The goal of prepatch tasks is to ensure that the system is in a proper state to receive the patch without issues.
1. Validates the correctness of the parameters.
2. Updates file permissions (e.g., crs_stat, etc.).
3. Searches for variables already included in specific files during installation (e.g., rootconfig, racgwrap) or when executing commands like olsnodes and crsctl.
4. Confirms that the variables' values were successfully retrieved.
5. Stores the variables and their corresponding values in the $CRS_HOME/install/params.crs file.
For Example if you are performing ROLLBACK Conflicting Patches in the GRID HOME:
su - oracle
export ORACLE_HOME=/u01/grid/oracle/product/19/grid
$ORACLE_HOME/OPatch/opatch lspatches | grep 34294787
### If a patch is returned from the above, it needs to be rolled back using the following
su - root
export ORACLE_HOME=/u01/grid/oracle/product/19/grid
$ORACLE_HOME/bin/crsctl stop crs
$ORACLE_HOME/crs/install/rootcrs.sh -prepatch
exit
$ORACLE_HOME/OPatch/opatch rollback -silent -local -id 34526993 #Continue if patch does not exist
$ORACLE_HOME/OPatch/opatch rollback -silent -local -id 34385841 #Continue if patch does not exist
$ORACLE_HOME/OPatch/opatch rollback -silent -local -id 34294787
su - root
$ORACLE_HOME/crs/install/rootcrs.sh -postpatch
exit
If you want to apply Additional GRID Patch 34534544:
Following is an example of installing patches in an environment where Oracle Grid Infrastructure for a Standalone Server or Clusterware is used. The shell script name for Clusterware is rootcrs.sh, and for the standalone is roothas.sh.
As root:
su - root
export ORACLE_HOME=/u01/grid/oracle/product/19/grid
###RAC Environments Only
$ORACLE_HOME/crs/install/rootcrs.sh -prepatch
###GRID Restart Environment Only
$ORACLE_HOME/crs/install/roothas.sh -prepatch
=====Postpatch.
As oracle:
su - oracle
export ORACLE_HOME=/u01/grid/oracle/product/19/grid
cd <stage>
$ORACLE_HOME/OPatch/opatch apply -silent -local ./34534544/34534544
As root:
su - root
export ORACLE_HOME=/u01/grid/oracle/product/19/grid
###RAC Environments Only
$ORACLE_HOME/crs/install/rootcrs.sh -postpatch
###GRID Restart Environment Only
$ORACLE_HOME/crs/install/roothas.sh -postpatch
postpatch.sh. Here, OPatch has already replaced the files (scripts, executables, and libraries). As with the previous script, this one is executed one per each ORACLE_HOME. We also have two different versions, one for the CRS_HOME and one for the RDBMS ORACLE_HOME. The goal of postpatch tasks is to ensure that the patch has been applied correctly and that the system is functioning as expected.
1. Ensures that the params.crs file is correctly formatted.
2. Analyzes the params.crs file and substitutes the correct values for the variables within it.
3. It will resets the permissions for few files.
4. Start the services that were stopped during the prepatch phase.
5. Check logs and run commands to verify that the patch was applied successfully.
6. Some patches may require running SQL scripts to update database objects or data.
Hope it worked !! 🙂