Moneycontrol Brokerage Recos

Monday, October 26, 2015

How to Apply Critical Patch Updates in Oracle Database?

Just thought to create a small paper that how we apply critical patch updates in oracle database on request of my two friends - Neha Mehra & Jatin Wadhwa

Please follow the below steps to learn how to apply critical patch update in Oracle database.
I have used Oracle database 11.2.0.1.0 and CPU2011 patch to write this paper and have restricted/removed some outputs(messages/standard outputs) to make the paper not lengthy.

Solution:

Pre-requisites: 

Always make sure you have appropriate Opatch version in place to apply CPU/PSU patches. Latest can be downloaded from Metalik patch number #6880880. 

Download Oracle CPU2011 patch - p12419278_112010_LINUX.zip from metalink with patch number - 12419278 and unzip it somewhere at your database server. In my case I have inflated inside /u01/app directory.

[oracle@oem12c app]$ pwd
/u01/app

[oracle@oem12c app]$ ls -ltr
total 53192
drwxrwxr-x 31 oracle  oinstall     4096 Jul  8  2011 12419278  -- unzipped CPU patch bundle
-rwxr-xr-x  1 oragrid oinstall  4633877 Oct 15 15:59 p12419278_112010_LINUX.zip -- downloaded CPU patch zip file


List of any previous interim one off patches if already applied any:

[oracle@oem12c OPatch]$ ./opatch lsinv
Picked up _JAVA_OPTIONS: -Xms256m -Xmx512m
Invoking OPatch 11.1.0.6.6

Oracle Interim Patch Installer version 11.1.0.6.6
Copyright (c) 2009, Oracle Corporation.  All rights reserved.


Oracle Home       : /u01/app/oracle/product/11.2.0/dbhome_1
Central Inventory : /u01/app/oraInventory
   from           : /etc/oraInst.loc
OPatch version    : 11.1.0.6.6
OUI version       : 11.2.0.1.0
OUI location      : /u01/app/oracle/product/11.2.0/dbhome_1/oui
Log file location : /u01/app/oracle/product/11.2.0/dbhome_1/cfgtoollogs/opatch/opatch2015-10-26_12-38-45PM.log

Patch history file: /u01/app/oracle/product/11.2.0/dbhome_1/cfgtoollogs/opatch/opatch_history.txt

Lsinventory Output file location : /u01/app/oracle/product/11.2.0/dbhome_1/cfgtoollogs/opatch/lsinv/lsinventory2015-10-26_12-38-45PM.txt

--------------------------------------------------------------------------------
Installed Top-level Products (1): 

Oracle Database 11g                                                  11.2.0.1.0
There are 1 products installed in this Oracle Home.


There are no Interim patches installed in this Oracle Home.


--------------------------------------------------------------------------------

OPatch succeeded.



Note : - We can see no any interim patches applied to this ORACLE_HOME.



Here we go and Apply CPU2011 patch now.
================================

Just navigate inside the unzipped patch directory and find the list of patches which will be applied.


[oracle@oem12c app]$ cd 12419278

[oracle@oem12c 12419278]$ pwd
/u01/app/12419278


Below are the list of interim patches inside this CPU patch bundle which will be applied to this ORACLE_HOME.

