Search This Blog

Tuesday, February 21, 2012

Applying OPATCH

OPATCH:


OPatch is a Database Patch.
OPatch is applied at the database level.


OPatch is the Oracle database's Interim (one-off) Patch Installer.
If OPatch is not installed into your Oracle Home ($ORACLE_HOME/OPatch), you may need to download it from Metalink and install it yourself.


To check whether the OPatch is already installed or no.

cd $ORACLE_HOME/OPatch

Please download latest OPatch Tool and extract the RDBMS Oracle home.

Eg: $opatch -lsinventory

This is command will show existing patch

Check opatch version using

Eg: $opatch -v

$opatch -help
Invoking OPatch 10.2.0.4.2

Oracle Interim Patch Installer version 10.2.0.4.2
Copyright (c) 2007, Oracle Corporation.  All rights reserved.


Usage: opatch [ -help ] [ -r[eport] ] [ command ]

   command := apply
                       lsinventory
                       napply
                       nrollback
                       rollback
                       query
                       version
                       prereq
                       util

<global_arguments> := -help       Displays the help message for the command.
                       -report     Print the actions without executing.

 example:
   'opatch -help'
   'opatch apply -help'
   'opatch lsinventory -help'
   'opatch napply -help'
   'opatch nrollback -help'
   'opatch rollback -help'
   'opatch prereq -help'
   'opatch util -help'

OPatch succeeded.




Pre-checks before apply opatch:

CHEK1: DB and Listener both must be down as opatch will update your current ORACLE_HOME with patches.
In single instance its not possible.but for RAC instance its possible. In RAC there will be two separate oracle home and two separate instances running once

instance on each oracle_home

use this command:

opatch napply -skip_subset -skip_duplicate -local -oh $ORACLE_HOME


using -local parameter and -oh $ORACLE_HOME --> means this patch session will only apply patch  to current sourced ORACLE_HOME.

Export the following environmental file:

$ export ORACLE_HOME=/UAT/app/oracle
$ export PATH=$PATH:$ORACLE_HOME/OPatch:$ORACLE_HOME/bin
$ export OBJECT_MODE=32_64

$cd patch/

Extract the Following OPatch.
p1234567_10203_LINUX.zip
p2345678_10203_LINUX.zip

1234567
2345678

Then Go to patch Directory and apply the Opatch.
$ cd 1234567/


$ opatch apply



Steps for applying opatch:

STEP1: check the database status.


select name,open_mode,database_name,created,log_mode,platform_name from v$database;


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

STEP2: Check the object's invalid.

SELECT owner,COUNT(*) FROM dba_objects WHERE status = 'INVALID' GROUP BY owner;


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

STEP3: count the invalid object's.

select count(*) from dba_objects WHERE status ='INVALID';

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

STEP4: Take backup of invalid's


create table bk_inv_ as select * from dba_objects where status='INVALID';
-------------------------------


STEP5: check opatch version using


$opatch -v

if opatch version is not compatible check the read-me file and download the latest version and uncompress in $ORACLE_HOME.
--------------------------------


STEP6: check oraInst.loc file pointing to your current $ORACLE_HOME or not.



$cat /etc/oraInst.loc

inventory_loc=/u01/app/oracle/10.2.0/GlobalOraInv
inst_group=dba

if your server have more then one $ORACLE_HOME then comment the other $ORACLE_HOME and uncomment the current $ORACLE_HOME inventory must point to the current

$ORACLE_HOME which is getting patched.
----------------------------------


STEP7: check free space on $ORACLE_HOME

df -h $ORACLE_HOME

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


STEP8: chek the utilities like

which ld
which ar
which make
etc as per readme file.

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

STEP9: unzip the patch

unzip -d /loc_unzip p.zip

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

STEP10: Go the patch directory

cd /loc_2_unzip/patch_number

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

STEP11: Bring down the listner.
sql> shut immediate
LSNRCTL stop LISTNER

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


STEP12
: Bring down the database
Shutdown immediate.

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

STEP13: export opatch
export PATH=$PATH:$HOME:$ORACLE_HOME/OPatch:/bin

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

STEP14: Start the patch
opatch napply -skip_subset -skip_duplicate

for RAC database then database can be up as it may be having more then one instance
so you can bring down one instance and listener and apply the patch and open it and then do the same on another node.
like this db will be up and no user will face issue in outage also.

to apply opatch in RAC instance
opatch napply -skip_subset -skip_duplicate -local -oh $ORACLE_HOME

when using -local parameter and
-oh $ORACLE_HOME this means this patch session will only apply patch to current ORACLE_HOME only.

--------------------------------------------------------
. All-Node Patch

. Shutdown all Oracle instances on all nodes
. Apply the patch to all nodes
. Bring all nodes up

. Minimum downtime

. Shutdown the Oracle instance on node 1
. Apply the patch to the Oracle instance on node 1
. Shutdown the Oracle instance on node 2
. Apply the patch to the Oracle instance on node 2
. Shutdown the Oracle instance on node 3
. At this point, instances on nodes 1 and 2 can be brought up
. Apply the patch to the Oracle instance on node 3
. Startup the Oracle instance on node 3

. (no downtime)

. Shutdown the Oracle instance on node 1
. Apply the patch to the Oracle instance on node 1
. Start the Oracle instance on node 1
. Shutdown the Oracle instance on node 2
. Apply the patch to the Oracle instance on node 2
. Start the Oracle instance on node 2
. Shutdown the Oracle instance on node 3
. Apply the patch to the Oracle instance on node 3
. Start the Oracle instance on node 3
---------------------------------------

STEP15: Once patch installation is completed need to do post patching steps.

a) starup the instance
startup

b) Loading modified sqlfiles into the database.
@$ORACLE_HOME/rdbms/admin/catbundle.sql cpu apply

to check the logs generated
catbundle_CPU__APPLY_.log
catbundle_CPU__GENERATE_.log

c) Recompiling Views in the Database
shutdown immediate
startup upgrade
@$ORACLE_HOME/cpu/view_recompile/view_recompile_jan2008cpu.sql
shutdown immediate
startup

If it is a RAC instance.
shutdown
startup nomount
alter database set cluster database=false scope=spfile;
shutdown
startup upgrade
@?/cpu/view_recompile/view_recompile_jan2008cpu.sql
shutdown
startup
alter database set cluster database=true scope=spfile;

restart the database.
cd $CRS_HOME/bin
srvctl start database -d

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


STEP16: If any invalid objects were reported, run the utlrp.sql script as follows


SELECT owner,COUNT(*) FROM dba_objects WHERE status = 'INVALID' GROUP BY owner;


select count(*) from dba_objects WHERE status ='INVALID';

if any new invalids seen then again take backup of invalid objects and compile it.

create table bk_inv_ as select * from dba_objects where status='INVALID';

@?/rdbms/admin/utlrp.sql --- to compile the invalid objects.

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

STEP17: Confirm that patch has been applied successfully or not at db level also.


post_patch.sql
--------------
col action_time for a40
col action for a15
col namespace for a15
col version for a15
col comments for a40
set pages 1000
set lines 170
select * from registry$history;
-----------------------------------


Reference:
------------

OPatch documentation list
Meta-link ID: 293369.1

4 comments:

  1. Can you describe the RAC steps id details like--

    For no downtime When we are bringing the database, are we going to set the cluster database parameter "false" and then shut instance 1.

    ReplyDelete
    Replies
    1. Oracle Apps Help: Applying Opatch >>>>> Download Now

      >>>>> Download Full

      Oracle Apps Help: Applying Opatch >>>>> Download LINK

      >>>>> Download Now

      Oracle Apps Help: Applying Opatch >>>>> Download Full

      >>>>> Download LINK Qs

      Delete
  2. I was surfing the Internet for information and came across your blog. I am impressed by the information you have on this blog. It shows how well you understand this subject. NIW

    ReplyDelete
  3. Oracle Apps Help: Applying Opatch >>>>> Download Now

    >>>>> Download Full

    Oracle Apps Help: Applying Opatch >>>>> Download LINK

    >>>>> Download Now

    Oracle Apps Help: Applying Opatch >>>>> Download Full

    >>>>> Download LINK Bd

    ReplyDelete