8i | 9i | 10g | 11g | 12c | 13c | 18c | 19c | 21c | 23c | Misc | PL/SQL | SQL | RAC | WebLogic | Linux

Home » Articles » Misc » Here

Patching : Apply a Database Release Update (RU) to a New ORACLE_HOME

This article gives an example of applying a database Release Update (RU) to a new ORACLE_HOME for a simple single-instance Oracle database.

You should always check the patch notes before doing any patching. It's always possible some changes have been introduced that make the process differ from that presented here.

Related articles.

Assumptions

This article makes some assumptions.

Environment

Set up the environment. This includes the database software, OPatch and patch file names, and the paths.

export ORA_INVENTORY=/u01/app/oraInventory
export ORACLE_BASE=/u01/app/oracle
export SOFTWARE_DIR=/u01/software

# 19c
export OLD_ORACLE_HOME=${ORACLE_BASE}/product/19.0.0/dbhome_1
export NEW_ORACLE_HOME=${ORACLE_BASE}/product/19.16.0/dbhome_1
export DB_SOFTWARE="LINUX.X64_193000_db_home.zip"
export OPATCH_FILE="p6880880_190000_Linux-x86-64.zip"
export PATCH_FILE="p34133642_190000_Linux-x86-64.zip"
export PATCH_TOP=${SOFTWARE_DIR}/34133642

# 21c
export OLD_ORACLE_HOME=${ORACLE_BASE}/product/21.0.0/dbhome_1
export NEW_ORACLE_HOME=${ORACLE_BASE}/product/21.7.0/dbhome_1
export DB_SOFTWARE="LINUX.X64_213000_db_home.zip"
export OPATCH_FILE="p6880880_210000_Linux-x86-64.zip"
export PATCH_FILE="p34160444_210000_Linux-x86-64.zip"
export PATCH_TOP=${SOFTWARE_DIR}/34160444

Create the New ORACLE_HOME

We create a new ORACLE_HOME by doing a software-only install. Create the new ORACLE_HOME and unzip the base software into it.

mkdir -p ${NEW_ORACLE_HOME}
cd ${NEW_ORACLE_HOME}
unzip -oq ${SOFTWARE_DIR}/${DB_SOFTWARE}

Update OPatch in the new home.

cd ${NEW_ORACLE_HOME}
rm -Rf OPatch
unzip -oq ${SOFTWARE_DIR}/${OPATCH_FILE}

Unzip the release update.

cd ${SOFTWARE_DIR}
unzip -oq ${PATCH_FILE}

Install the Oracle software in the new home, applying the RU as part of the installation process. Notice we are referencing the NEW_ORACLE_HOME location in the runInstaller command, and we unset the ORACLE_HOME variable, just to be on the safe side.

unset ORACLE_HOME
cd ${NEW_ORACLE_HOME}

${NEW_ORACLE_HOME}/runInstaller -ignorePrereq -waitforcompletion -silent       \
    -applyRU ${PATCH_TOP}                                                      \
    -responseFile ${NEW_ORACLE_HOME}/install/response/db_install.rsp           \
    oracle.install.option=INSTALL_DB_SWONLY                                    \
    ORACLE_HOSTNAME=${ORACLE_HOSTNAME}                                         \
    UNIX_GROUP_NAME=oinstall                                                   \
    INVENTORY_LOCATION=${ORA_INVENTORY}                                        \
    SELECTED_LANGUAGES=en,en_GB                                                \
    ORACLE_HOME=${NEW_ORACLE_HOME}                                             \
    ORACLE_BASE=${ORACLE_BASE}                                                 \
    oracle.install.db.InstallEdition=EE                                        \
    oracle.install.db.OSDBA_GROUP=dba                                          \
    oracle.install.db.OSBACKUPDBA_GROUP=dba                                    \
    oracle.install.db.OSDGDBA_GROUP=dba                                        \
    oracle.install.db.OSKMDBA_GROUP=dba                                        \
    oracle.install.db.OSRACDBA_GROUP=dba                                       \
    SECURITY_UPDATES_VIA_MYORACLESUPPORT=false                                 \
    DECLINE_SECURITY_UPDATES=true

Run the root scripts as instructed.

# 19c
As a root user, execute the following script(s):
        1. /u01/app/oracle/product/19.16.0/dbhome_1/root.sh

# 21c
As a root user, execute the following script(s):
        1. /u01/app/oracle/product/21.7.0/dbhome_1/root.sh

We now have the newly patched home, so we are ready to patch the database.

Patch the Database

To patch the database we need to switch it to the new ORACLE_HOME and run the datapatch utility in the normal way.

Turn off all the services in the current ORACLE_HOME.