[oracle@oem12c 12419278]$ pwd
/u01/app/12419278
[oracle@oem12c 12419278]$ ls -ltr
total 168
drwxr-xr-x 4 oracle oinstall  4096 Mar 15  2010 9454038
drwxr-xr-x 4 oracle oinstall  4096 Mar 24  2010 9454037
drwxr-xr-x 4 oracle oinstall  4096 May 31  2010 9676419
drwxr-xr-x 4 oracle oinstall  4096 May 31  2010 9676420
drwxr-xr-x 4 oracle oinstall  4096 Sep 14  2010 9971778
drwxr-xr-x 4 oracle oinstall  4096 Sep 14  2010 9971779
drwxr-xr-x 4 oracle oinstall  4096 Sep 14  2010 9971780
drwxr-xr-x 4 oracle oinstall  4096 Nov 23  2010 10323077
drwxr-xr-x 4 oracle oinstall  4096 Nov 23  2010 10323079
drwxr-xr-x 4 oracle oinstall  4096 Nov 23  2010 10323081
drwxr-xr-x 4 oracle oinstall  4096 Nov 23  2010 10323082
drwxr-xr-x 4 oracle oinstall  4096 Feb 23  2011 11794164
drwxr-xr-x 4 oracle oinstall  4096 Feb 23  2011 11794167
drwxr-xr-x 4 oracle oinstall  4096 Mar 25  2011 11794163
drwxr-xr-x 4 oracle oinstall  4096 May 18  2011 12534742
drwxr-xr-x 4 oracle oinstall  4096 May 18  2011 12534743
drwxr-xr-x 4 oracle oinstall  4096 May 18  2011 12534745
drwxr-xr-x 4 oracle oinstall  4096 May 18  2011 12534746
drwxr-xr-x 4 oracle oinstall  4096 May 18  2011 12534747
drwxr-xr-x 4 oracle oinstall  4096 May 18  2011 12534748
drwxr-xr-x 4 oracle oinstall  4096 May 18  2011 12534749
drwxr-xr-x 4 oracle oinstall  4096 May 18  2011 12534750
drwxr-xr-x 4 oracle oinstall  4096 May 18  2011 12534752
drwxr-xr-x 4 oracle oinstall  4096 May 18  2011 12534753
drwxr-xr-x 4 oracle oinstall  4096 May 18  2011 12534754
drwxr-xr-x 4 oracle oinstall  4096 May 18  2011 12534755
drwxr-xr-x 4 oracle oinstall  4096 May 18  2011 12534756
drwxr-xr-x 5 oracle oinstall  4096 May 19  2011 12419278
drwxr-xr-x 4 oracle oinstall  4096 Jul  8  2011 12534751
-rw-r--r-- 1 oracle oinstall    21 Jul  8  2011 README.txt
-rwxr-xr-x 1 oracle oinstall  2872 Jul  8  2011 patchmd.xml
-rw-rw-r-- 1 oracle oinstall 42530 Jul 18  2011 README.html


Note : - you can see there are many interim patches since 2010, yes Oracle critical patches are cumulative which includes all previous CPU patches released for that database version so far this is why it is recommended to apply latest CPU/PSU patches to an Oracle database.


Now let's invoke opatch from ORACLE_HOME where we are going to apply these N number of CPU patches included in CPU2011 CPU patch bundle.

[oracle@oem12c 12419278]$ /u01/app/oracle/product/11.2.0/dbhome_1/OPatch/opatch napply 
Picked up _JAVA_OPTIONS: -Xms256m -Xmx512m
Invoking OPatch 11.1.0.6.6

Oracle Interim Patch Installer version 11.1.0.6.6
Copyright (c) 2009, Oracle Corporation.  All rights reserved.

UTIL session

Oracle Home       : /u01/app/oracle/product/11.2.0/dbhome_1
Central Inventory : /u01/app/oraInventory
   from           : /etc/oraInst.loc
OPatch version    : 11.1.0.6.6
OUI version       : 11.2.0.1.0
OUI location      : /u01/app/oracle/product/11.2.0/dbhome_1/oui
Log file location : /u01/app/oracle/product/11.2.0/dbhome_1/cfgtoollogs/opatch/opatch2015-10-26_12-56-58PM.log

Patch history file: /u01/app/oracle/product/11.2.0/dbhome_1/cfgtoollogs/opatch/opatch_history.txt

Invoking utility "napply"
Checking conflict among patches...
Checking if Oracle Home has components required by patches...
Checking conflicts against Oracle Home...
OPatch continues with these patches:   10323077  10323079  10323081  10323082  11794163  11794164  11794167  12419278  12534742  12534743  12534745  12534746  12534747  12534748  12534749  12534750  12534751  12534752  12534753  12534754  12534755  12534756  9454037  9454038  9676419  9676420  9971778  9971779  9971780  

Do you want to proceed? [y|n]   -- here press y to agree on applying all patches inside this patch bundle.
y       
User Responded with: Y

Running prerequisite checks...
Patch 12534751: Optional component(s) missing : [ oracle.client, 11.2.0.1.0 ] 

OPatch detected non-cluster Oracle Home from the inventory and will patch the local system only.


Please shutdown Oracle instances running out of this ORACLE_HOME on the local system.
(Oracle Home = '/u01/app/oracle/product/11.2.0/dbhome_1')


Is the local system ready for patching? [y|n]  -- Here press y if your all oracle services are down which are running from the ORACLE_HOME in order to proceed ahead for patching activity.
y
User Responded with: Y
Backing up files affected by the patch 'NApply' for restore. This might take a while...
Execution of 'sh /u01/app/12419278/12419278/custom/scripts/pre -apply 12419278 ':


Return Code = 0

Applying patch 10323077...

