Oracle: Quick Guide to Opatch - (Oracle Database Patching utility)

Tags:

Opatch FAQs and Tips

====================  
[This guide is inteded to provide a brief overview of the OPatch utility and you should always refer to the official documentation released by oracle corporation for latest information]

OPatch is a java based utility that allow the application and rolling back of interim patches to an Oracle product. The program has sub-commands that  
may take arguments. The program requires Java(JVM) to be present on the current system.OPatch expects users to have commands such as fuser, jar, ar and make on  
Unix platforms and jar on Windows platforms to be available in their PATH.

Help : $ORACLE_HOME/OPatch/docs/Users_Guide.txt

Where to download OPatch from?

Oracle 10G onwards, the RDBMS software ships with OPatch and it can be loacated under $ORACLE_HOME/OPatch. To download, opatch you need to have an metalink.oracle.com account. On Metalink search for Patch 4898608 (As of Oct 2007), select the Oracle RDBMS version and download the patch.

Check if opatch is in your path ?

Set Oracle Home  
[oracle@geeko ~]$ oraenv  
ORACLE_SID = [IDISE00P] ?

[oracle@geeko ~]$ which opatch

/usr/bin/which: no opatch in (/opt/oracle/product/10g/db_2/bin:/opt/oracle/product/db/jre/1.4.2  
/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/home/oracle/bin:/usr/local  
/bin:/opt/CLEAN_Address/bin)  
Set the PATH variable:  
[oracle@geeko ~]$ export PATH=$PATH:$ORACLE_HOME/OPatch  
[oracle@geeko ~]$ which opatch  
/opt/oracle/product/10g/db_2/OPatch/opatch

Where is your oracle Inventory?

[oracle@geeko etc]$ ls oraInst.loc  
oraInst.loc  
[oracle@geeko etc]$ cat oraInst.loc  
inventory_loc=/opt/oracle/oraInventory  
inst_group=dba  
[oracle@geeko etc]$

Where can You find Opatch Help ?

opatch <COMMAND> -help will print the help for you.

Query the Oracle Inventory:

[oracle@geeko ~]$ opatch lsinventory

Invoking OPatch 10.2.0.3.0

Oracle interim Patch Installer version 10.2.0.3.0  
Copyright (c) 2005, Oracle Corporation. All rights reserved..

Oracle Home : /opt/oracle/product/10g/db_2  
Central Inventory : /opt/oracle/oraInventory  
from : /etc/oraInst.loc  
OPatch version : 10.2.0.3.0  
OUI version : 10.2.0.3.0  
OUI location : /opt/oracle/product/10g/db_2/oui  
Log file location : /opt/oracle/product/10g/db_2/cfgtoollogs/opatch/opatch2007-10-18_09-21-35AM.log

Lsinventory Output file location : /opt/oracle/product/10g/db_2/cfgtoollogs/opatch/lsinv/lsinventory2007-10-18_09-21-35AM.txt

——————————————————————————–  
Installed Top-level Products (2):

Oracle Database 10g 10.2.0.1.0  
Oracle Database 10g Release 2 Patch Set 2 10.2.0.3.0  
There are 2 products installed in this Oracle Home.

Interim patches (2) :

Patch 5556081 : applied on Sun Feb 11 12:40:40 EST 2007  
Created on 9 Nov 2006, 22:20:50 hrs PST8PDT  
Bugs fixed:  
5556081

Patch 5557962 : applied on Sun Feb 11 12:40:31 EST 2007  
Created on 9 Nov 2006, 23:23:06 hrs PST8PDT  
Bugs fixed:  
4269423, 5557962, 5528974

——————————————————————————–

OPatch succeeded.

Query the Oracle Inventory for Details:

[oracle@geeko ~]$ opatch lsinventory -detail

Invoking OPatch 10.2.0.3.0

Oracle interim Patch Installer version 10.2.0.3.0  
Copyright (c) 2005, Oracle Corporation. All rights reserved..

Oracle Home : /opt/oracle/product/10g/db_2  
Central Inventory : /opt/oracle/oraInventory  
from : /etc/oraInst.loc  
OPatch version : 10.2.0.3.0  
OUI version : 10.2.0.3.0  
OUI location : /opt/oracle/product/10g/db_2/oui  
Log file location : /opt/oracle/product/10g/db_2/cfgtoollogs/opatch/opatch2007-10-18_09-22-01AM.log

Lsinventory Output file location : /opt/oracle/product/10g/db_2/cfgtoollogs/opatch/lsinv/lsinventory2007-10-18_09-22-01AM.txt

——————————————————————————–  
Installed Top-level Products (2):

Oracle Database 10g 10.2.0.1.0  
Oracle Database 10g Release 2 Patch Set 2 10.2.0.3.0  
There are 2 products installed in this Oracle Home.

Installed Products (183):

Agent Required Support Files 10.2.0.1.0  
Agent Required Support Files Patch 10.2.0.3.0  
..  
..

100s of lines ..  
..  
——————————————————————————–

OPatch succeeded.

What options are installed in your ORACLE_HOME?

[oracle@geeko ~]$ opatch lsinventory -detail | /bin/grep -E ‘Real Application’\|’Partitioning’\|’OLAP’\|’Data Mining’\|’Spatial’\|’Advanced Security’\|’Label Security’\|’Programmer’

OLAP SQL Scripts 10.2.0.1.0  
OLAP SQL Scripts Patch 10.2.0.3.0  
Oracle Advanced Security 10.2.0.1.0  
Oracle Advanced Security Patch 10.2.0.3.0  
Oracle Data Mining RDBMS Files 10.2.0.1.0  
Oracle Data Mining RDBMS Files Patch 10.2.0.3.0  
Oracle OLAP 10.2.0.1.0  
Oracle OLAP API 10.2.0.1.0  
Oracle OLAP API Patch 10.2.0.3.0  
Oracle OLAP Patch 10.2.0.3.0  
Oracle OLAP RDBMS Files 10.2.0.1.0  
Oracle OLAP RDBMS Files Patch 10.2.0.3.0  
Oracle Partitioning 10.2.0.1.0  
Oracle Partitioning Patch 10.2.0.3.0  
Oracle Programmer 10.2.0.1.0  
Oracle Spatial 10.2.0.1.0

How to apply a patch ?

1. You MUST read the Readme.txt file included in opatch file, look for any prereq. steps/ post installation steps or and DB related changes. Also, make sure that you have the correct opatch version required by this patch.  
2.Make sure you have a good backup of database.  
3. Make a note of all Invalid objects in the database prior to the patch.  
4. Shutdown All the Oracle Processes running from that Oracle Home , including the Listener and Database instance, Management agent etc.  
5. You MUST Backup your oracle Home and Inventory

tar cvf - $ORACLE_HOME $ORACLE_HOME/oraInventory | gzip > Backup_Software_Version.tar.gz

6. Unzip the patch in $ORACLE_HOME/patches  
7. cd to the patch direcory and do opatch -apply to apply the patch.  
8. Read the output/log file to make sure there were no errors.

How to Rollback a patch?

opatch rollback -id <Patch Number>

I messed up my Oracle home/ opatch rollback is failing , what to do now?

Remember, we took the backup of the ORACLE_HOME and main importantly the Oracle inventory, you can just restore (uncompress) the software and the inventory and you are all set. Also for fixing the corrupt inventory, please refer to this metalink Note:298906.1