Opatch


Set enviroment
export PATH=$PATH:<GI_HOME>/OPatch

To see the version
cd $ORACLE_HOME/OPatch

./opatch lsinventory

To Update Opatch (Patch 6880880) 
1# Backup ORACLE_HOME
tar -czvf ORACLE_BKUP.tgz $ORACLE_HOME

1# download the last one -link

2# To backup $ORACLE/OPatch
cd $ORACLE
cp -rp OPatch OPatch_back
./opatch version

3# unzip file.zip -d $ORACLE/OPatch
./opatch version

One-off Patch Conflict Detection and Resolution

In case you are applying the patch #GRID_HOME/OPatch/opatchauto apply <UNZIPPED_PATCH_LOCATION>/25901062 -analyze -ocmrf <ocm response file>
In case you are rolling back the patch #GRID_HOME/OPatch/opatchauto rollback <UNZIPPED_PATCH_LOCATION>/25901062 -analyze

opatchauto for GI

as a root or with sudo

To create response file for OCM
$ORACLE_HOME/OPatch/ocm/bin/emocmrsp  -no_banner -output <specify_the_location>/file.rsp

to run as silent
opatch apply -silent -ocmrf /u02/ocm.rsp

User below for CPU/SPU apply
opatch napply -silent -ocmrf /u02/ocm.rsp

Use below for  PSU apply
opatch apply -silent -ocmrf /u02/ocm.rsp

GRID patching command changed sightly as below 
opatch auto -ocmrf /u02/ocm.rsp


* creates the response in location specified by the parameter "-output"
* running without "-output <specify_the_location>/file.rsp"  creates the file in current directory with default name(ocm.rsp)
note: ocmrf if no more necessary


To patch the GI home and all Oracle RAC database homes of the same version:
# opatchauto apply <UNZIPPED_PATCH_LOCATION>/25901062 -ocmrf <ocm response file>

To patch only the GI home:
# opatchauto apply <UNZIPPED_PATCH_LOCATION>/25901062 -oh <GI_HOME> -ocmrf <ocm response file>

To patch one or more Oracle RAC database homes:
# opatchauto apply <UNZIPPED_PATCH_LOCATION>/25901062 -oh <oracle_home1_path>,<oracle_home2_path> -ocmrf <ocm response file>

To roll back the patch from the GI home and each Oracle RAC database home:
# opatchauto rollback <UNZIPPED_PATCH_LOCATION>/25901062 

To roll back the patch from the GI home:
# opatchauto rollback <UNZIPPED_PATCH_LOCATION>/25901062 -oh <path to GI home>  

To roll back the patch from the Oracle RAC database home:
# opatchauto rollback <UNZIPPED_PATCH_LOCATION>/25901062 -oh <oracle_home1_path>,<oracle_home2_path> 

Patch Installation
Case 1: 
GI Home and the Database Homes that are not shared and ACFS file system is not configured.
Case 2: 
GI Home is not shared, Database Home is shared, ACFS may be used.
  1. Patching Oracle Restart Home.
  2. Patching Oracle RAC Database Homes.
  3. Patching GI Home alone.
  4. Patching a software only GI Home installation or before the GI Home is configured.
Patching Oracle RAC Database Homes and GI Together

Case 1: 
GI Home and the Database Homes that are not shared and ACFS file system is not configured.

<GI_HOME>/OPatch/opatchauto apply <UNZIPPED_PATCH_LOCATION>/25901062 -ocmrf <ocm response file>

Case 2: 
GI Home is not shared, Database Home is shared, ACFS may be used.
  1. From the Oracle database home, make sure to stop the Oracle RAC databases running on all nodes. As the database home owner execute:
    $ <ORACLE_HOME>/bin/srvctl stop database –d <db-unique-name>
    
  2. On the 1st node, unmount the ACFS file systems. See My Oracle Support Document 1494652.1 for unmounting ACFS file systems.
  3. On the 1st node, apply the patch to the GI Home using the opatchauto command. As root user, execute the following command:
    # <GI_HOME>/OPatch/opatchauto apply <UNZIPPED_PATCH_LOCATION>/25901062 -oh <GI_HOME> -ocmrf <ocm response file>
    
  4. If the message, "A system reboot is recommended before using ACFS” is shown, then a reboot must be issued before continuing. Failure to do so will result in running with an unpatched ACFS\ADVM\OKS driver.
  5. On the 1st node, remount ACFS file systems. See My Oracle Support Document 1494652.1 for mounting ACFS file systems.
  6. On the 1st node, apply the patch to the Database home using the opatchauto command. Since the Database home is shared, this operation will patch the Database home across the cluster. Note that a USM only patch cannot be applied to a database home. As root user, execute the following command:
    # <GI_HOME>/OPatch/opatchauto apply <UNZIPPED_PATCH_LOCATION>/25901062 -oh <ORACLE_HOME> -ocmrf <ocm response file>
    
  7. On the 1st node only, restart the Oracle instance, which you have previously stopped in Step 1. As the database home owner execute:
    $ <ORACLE_HOME>/bin/srvctl start instance –d <db-unique-name> -n <nodename>
    
  8. On the 2nd (next) node, unmount the ACFS file systems. See My Oracle Support Document 1494652.1 for unmounting ACFS file systems.
  9. On the 2nd node, apply the patch to GI Home using the opatchauto command. As root user, execute the following command:
    # <GI_HOME>/OPatch/opatchauto apply <UNZIPPED_PATCH_LOCATION>/25901062 -oh <GI_HOME> -ocmrf <ocm response file>
    
  10. If the message, "A system reboot is recommended before using ACFS” is shown, then a reboot must be issued before continuing. Failure to do so will result in running with an unpatched ACFS\ADVM\OKS driver.
  11. On the 2nd node, running the opatchauto command in Step 9 will restart the stack.
  12. On the 2nd node, remount ACFS file systems. See My Oracle Support Document 1494652.1 for mounting ACFS file systems.
  13. On the 2nd node only, restart the Oracle instance, which you have previously stopped in Step 1. As the database home owner execute:
    $ <ORACLE_HOME>/bin/srvctl start instance –d <db-unique-name> -n <nodename>
    
  14. Repeat Steps 8 through 13 for all remaining nodes of the cluster.