ApplySession applying interim patch '10323077' to OH '/u01/app/oracle/product/11.2.0/dbhome_1'
Backing up files affected by the patch '10323077' for rollback. This might take a while...

Patching component oracle.rdbms.dv.oc4j, 11.2.0.1.0...
Updating jar file "/u01/app/oracle/product/11.2.0/dbhome_1/dv/jlib/dva_webapp.ear" with "/dv/jlib/dva_webapp.ear/dva_webapp.war/WEB-INF/lib/dva_webapp.jar/oracle/security/datval/dva/BasePageHandler.class"
Updating jar file "/u01/app/oracle/product/11.2.0/dbhome_1/dv/jlib/dva_webapp.ear" with "/dv/jlib/dva_webapp.ear/dva_webapp.war/WEB-INF/lib/dva_webapp.jar/oracle/security/datval/dva/admin/AdminPageHandler.class"
Updating jar file "/u01/app/oracle/product/11.2.0/dbhome_1/dv/jlib/dva_webapp.ear" with "/dv/jlib/dva_webapp.ear/dva_webapp.war/WEB-INF/lib/dva_webapp.jar/oracle/security/datval/dva/security/LoginPageHandler.class"
Updating jar file "/u01/app/oracle/product/11.2.0/dbhome_1/dv/jlib/dva_webapp.ear" with "/dv/jlib/dva_webapp.ear/dva_webapp.war/WEB-INF/lib/dva_webapp.jar/oracle/security/datval/util/ViewUtil.class"
Updating jar file "/u01/app/oracle/product/11.2.0/dbhome_1/dv/jlib/dva_webapp.ear" with "/dv/jlib/dva_webapp.ear/dva_webapp.war/WEB-INF/lib/dva_webapp_jsp.jar/_home/_about.class"
Updating jar file "/u01/app/oracle/product/11.2.0/dbhome_1/dv/jlib/dva_webapp.ear" with "/dv/jlib/dva_webapp.ear/dva_webapp.war/WEB-INF/lib/dva_webapp_jsp.jar/_delete.class"
Updating jar file "/u01/app/oracle/product/11.2.0/dbhome_1/dv/jlib/dva_webapp.ear" with "/dv/jlib/dva_webapp.ear/dva_webapp.war/WEB-INF/lib/dva_webapp_jsp.jar/_errorPage.class"
.
.
.
.
.
.
.
.
.
.
.
Applying patch 9971779...

ApplySession applying interim patch '9971779' to OH '/u01/app/oracle/product/11.2.0/dbhome_1'
Backing up files affected by the patch '9971779' for rollback. This might take a while...

Patching component oracle.javavm.server, 11.2.0.1.0...
Copying file to "/u01/app/oracle/product/11.2.0/dbhome_1/javavm/install/jvm_exp.sql"
Copying file to "/u01/app/oracle/product/11.2.0/dbhome_1/javavm/install/initjvm.sql"
Copying file to "/u01/app/oracle/product/11.2.0/dbhome_1/javavm/install/jvmursc.sql"
ApplySession adding interim patch '9971779' to inventory

Verifying the update...
Inventory check OK: Patch ID 9971779 is registered in Oracle Home inventory with proper meta-data.
Files check OK: Files from Patch ID 9971779 are present in Oracle Home.

Applying patch 9971780...

ApplySession applying interim patch '9971780' to OH '/u01/app/oracle/product/11.2.0/dbhome_1'
Backing up files affected by the patch '9971780' for rollback. This might take a while...

Patching component oracle.rdbms.dbscripts, 11.2.0.1.0...
Copying file to "/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/admin/dbmscdcu.sql"
Copying file to "/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/admin/prvtcdcu.plb"
Copying file to "/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/admin/prvtcdcp.plb"
Copying file to "/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/admin/prvtcdcs.plb"

Patching component oracle.rdbms, 11.2.0.1.0...
Updating archive file "/u01/app/oracle/product/11.2.0/dbhome_1/lib/libserver11.a"  with "lib/libserver11.a/kkzl.o"
ApplySession adding interim patch '9971780' to inventory

Verifying the update...
Inventory check OK: Patch ID 9971780 is registered in Oracle Home inventory with proper meta-data.
Files check OK: Files from Patch ID 9971780 are present in Oracle Home.
Running make for target ioracle
Running make for target client_sharedlib
Running make for target client_sharedlib
Running make for target itnslsnr

The local system has been patched and can be restarted.

UtilSession: N-Apply done.

OPatch succeeded.   



Post OPatch steps:
=============

As in the previous step, all patches have been applied to the ORACLE_HOME so we can start Oracle services now and run the following catcpu.sql script from the ORACLE_HOME where we applied the patch.

[oracle@oem12c CPUJul2011]$ pwd
/u01/app/oracle/product/11.2.0/dbhome_1/cpu/CPUJul2011

Connect as sysdba and run the script as below.

SQL>@/u01/app/oracle/product/11.2.0/dbhome_1/cpu/CPUJul2011/catcpu.sql


After running above CPU bundle script, run utlrp.sql script to compile database objects gone in INVALID state during patching activity.

SQL>$ORACLE_HOME/rdbms/admin/utlrp.sql


Let's verify the number of patches applied to this ORACLE_HOME
===================================================

[oracle@oem12c OPatch]$ ./opatch lsinv
Picked up _JAVA_OPTIONS: -Xms256m -Xmx512m
Invoking OPatch 11.1.0.6.6

Oracle Interim Patch Installer version 11.1.0.6.6
Copyright (c) 2009, Oracle Corporation.  All rights reserved.


Oracle Home       : /u01/app/oracle/product/11.2.0/dbhome_1
Central Inventory : /u01/app/oraInventory
   from           : /etc/oraInst.loc
OPatch version    : 11.1.0.6.6
OUI version       : 11.2.0.1.0
OUI location      : /u01/app/oracle/product/11.2.0/dbhome_1/oui
Log file location : /u01/app/oracle/product/11.2.0/dbhome_1/cfgtoollogs/opatch/opatch2015-10-26_16-18-51PM.log

Patch history file: /u01/app/oracle/product/11.2.0/dbhome_1/cfgtoollogs/opatch/opatch_history.txt

Lsinventory Output file location : /u01/app/oracle/product/11.2.0/dbhome_1/cfgtoollogs/opatch/lsinv/lsinventory2015-10-26_16-18-51PM.txt

--------------------------------------------------------------------------------
Installed Top-level Products (1): 

Oracle Database 11g                                                  11.2.0.1.0
There are 1 products installed in this Oracle Home.


Interim patches (29) :

Patch  9971780      : applied on Mon Oct 26 13:15:17 IST 2015
Unique Patch ID:  13710306
   Created on 14 Sep 2010, 06:04:59 hrs PST8PDT
   Bugs fixed:
     9971780

Patch  9971779      : applied on Mon Oct 26 13:15:10 IST 2015
Unique Patch ID:  13710306
   Created on 14 Sep 2010, 06:04:14 hrs PST8PDT
   Bugs fixed:
     9971779, 9454036

Patch  9971778      : applied on Mon Oct 26 13:15:07 IST 2015
Unique Patch ID:  13710306
   Created on 14 Sep 2010, 06:02:16 hrs PST8PDT
   Bugs fixed:
     9971778

Patch  9676420      : applied on Mon Oct 26 13:15:05 IST 2015
Unique Patch ID:  13710306
   Created on 31 May 2010, 02:36:09 hrs PST8PDT
   Bugs fixed:
     9676420

Patch  9676419      : applied on Mon Oct 26 13:15:03 IST 2015
Unique Patch ID:  13710306
   Created on 31 May 2010, 02:07:11 hrs PST8PDT
   Bugs fixed:
     9676419

Patch  9454038      : applied on Mon Oct 26 13:15:00 IST 2015
Unique Patch ID:  13710306
   Created on 15 Mar 2010, 08:56:17 hrs PST8PDT
   Bugs fixed:
     9454038

Patch  9454037      : applied on Mon Oct 26 13:14:58 IST 2015
Unique Patch ID:  13710306
   Created on 24 Mar 2010, 06:44:08 hrs PST8PDT
   Bugs fixed:
     9454037

Patch  12534756     : applied on Mon Oct 26 13:14:55 IST 2015
Unique Patch ID:  13710306
   Created on 18 May 2011, 06:13:30 hrs PST8PDT
   Bugs fixed:
     12534756, 11794165

Patch  12534755     : applied on Mon Oct 26 13:14:51 IST 2015
Unique Patch ID:  13710306
   Created on 18 May 2011, 06:13:28 hrs PST8PDT
   Bugs fixed:
     12534755, 8702535, 8991997

Patch  12534754     : applied on Mon Oct 26 13:14:35 IST 2015
Unique Patch ID:  13710306
   Created on 18 May 2011, 06:13:27 hrs PST8PDT
   Bugs fixed:
     12534754

Patch  12534753     : applied on Mon Oct 26 13:14:29 IST 2015
Unique Patch ID:  13710306
   Created on 18 May 2011, 06:13:25 hrs PST8PDT
   Bugs fixed:
     12534753

Patch  12534752     : applied on Mon Oct 26 13:13:58 IST 2015
Unique Patch ID:  13710306
   Created on 18 May 2011, 06:13:24 hrs PST8PDT
   Bugs fixed:
     12534752

Patch  12534751     : applied on Mon Oct 26 13:13:55 IST 2015
Unique Patch ID:  13710306
   Created on 8 Jul 2011, 02:03:42 hrs PST8PDT
   Bugs fixed:
     12534751

Patch  12534750     : applied on Mon Oct 26 13:13:53 IST 2015
Unique Patch ID:  13710306
   Created on 18 May 2011, 06:13:21 hrs PST8PDT
   Bugs fixed:
     12534750

Patch  12534749     : applied on Mon Oct 26 13:13:49 IST 2015
Unique Patch ID:  13710306
   Created on 18 May 2011, 06:13:20 hrs PST8PDT
   Bugs fixed:
     12534749

Patch  12534748     : applied on Mon Oct 26 13:13:36 IST 2015
Unique Patch ID:  13710306
   Created on 18 May 2011, 06:13:18 hrs PST8PDT
   Bugs fixed:
     12534748

Patch  12534747     : applied on Mon Oct 26 13:12:01 IST 2015
Unique Patch ID:  13710306
   Created on 18 May 2011, 06:13:16 hrs PST8PDT
   Bugs fixed:
     12534747

Patch  12534746     : applied on Mon Oct 26 13:07:56 IST 2015
Unique Patch ID:  13710306
   Created on 18 May 2011, 06:13:13 hrs PST8PDT
   Bugs fixed:
     12534746

Patch  12534745     : applied on Mon Oct 26 13:07:46 IST 2015
Unique Patch ID:  13710306
   Created on 18 May 2011, 06:13:11 hrs PST8PDT
   Bugs fixed:
     12534745

Patch  12534743     : applied on Mon Oct 26 13:07:32 IST 2015
Unique Patch ID:  13710306
   Created on 18 May 2011, 06:13:08 hrs PST8PDT
   Bugs fixed:
     12534743

Patch  12534742     : applied on Mon Oct 26 13:04:44 IST 2015
Unique Patch ID:  13710306
   Created on 18 May 2011, 06:13:07 hrs PST8PDT
   Bugs fixed:
     12534742

Patch  12419278     : applied on Mon Oct 26 13:04:18 IST 2015
Unique Patch ID:  13710306
   Created on 19 May 2011, 06:17:30 hrs PST8PDT
   Bugs fixed:
     9655013, 12419278, 9952260, 9369797, 11724991, 10249532

Patch  11794167     : applied on Mon Oct 26 13:04:14 IST 2015
Unique Patch ID:  13710306
   Created on 23 Feb 2011, 04:04:04 hrs PST8PDT
   Bugs fixed:
     11794167

Patch  11794164     : applied on Mon Oct 26 13:04:05 IST 2015
Unique Patch ID:  13710306
   Created on 23 Feb 2011, 00:52:19 hrs PST8PDT
   Bugs fixed:
     11794164

Patch  11794163     : applied on Mon Oct 26 13:04:02 IST 2015
Unique Patch ID:  13710306
   Created on 25 Mar 2011, 02:54:11 hrs PST8PDT
   Bugs fixed:
     10323080, 11794163

Patch  10323082     : applied on Mon Oct 26 13:03:43 IST 2015
Unique Patch ID:  13710306
   Created on 15 Dec 2010, 05:59:50 hrs PST8PDT
   Bugs fixed:
     10323082

Patch  10323081     : applied on Mon Oct 26 13:03:22 IST 2015
Unique Patch ID:  13710306
   Created on 15 Dec 2010, 05:59:55 hrs PST8PDT
   Bugs fixed:
     10323081

Patch  10323079     : applied on Mon Oct 26 13:03:18 IST 2015
Unique Patch ID:  13710306
   Created on 15 Dec 2010, 06:00:22 hrs PST8PDT
   Bugs fixed:
     10323079

Patch  10323077     : applied on Mon Oct 26 13:03:05 IST 2015
Unique Patch ID:  13710306
   Created on 15 Dec 2010, 06:00:48 hrs PST8PDT
   Bugs fixed:
     10323077



--------------------------------------------------------------------------------

OPatch succeeded.


Now we are done with CPU patching activity.
Hope it would help someone in understanding how to apply CPU patches in oracle database.


No comments:

Post a Comment