Opatch commands



Which Patch has been installed?

The easies way to list the installed patches in the current ORACLE_HOME is to use the patch utility.

List of installed patches:
$ORACLE_HOME/OPatch/opatch lsinventory

Grep on the patch description:
$ORACLE_HOME/OPatch/opatch lsinventory|grep "Patch description"
Patch description: "Database Patch Set Update : 11.2.0.3.7 (16619892)"

A more verbose list on the installed patches:
$ORACLE_HOME/OPatch/opatch lsinventory -details
Which Patch has been applied?

The table REGISTRY$HISTORY does contain information on applied patches respectively PSU, SRU or CPU. SinceSince I use this query regularly during the tests of the Critical Patch Update, I have it packed in a handy script ( cpui.sql).
SET linesize 200 pagesize 200
col action_time FOR a28
col version FOR a10
col comments FOR a35
col action FOR a25
col namespace FOR a12

SELECT * FROM registry$history;


Patch Conflict:
opatch apply -silent -no_bug_superset -report

----
Opatch is an Oracle utility for the application and rolling back of interim patches to the Oracle RDBMS.  In order to use opatch it is recommended to set its location in $PATH.

Location

OPatch can be found under $ORACLE_HOME/OPatch

Current Patch History

To find the current patch history run the following:
$ opatch lsinventory [ -all ] [ -i[nvPtrLoc] ][ -oh ]
-all
– list all patches currently applied.

OPatch Version

$ sh opatch version
Invoking OPatch 10.2.0.4.2
OPatch Version: 10.2.0.4.2
OPatch succeeded.

OPatch Apply

$ opatch apply [-f[orce]] [-i[nvPtrLoc]] []
-force
– used to remove any conflicting patches and force the patch to be applied
-invPtrLoc
– used to locate the oraInst.loc file
-minimize_downtime
– used only in RAC instances, allowing for the remaining instances to remain up during patching. It is the responsibility of the user to shutdown each instance before applying the patches, after the last instance is patched then all instances can be brought back up.
-no_inventory
– This only works if the inventory is unavailable and allows for bypassing the inventory for reading and updates.
-oh
– Directory to be used instead of the default $ORACLE_HOME
patch_location
– Where to install the patch from

OPatch Rollback

Sometimes it is necessary to rollback a patch once it has been applied.
$ opatch rollback -id patch_id [-i[nvPtrLoc]] [-oh ] -pj patch_dir
-id
– The id of the patch that requires rollback
-ph
– The directory that is a valid patch area.

How to check which PSU is installed…if any

Oracle PSUs (Patch Set Updates) are referenced by their 5-place version number.  Unfortunately they do not change version numbers in the Oracle binaries, product banners and such though (see MOS 861152.1), so here’s how to identify which PSU your ORACLE_HOME is at…
Database Server:
$ORACLE_HOME/OPatch/opatch lsinventory -bugs_fixed | grep -i -E 'DATABASE PSU|DATABASE PATCH SET UPDATE'
$ORACLE_HOME/OPatch/opatch lsinventory -bugs_fixed | egrep -i 'DATABASE PSU|DATABASE PATCH SET UPDATE'
(The first command above being for Linux)
…or using the following SQL:
select comments, version, bundle_series
from sys.registry$history
where bundle_series = 'PSU'
order by action_time;

COMMENTS                       VERSION                        BUNDLE_SERIES
------------------------------ ------------------------------ -----------------
Patchset 11.2.0.2.0            11.2.0.3                       PSU
PSU 11.2.0.3.5                 11.2.0.3                       PSU
The above view is populated when catbundle.sql is executed.  If the query above ends with “ORA-00904: “BUNDLE_SERIES”: invalid identifier” then no bundle patch (PSU or CPU) has been applied.
Grid Infrastructure:
$ORACLE_HOME/OPatch/opatch lsinventory -bugs_fixed | grep -i 'GI PSU'
Cluster Ready Services:
$ORACLE_HOME/OPatch/opatch lsinventory -bugs_fixed | grep -i 'TRACKING BUG' | grep -i 'PSU'
Enterprise Manager Agent:
$ORACLE_HOME/OPatch/opatch lsinventory -bugs_fixed | grep -i 'ENTERPRISE MANAGER AGENT' | grep -i 'PSU'
Enterprise Manager OMS:
$ORACLE_HOME/OPatch/opatch lsinventory -bugs_fixed | grep -i 'ENTERPRISE MANAGER OMS' | grep -i 'PSU'

No comments: