Thursday, October 18, 2012

HOW TO APPLY ORACLE PATCH

================================================================================
HOW TO APPLY PATCH on a DATABASE
================================================================================
1) Make a note of the output of below command:
   ps -ef|grep pmon
   ps -ef|grep tns
2) Login to database and take the snaps of all the invalid objects as mention below:
   spool invalid_Object_pre.log
   set linesize 256
   set pagesize 256
   col object_name for a30
   select name from v$database;
   select owner, object_name, object_type from dba_objects where status <>'VALID' order by owner, object_name;
   spool off
3) Set OEM Agent blackouts on the server as follows :
 a) cd /prod01/app/oracle/product/AGENT/agent10g/bin
 b) ./emctl start blackout servername_date_time_maint-nodelevel
4) Stop OEM Agent on the database server as follows:
        a) cd /prod01/app/oracle/product/AGENT/agent10g/bin/
        b) ./emctl stop agent

5)  Shutdown all the databases under this ORACLE_HOME with below command;
  
   SHUTDOWN IMMEDIATE

6) stop all the LISTENER  under this ORACLE_HOME
7) Cross-Check the database and Listener are down with below command:
   ps -ef|grep pmon
   ps -ef|grep tns
8)Take the Backup of global inventory (oraInventory) and local inventory as menetion below:
To find global inventory
cat /etc/oraInst.loc
or
cat /var/opt/oracle/oraInst.loc
go to that path and cd ..
Ex:
tar -cvf oraInventory_today'sdate oraInventory
Each ORACLE_HOME has its own inventory, its called local inventory
Ex:
cd /opt/oracle/product/10.2.0.4
tar -cvf inventory_today'sdate inventory
9)Go to below Location:
        uname -a (Find the server details)
Download the patch from Oracle site  to ORACLE_HOME

To know the bit (whether 64 or 32) use the following command
$ getconf KERNEL_BITS  or getconf -a | grep KERNEL
 
unzip p9352224_92080_AIX64-5L.zip
10)Apply the Patch as mention below:
fuser -cu $ORACLE_HOME
 (A)  export PATH=$PATH:$ORACLE_HOME/OPatch
          export TMP=$ORACLE_HOME/tmp   
          export TMPDIR=$TMP
     export JDK_HOME=$ORACLE_HOME/jdk -- for upto 9i
     export PATH=$PATH:$JDK_HOME/bin:. -- -- for upto 9i
 (B) Check the which opatch version and opatch is pointing to, as mention below:
     opatch version (It should 1.0.0.0.57 or higher)
     which opatch   (It Should be /prod01/app/oracle/product/9.2/OPatch/opatch)
 (C) Apply the patch with below command:
     opatch apply  or opatch napply -skip_subset -skip_duplicate
11) Crosscheck the Patch is applied or not with below command:
    opatch lsinventory
12) startup the Database
    STARTUP
 cd $ORACLE_HOME/rdbms/admin
 sqlplus /nolog
 CONNECT / AS SYSDBA
 STARTUP
 @catbundle.sql psu apply
shutdown immediate
startup
++++  REPEAT the same steps for all databases. ++++++
IMP : Check the status of compoents after patching :
select COMP_NAME,STATUS from dba_registry;

13) Crosscheck the Patch is register in the database with below command:
    SELECT * from REGISTRY$HISTORY;
14) Cross check the invalid objects as mention below:
   spool invalid_Object_Post.log
   set linesize 256
   set pagesize 256
   col object_name for a30
   select name from v$database;
   select owner, object_name, object_type from dba_objects where status <>'VALID' order by owner, object_name;
   spool off
15) If the Output of invalid_Object_Post.log >(greater) than the output of invalid_Object_Pre.log then execute the below cmd:
    @$ORACLE_HOME/rdbms/admin/utlrp.sql;
    select owner, object_name,object_type from dba_objects where status <>'VALID' order by owner, object_name;
16) start the all listeners
17) Start OEM Agent on the database server as follows:
        a) cd /prod01/app/oracle/product/AGENT/agent10g/bin/
   b) ./emctl start agent
18) Remove OEM Agent blackouts on the server as follows:
 a) cd /prod01/app/oracle/product/AGENT/agent10g/bin/
 b) ./emctl stop blackout servername_date_time_maint-nodelevel.
19) Logout from the Server.

No comments:

Post a Comment

Share your knowledge it really improves, don't show off...