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

Home » Articles » Misc » Here

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

This article gives an example of applying a database Release Update (RU) to an existing 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 OPatch and patch file names, and the paths. Notice how OPatch has been added to the PATH environment variable.

export SOFTWARE_DIR=/u01/software

# 19c
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 OPATCH_FILE="p6880880_210000_Linux-x86-64.zip"
export PATCH_FILE="p34160444_210000_Linux-x86-64.zip"
export PATCH_TOP=${SOFTWARE_DIR}/34160444

export PATH=${ORACLE_HOME}/OPatch:${PATH}

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

Apply the Patch

Keep a copy of the existing OPatch, and unzip the latest version of OPatch.

cd ${ORACLE_HOME}
mv OPatch OPatch.`date +"%Y"-"%m"-"%d"`
unzip -oq ${SOFTWARE_DIR}/${OPATCH_FILE}

Unzip the patch software.

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

Shutdown the services run from the ORACLE_HOME.

dbshut ${ORACLE_HOME}

Apply the patch.

cd ${PATCH_TOP}
opatch prereq CheckConflictAgainstOHWithDetail -ph ./
opatch apply -silent

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

Clean up the patch software.

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

Check the Patch History

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

opatch lsinventory

Rollback the Patch

Shutdown the services run from the ORACLE_HOME.

dbshut ${ORACLE_HOME}

Rollback the patch.

# 19c
opatch rollback -id 34133642 -silent

# 21c
opatch rollback -id 34160444 -silent

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.