export ORACLE_SID=cdb1
export ORAENV_ASK=NO
. oraenv
export ORAENV_ASK=YES

dbshut ${ORACLE_HOME}

Edit the "/etc/oratab" file, setting the new home for the instance.

# 19c
#cdb1:/u01/app/oracle/product/19.0.0/dbhome_1:Y
cdb1:/u01/app/oracle/product/19.16.0/dbhome_1:Y

# 21c
#cdb1:/u01/app/oracle/product/21.0.0/dbhome_1:Y
cdb1:/u01/app/oracle/product/21.7.0/dbhome_1:Y

In previous releases we would need to copy the following files between the homes, but in 21c onward this is not necessary, as we are using read-only homes, so all the configuration files are no longer stored in the same place as the binaries.

# 19c
cp ${OLD_ORACLE_HOME}/dbs/*${ORACLE_SID}* ${NEW_ORACLE_HOME}/dbs/
cp ${OLD_ORACLE_HOME}/dbs/*${ORACLE_SID^^}* ${NEW_ORACLE_HOME}/dbs/

cp ${OLD_ORACLE_HOME}/network/admin/*.ora ${NEW_ORACLE_HOME}/network/admin/
sed -i -e "s|${OLD_ORACLE_HOME}|${NEW_ORACLE_HOME}|g" ${NEW_ORACLE_HOME}/network/admin/*.ora

Make sure we are using the new ORACLE_HOME.

export ORACLE_SID=cdb1
export ORAENV_ASK=NO
. oraenv
export ORAENV_ASK=YES

echo ${ORACLE_HOME}
/u01/app/oracle/product/21.7.0/dbhome_1
$

Start the listener.

lsnrctl start

Start the database, making sure all pluggable databases are open.

sqlplus / as sysdba <<EOF
startup;
alter pluggable database all open;
exit;
EOF

Run datapatch.

cd $ORACLE_HOME/OPatch
./datapatch -verbose

Recompile any invalid objects.

$ORACLE_HOME/perl/bin/perl \
    -I$ORACLE_HOME/perl/lib \
    -I$ORACLE_HOME/rdbms/admin \
    $ORACLE_HOME/rdbms/admin/catcon.pl \
    -l /tmp/ \
    -b postpatch_${ORACLE_SID}_recompile \
    -C 'PDB$SEED' \
    $ORACLE_HOME/rdbms/admin/utlrp.sql

Clean Up

If we have any additional environment files or scripts containing paths that include the ORACLE_HOME, they will need to be adjusted.

Clean up the patch software.

cd ${SOFTWARE_DIR}
rm -Rf ${DB_SOFTWARE}
rm -Rf ${PATCH_TOP}
rm -Rf ${OPATCH_FILE}
rm -Rf ${PATCH_FILE}
rm -Rf PatchSearch.xml

At some point we will need to remove the old ORACLE_HOME.

Check the Patch History

We can check the patch history by running the following command.

${ORACLE_HOME}/OPatch/opatch lsinventory

Rollback the Patch

To rollback the patch we need to switch it to the old ORACLE_HOME and run the datapatch utility in the normal way.

Shutdown the services run from the ORACLE_HOME.

dbshut ${ORACLE_HOME}

Edit the "/etc/oratab" file, setting the original home for the instance.

# 19c
cdb1:/u01/app/oracle/product/19.0.0/dbhome_1:Y
#cdb1:/u01/app/oracle/product/19.16.0/dbhome_1:Y

# 21c
cdb1:/u01/app/oracle/product/21.0.0/dbhome_1:Y
#cdb1:/u01/app/oracle/product/21.7.0/dbhome_1:Y

Make sure we are using the original ORACLE_HOME.

export ORACLE_SID=cdb1
export ORAENV_ASK=NO
. oraenv
export ORAENV_ASK=YES

echo ${ORACLE_HOME}
/u01/app/oracle/product/21.0.0/dbhome_1
$

Start the listener.

lsnrctl start

Start the database, making sure all pluggable databases are open.

sqlplus / as sysdba <<EOF
startup;
alter pluggable database all open;
exit;
EOF

Run datapatch.

cd $ORACLE_HOME/OPatch
./datapatch -verbose

Recompile any invalid objects.

$ORACLE_HOME/perl/bin/perl \
    -I$ORACLE_HOME/perl/lib \
    -I$ORACLE_HOME/rdbms/admin \
    $ORACLE_HOME/rdbms/admin/catcon.pl \
    -l /tmp/ \
    -b postpatch_${ORACLE_SID}_recompile \
    -C 'PDB$SEED' \
    $ORACLE_HOME/rdbms/admin/utlrp.sql

Pros and Cons

Pros:

Cons:

For more information see:

Hope this helps. Regards Tim...

Back to the Top.