Translate into your own language

Sunday, March 20, 2016

Step by step how to apply CPU(SPU) Patch in Oracle

STEP 1:Check the operating system bit version (32 bit or 64 bit).

 [oracle@host1 ~]$ uname -a

 Linux host11.intra.searshc.com 2.6.18-308.1.1.el5xen #1 SMP Fri Feb 17 17:11:09 EST 2012 x86_64 x86_64 x86_64 GNU/Linux.

here we can see it is Linux operating system with bit version  x86_64.

If it is AIX server then use below command to check the bit version:

host03-oracle:/home/oracle(PROD)-->getconf -a | grep KERN
KERNEL_BITMODE:                         64


STEP 2:Check the oracle database version where we have to apply the patch.

There are various method to check the database version. I would be using lsinventory command because it shows many more details apart from database version.

[oracle@host1 ~]$ $ORACLE_HOME/OPatch/opatch lsinventory

Oracle Interim Patch Installer version 11.2.0.3.5
Copyright (c) 2013, Oracle Corporation.  All rights reserved.


Oracle Home       : /u01/app/oracle/product/11.2.0.2/db_1
Central Inventory : /u01/app/oraInventory
   from           : /u01/app/oracle/product/11.2.0.2/db_1/oraInst.loc
OPatch version    : 11.2.0.3.5
OUI version         : 11.2.0.2.0
Log file location : /u01/app/oracle/product/11.2.0.2/db_1/cfgtoollogs/opatch/opatch2016-03-21_00-14-10AM_1.log

Lsinventory Output file location : /u01/app/oracle/product/11.2.0.2/db_1/cfgtoollogs/opatch/lsinv/lsinventory2016-03-21_00-14
-10AM.txt

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

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

the above is the only parical output. You can see lot of other detials as well.
Here you can notice two things:
1. OPatch version    : 11.2.0.3.5
2. Oracle Database 11g : 11.2.0.2.0

I will cover the OPatch version in the later steps. Here we will concentrate only on oracle database version.

So from above two steps we have found that the operating system bit version is
x86_64 and database version is 11.2.0.2.0.

STEP 3: Now check in the patch advisory document what patch oracle has released for 11.2.0.2.0. You can find the patch advisory document for each quarter's patch.


STEP 4: Download the patch from my oracle support(meta link). While downloading make sure you are downloading the patch for the correct operating system bit version.
Here we have to downlaod the patch for operating system bit version
x86_64 and database version 11.2.0.2.0.


STEP 5. Move the downloaded zipped file into the server. And then unzip it using the appropriate unzip command into the server only.

STEP 6. Now you can unzip the file on your local system and open the read me file from it.

STEP 7: In the prerequisite section you can see the OPatch version required to apply this patch. It clearly mention if higher version of OPatch is needed or not. If so then download the OPatch and move it to the Oracle home. Make sure you rename or remove the old OPatch direcotry from the Oracle home. After this verify the new opatch version using lsinventory command. OPatch version will be changed from what was earlier. Now we are good to go.


STEP 8: Count the invalid object and make a note of it.


STEP 9: If listener is running from the home where we are go apply to patch then stop it otherwise no need to stop it. Many time it is running from Grid home. So no need to stop it if is running from Grid home.

STEP 10: If the server is being monitored by OEM grid control then put it into blackout.

STEP 11: Check the space into the mount point what oracle home is reffering to.

STEP 12: Shut down all the databases running from that home.

STEP 13: Go to the directory where you have moved and unzipped the patch:

[oracle@host1  tmp]$ cd p14841437_112020_Linux-x86-64
[oracle@host1 p14841437_112020_Linux-x86-64]$ ls -ltr
total 4
drwxr-xr-x 43 ralam0 ldap-users 4096 Feb 11  2013 14841437
[oracle@host1 p14841437_112020_Linux-x86-64]$ cd 14841437
[oracle@hsot1 14841437]$ ls -ltr
total 164
drwxr-xr-x 4 ralam0 ldap-users 4096 Feb 11  2013 11830776
drwxr-xr-x 4 ralam0 ldap-users 4096 Feb 11  2013 11830777
drwxr-xr-x 4 ralam0 ldap-users 4096 Feb 11  2013 12586486
drwxr-xr-x 4 ralam0 ldap-users 4096 Feb 11  2013 12586488
drwxr-xr-x 4 ralam0 ldap-users 4096 Feb 11  2013 12586489
drwxr-xr-x 4 ralam0 ldap-users 4096 Feb 11  2013 12586491
drwxr-xr-x 4 ralam0 ldap-users 4096 Feb 11  2013 12586492
drwxr-xr-x 4 ralam0 ldap-users 4096 Feb 11  2013 12586493
drwxr-xr-x 4 ralam0 ldap-users 4096 Feb 11  2013 12586494
drwxr-xr-x 4 ralam0 ldap-users 4096 Feb 11  2013 12586495
drwxr-xr-x 4 ralam0 ldap-users 4096 Feb 11  2013 12586496
drwxr-xr-x 4 ralam0 ldap-users 4096 Feb 11  2013 12846268
drwxr-xr-x 4 ralam0 ldap-users 4096 Feb 11  2013 12846269
drwxr-xr-x 4 ralam0 ldap-users 4096 Feb 11  2013 13386082
drwxr-xr-x 4 ralam0 ldap-users 4096 Feb 11  2013 13769501
drwxr-xr-x 4 ralam0 ldap-users 4096 Feb 11  2013 13769502
drwxr-xr-x 4 ralam0 ldap-users 4096 Feb 11  2013 13769503

STEP 14: Now issue the following command:

$opatch napply -skip_subset -skip_duplicate

     This command will show logs as below :

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


Interim patches (3) :

Patch  13528551     : applied on Thu Mar 22 05:19:12 CDT 2012
Unique Patch ID:  14454920
    Created on 6 Jan 2012, 05:04:26 hrs PST8PDT
    Bugs fixed:
      13528551

Patch  13499128     : applied on Thu Mar 22 05:19:05 CDT 2012
Unique Patch ID:  14454920
    Created on 6 Jan 2012, 04:58:55 hrs PST8PDT
    Bugs fixed:
    13499128

Patch  13466801     : applied on Thu Mar 22 05:19:00 CDT 2012
Unique Patch ID:  14454920
  Created on 6 Jan 2012, 04:50:15 hrs PST8PDT
    Bugs fixed:
      13466801

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

OPatch succeeded


STEP 15: Start up the database and run the catbundle command for each databases running under that home.

$cd $ORACLE_HOME/rdbms/admin
SQL>SQLPLUS “/ AS SYSDBA”
SQL> STARTUP
        SQL> @catbundle.sql cpu apply
        Below are the log of catbundle command
SQL> @?/rdbms/admin/catbundle.sql cpu apply
PL/SQL procedure successfully completed.
PL/SQL procedure successfully completed.
PL/SQL procedure successfully completed.
Generating apply and rollback scripts...
Check the following file for errors:
/u01/app/oracle/product/11.2.0/dbhome_          1/cfgtoollogs/catbundle/catbundle_CPU_IKBTEST1_GENERATE_2012Mar22_05_22 _13.log
Apply script: /u01/app/oracle/product/11.2.0/dbhome_ 1/rdbms/admin/catbundle_CPU_IKBTEST1_APPLY.sql
Rollback script: /u01/app/oracle/product/11.2.0/dbhome_ 1/rdbms/admin/catbundle_CPU_IKBTEST1_ROLLBACK.sql
PL/SQL procedure successfully completed.
Executing script file...
SQL> COLUMN spool_file NEW_VALUE spool_file NOPRINT
SQL> SELECT '/u01/app/oracle/product/11.2.0/dbhome_1/cfgtoollogs/catbundle/' || 'catbundle_CPU_' || name || '_APPLY_' || TO_CHAR(SYSDATE, 'YYYYMonDD_hh24 _mi_ss', 'NLS_DATE_LANGUAGE=''AMERICAN''') || '.log' AS spool_file FROM v $database;
            ------------------------------------------------------------------------------------------------------------
            ------------------------------------------------------------------------------------------------------------
            ------------------------------------------------------------------------------------------------------------
            ------------------------------------------------------------------------------------------------------------
SQL> SPOOL &spool_file
SQL> exec dbms_registry.set_session_namespace('SERVER')
PL/SQL procedure successfully completed.
SQL> ALTER SESSION SET current_schema = SYS;
Session altered.
SQL> PROMPT Updating registry...
Updating registry...
SQL> INSERT INTO registry$history
  2    (action_time, action,
  3     namespace, version, id,
  4     bundle_series, comments)
  5  VALUES
  6    (SYSTIMESTAMP, 'APPLY',
  7     SYS_CONTEXT('REGISTRY$CTX','NAMESPACE'),
  8     '11.2.0.3',
  9     1,
  10     'CPU',
  11     'CPUJan2012');
1 row created.
SQL>  COMMIT;
Commit complete.
SQL> SPOOL off
SQL> SET echo off
Check the following log file for errors:
/u01/app/oracle/product/11.2.0/dbhome_ 1/cfgtoollogs/catbundle/catbundle_CPU_IKBTEST1_APPLY_2012Mar22_05_22_ 14.log

STEP 16: Run the utlrp.sql script to validate the objects.

SQL>@utlrp.sql

STEP 17. Count the invalid object and make sure it is lesser or same than what it was in earlier count before patching.





2 comments: