Learn to patch the way God intended (S1E3)

In the previous episode we showed how to apply out-of-place patches, a technique full of advantages, especially the minimal suspension of the service, but what happens if we have to apply the patch on multiple servers?

Of course we can apply the known procedure, but repeating the steps over and over again does not seem to be very efficient, and indeed it is not.

Fortunately, it is possible to optimize the procedure, taking the advantages of out-of-place patching to the limit, as shown below.

Gold Image to the rescue

What if instead of installing the base software and applying the required patches over and over again, we simply install the patched software as we need it, saving time and effort?

Well this is possible and is known as Gold Image, let’s see how it is created.

Creation of Oracle Home

A directory is created which will then be associated with an Oracle Home called DBTemp.

$ mkdir /u01/app/oracle/19.0.0/db_1

1

2

Oracle Database Installation

Unzip the Oracle Database 19c base software in the newly created directory.

$ export DB_HOME=/u01/app/oracle/19.0.0/db_1
$ export STAGE=/stage

$ unzip -oq ${STAGE}/LINUX.X64_193000_db_home.zip -d ${DB_HOME}
$ rm -rf ${DB_HOME}/OPatch
$ unzip -oq ${STAGE}/p6880880_190000_Linux-x86-64.zip -d ${DB_HOME}

After this we have the Oracle Database 19.3 binaries in the new directory.

Patching the new Oracle Home

The following patches are applied:

36233263 database release update 19.23.0.0.0
36199232 ojvm release update 19.23.0.0.0
36195566 jdk bundle patch 19.0.0.0.240416
36701173 database mrp 19.23.0.0.240618
36420641 datapump bundle patch 19.23.0.0.0
$ ${DB_HOME}/runInstaller -silent -printtime \
-waitforcompletion -ignorePrereqFailure \
ORACLE_HOME_NAME="DBTemp" -applyRU ${STAGE}/36233263 \
-applyOneOffs ${STAGE}/36199232,${STAGE}/36195566,${STAGE}/36420641 \
-responseFile ${DB_HOME}/install/response/db_install.rsp \
INVENTORY_LOCATION=/u01/app/oraInventory \
UNIX_GROUP_NAME=oinstall \
ORACLE_BASE=/u01/app/oracle \
oracle.install.option=INSTALL_DB_SWONLY \
oracle.install.db.InstallEdition=EE \
oracle.install.db.OSDBA_GROUP=dba \
oracle.install.db.OSBACKUPDBA_GROUP=backupdba \
oracle.install.db.OSDGDBA_GROUP=dgdba \
oracle.install.db.OSKMDBA_GROUP=kmdba \
oracle.install.db.OSRACDBA_GROUP=racdba \
oracle.install.db.rootconfig.executeRootScript=false

$ opatch napply ${STAGE}/36701173 -oh ${DB_HOME} -silent

$ sudo /u01/app/oracle/19.0.0/db_1/root.sh
After this we have the Oracle Home DBTemp containing the Oracle Database 19.23 binaries.

3

4

Gold Image creation

As a final step, we create the Gold Image based on the Oracle Home that we have already patched.

$ ${DB_HOME}/runInstaller \
-silent \
-createGoldImage \
-destinationLocation \
${STAGE}/goldImages \
-name db_home_19_23.zip

The final result is a zip file with the contents of the Oracle Home DBTemp, which we can keep in a shared directory with NFS, for use in the patching of all servers with Oracle Database.

$ ls -lt /stage/goldImages
total 27643584
drwxrwxr-x  2       4096 May 21 15:52 .
drwxrwxr-x 27       4096 Jul 15 14:28 ..
-rw-r--r--  1 2960756437 May 21 19:06 db_home_19_23.zip
-rw-r--r--  1 4251067464 May 21 17:52 grid_home_19_23.zip
-rw-r--r--  1 2920473198 Feb  3 14:31 db_home_19_22.zip
-rw-r--r--  1 4029564670 Feb  3 13:23 grid_home_19_22.zip

Out-of-place patching with Gold Image

If you haven’t done it yet, I recommend you to read first the steps to apply an out-of-place patch, for a better understanding of what is coming, and then come back. Now that we have a Gold Image, we can replace steps 3 and 4 of that procedure with the following:

Copying from Gold Image

Unzip the patched Oracle Database 19c software, contained in the Gold Image, in the newly created directory.

$ export DB_HOME=/u01/app/oracle/19.0.0/db_2
$ export STAGE=/stage

$ unzip -oq ${STAGE}/goldImages/db_home_19_23.zip -d ${DB_HOME}

1

2

Registering the new Oracle Home

We proceed to compile the binaries and register the Oracle Home DBHome2 in the inventory.

$ ${DB_HOME}/runInstaller -silent -printtime \
-waitforcompletion -ignorePrereqFailure \
ORACLE_HOME_NAME="DBHome2" \
-responseFile ${DB_HOME}/install/response/db_install.rsp \
INVENTORY_LOCATION=/u01/app/oraInventory \
UNIX_GROUP_NAME=oinstall \
ORACLE_BASE=/u01/app/oracle \
oracle.install.option=INSTALL_DB_SWONLY \
oracle.install.db.InstallEdition=EE \
oracle.install.db.OSDBA_GROUP=dba \
oracle.install.db.OSBACKUPDBA_GROUP=backupdba \
oracle.install.db.OSDGDBA_GROUP=dgdba \
oracle.install.db.OSKMDBA_GROUP=kmdba \
oracle.install.db.OSRACDBA_GROUP=racdba \
oracle.install.db.CLUSTER_NODES=${NODE1} \
oracle.install.db.rootconfig.executeRootScript=false

$ sudo /u01/app/oracle/19.0.0/db_2/root.sh
With this we have everything ready to continue with the out-of-place patching procedure, from step 5 onwards.

Conclusions

Preparing each new Oracle Home for an out-of-place patch, depending on the number of patches considered, can take 20 minutes or more, but thanks to the previous work of preparing a Golden Image it can take as little as a couple of minutes!

At this point, after all you have learned, it should be clear that out-of-place patching with Golden Image is the winning combination: minimum software setup time and minimum service suspension.

If you want to simplify tasks and reduce time even further, you can automate all these steps, for example by shell scripting, or with something a bit more sophisticated such as creating Ansible playbooks.

With this episode let’s end the first season, but there is still a lot to explore, for example: how to patch Grid Home, how to patch Oracle RAC, so stay tuned for the second season!

Did you find this article interesting, did you have any doubts, do you want to suggest a topic to cover, leave me your comments or contact me me right now!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Related Posts

Learn how to resolve and avoid the ORA-01017 error when you have Oracle Data Guard with wallet implemented.
Learn how to identify the row involved in the occurrence of the wait even "enq: TX - row lock contention"
Learn how to resolve the CRS-2304 GPnP profile signature verification failed error when starting an 11.2 database on a 19c cluster.

Need Help?

Fill in these details and I will be in touch as soon as possible.