Friday, May 2, 2025

Run opatch in silent mode in EBS R12.2

Sometimes, you want to apply patches to Oracle Home in a shell script. To do that, you do not want to run opatch interactively. Here is how to apply patches to an Oracle Home of Fusion Middleware in silent mode.

$ export ORACLE_HOME=$FMW_HOME/oracle_common
$ export PATH=$ORACLE_HOME/OPatch:$PATH
$ which opatch    <= make sure opatch is from oracle_common/OPatch
$ echo $ORACLE_HOME
$RUN_BASE/FMW_Home/oracle_common

First, run emocmrsp to create a response file ocm.rsp:
$ cd $ORACLE_HOME/OPatch/ocm/bin
$ ./emocmrsp
The ORACLE_HOME does not contain java.
The ORACLE_HOME does not contain a valid JDK/JRE.
Redefine JAVA_HOME to refer to a JDK/JRE 1.2.2 or greater.

$ export JAVA_HOME=$FMW_HOME/webtier/jdk   <= I chose this 64-bit JDK
$ echo $JAVA_HOME
$RUN_BASE/FMW_Home/webtier/jdk
$ ./emocmrsp
OCM Installation Response Generator 10.3.7.0.0 - Production
Copyright (c) 2005, 2012, Oracle and/or its affiliates.  All rights reserved.
Provide your email address to be informed of security issues, install and
initiate Oracle Configuration Manager. Easier for you if you use your My
Oracle Support Email address/User Name.
Visit http://www.oracle.com/support/policies.html for details.
Email address/User Name:
You have not provided an email address for notification of security issues.
Do you wish to remain uninformed of security issues ([Y]es, [N]o) [N]:  Y
The OCM configuration response file (ocm.rsp) was successfully created.

$ ls -al
-rwxr-x---. 1 userID Group 9063 Jul 21  2022 emocmrsp
-rw-rw-r--. 1 userID Group oaa  622 May 1 13:08 ocm.rsp

File ocm.rsp is created in $ORACLE_HOME/OPatch/ocm/bin by emocmrsp. It is a binary file, and can be copied to a shared location /path/to/sharedLocation for patching in other nodes or instances. 

Now, apply a patch to Oracle Common home without answering any opatch questions. For example, apply patch 33974106.

$ ps -ef | grep $LOGNAME     <= make sure EBS services are shutdown
$ cd /path/to/33974106

$ opatch apply -silent -ocmrf /path/to/sharedLocation/ocm.rsp
Oracle Interim Patch Installer version 11.1.0.12.9
Copyright (c) 2025, Oracle Corporation.  All rights reserved.
Oracle Home       : $RUN_BASE/FMW_Home/oracle_common
Central Inventory : /u03/app/oraInventoryDEVEBS
from                     : $RUN_BASE/FMW_Home/oracle_common/oraInst.loc
OPatch version    : 11.1.0.12.9
OUI version         : 11.1.0.11.0
Log file location : $RUN_BASE/FMW_Home/oracle_common/cfgtoollogs/opatch/33974106_May_1_2025_13_02_04/apply2025-05-1_13-02-04PM_1.log
OPatch detects the Middleware Home as "$RUN_BASE/FMW_Home"
Applying interim patch '33974106' to OH '$RUN_BASE/FMW_Home/oracle_common'
Verifying environment and performing prerequisite checks...
All checks passed.
Please shutdown Oracle instances running out of this ORACLE_HOME on the local system.
(Oracle Home = '$RUN_BASE/FMW_Home/oracle_common')
Is the local system ready for patching? [y|n]
Y (auto-answered by -silent)
User Responded with: Y
Backing up files...
Patching component oracle.jrf.thirdparty.jee, 11.1.1.9.0...
Verifying the update...
Patch 33974106 successfully applied
Log file location: $RUN_BASE/FMW_Home/oracle_common/cfgtoollogs/opatch/33974106_May_1_2025_13_02_04/apply2025-05-1_13-02-04PM_1.log
OPatch succeeded.

No comments: