2 Binary Patching Using OPatch

OPatch is a utility that allows you to apply and/or roll back interim patches to Oracle's software. The manual process of applying a patch is called binary patching. For binary patching, you can use the OPatch utility to:

Note:

Always refer to the patch README for any special instructions before you apply a patch.

Oracle recommends that you back up the ORACLE_HOME before any patch operation. You can back up the ORACLE_HOME using your preferred method. You can use any method, such as zip, cp -r, tar, and cpio to compress the ORACLE_HOME.

2.1 Obtain the Latest OPatch Utility

You should use the version of OPatch that supports the ORACLE_HOME release. For example, if you are patching a 12.0.1 Oracle Home, then use OPatch version 12.0.1. If the Oracle Home is version 11.2 , then use OPatch version 11.2.

Oracle recommends that you use the latest released OPatch for 12.1 releases, which is available for download from My Oracle Support (patch 6880880). Select the ARU link for the 12.1.0.1.0 release.

https://updates.oracle.com/download/6880880.html

You can also view the support document "OPatch - Where Can I Find the Latest Version of OPatch?" (Doc ID 224346.1). This document contains a link to the instructional video "Downloading the OPatch Tool from MOS."

2.2 Using OPatch

Before you use the OPatch command and available options, you must check that OPatch prerequisites have been fulfilled.

2.2.1 Patching Workflow

Using the OPatch utility to patch your product (e.g., Fusion Middleware) home typically consists of the following steps:

  1. Setting the ORACLE_HOME Environment Variable

  2. Determining What is Installed On Your System

  3. Ensuring Patch Application Prerequisites are Met

  4. Applying a Patch

  5. Running Post-apply Checks

2.2.1.1 Setting the ORACLE_HOME Environment Variable

OPatch verifies whether the product home is present. You must ensure that the ORACLE_HOME environment variable is set to the product home of the product you are trying to patch. Check your respective vendor documentation for the details on how to set the environment variable.

Note:

Oracle Universal Installer binaries and inventories must be present in the home to be patched.

Other environment variables used include:

  • OPATCH_DEBUG — Boolean setting that enables additional debugging information that can be used by software developers.

  • PATH — Product home path information.

Note:

Adding $ORACLE_HOME/OPatch to the $PATH makes it more convenient to execute the OPatch commands from any directory.

2.2.1.2 Determining What is Installed On Your System

The next step is to determine what is already installed on your system. For this, you use the opatch lsinventory command with either the patch or patch_id options.

Example 2-1 lsinventory Command

opatch lsinventory

For more information about this command, see "lsinventory."

2.2.1.3 Ensuring Patch Application Prerequisites are Met

After you have determined that your system configuration is appropriate for the patches you wish to apply, it is advisable to view the operations OPatch will perform before performing the patch application to help determine whether all system prerequisites are met before applying the patch. For this, you use the OPatch -report option to print all patch application actions OPatch will perform without actually executing the actions.

Example 2-2 report Option

opatch apply -report

For more information about the -report option, see "OPatch Syntax and Commands."

2.2.1.4 Applying a Patch

Once you have determined that the patch can be applied to your system successfully, you can now use OPatch to apply the patch. For this, you use the OPatch apply command.

Example 2-3 apply Command

opatch apply /tmp/patch/12345678

For more information about this command, see"apply."

2.2.1.5 Running Post-apply Checks

After you have applied the patch to your system, you should perform a final check to ensure all patches have been successfully applied. For this, you again use the OPatch lsinventory command with either the patch or patch_id options. For more information about this OPatch command, see "lsinventory."

2.3 Applying a Patch Set Update (PSU)

Once you have verified the prerequisite checks, use OPatch to apply a patch:

The OPatch utility is located in the $Oracle_Home/OPatch directory. You can run it with various commands and options. See OPatch Syntax and Commands, for a complete list of command options available with OPatch.

2.3.1 Applying a Single Patch

You apply a single patch following the generic patching workflow discussed earlier:

  1. Obtain the Latest OPatch Utility

  2. Setting the ORACLE_HOME Environment Variable

  3. Determining What is Installed On Your System

  4. Ensuring Patch Application Prerequisites are Met

  5. Applying a Patch

  6. Running Post-apply Checks

Once you have downloaded the patch, you can apply it (step 5) using the following command:

# opatch apply <patch directory location>/<patch ID>

For example:

# opatch apply /tmp/patch/12345678

2.3.2 Apply Multiple Patches Using a Text File

You can create a text file containing the location of all patches you need to apply. Use OPatch to reference the file and apply the patches:

  1. Create the text file of the patch location. The entry should have each patch location on a separate line:

    vi patches.txt
    /tmp/patchlocation1/12345678
    /tmp/patchlocation2/12365478
    /scratch/patchlocation3/32165487
    

    Save your changes.

  2. Apply the patches with OPatch:

    # opatch napply - -phBaseFile <location of text file>
    

    For example:

    #opatch napply - -phBaseFile /tmp/patches/patches.txt
    

2.4 Patch Conflict Detection and Resolution

OPatch detects and reports any conflicts encountered when applying a patch with a previously applied patch. The patch application fails in case of conflicts. You can use the -force option of OPatch to override this failure. If you specify -force, the installer firsts rolls back any conflicting patches and then proceeds with the installation of the desired patch. Using -force means that you will likely lose some bug fixes, that are causing the conflict, in exchange for getting the incoming patch to be applied.

You may experience a bug conflict and might want to remove the conflicting patch. This process is known as patch rollback. During patch installation, OPatch saves copies of all the files that were replaced by the new patch before the new versions of these files are loaded, and stores them in $ORACLE_HOME/.patch_storage. These saved files are called rollback files and are key to making patch rollback possible. When you roll back a patch, these rollback files are restored to the system. If you have a complete understanding of the patch rollback process, you should only override the default behavior by using the -force flag. To roll back a patch, execute the following command:

$ OPatch/opatch rollback -id <Patch_ID>

A patch conflict occurs when multiple fixes in different patches touch the same files but have not been tested together as a single entity. OPatch and OPatchAuto help you avoid these conflicts by identifying these conditions. When patch conflicts occur and you are unable to resolve them using documented support procedures, MOS then becomes the go-to source for technical assistance. Conflict resolution may entail filing a Service Request and obtaining a Merge Label Request (MLR) patch to overcome a patching issue. Once a solution has been found, you use OPatch to apply the fixed patch.