How to install a release patch on database 12.1 or 12.2

The installation of oracle database patches is an operation not to be taken for granted. Unlike other systems or subsystems it is necessary to perform a series of steps manually.

Below there is the complete list of commands and an example for apply a patch called “release” (that includes the correction of many bugs without introducing substantial changes in performance) on a 12.2 database in an Oracle Linux 7.5 environment

Here’s how to install a release patch on 12.1 or 12.2 database:

#STEP1: Download patches 
 https://support.oracle.com
 - How To Download And Install The Latest OPatch(6880880) Version (Doc ID 274526.1) 
    (https://updates.oracle.com/download/6880880.html)
 - Oracle Database (RDBMS) Releases Support Status Summary (Doc ID 161818.1)

#STEP2: Setting envs 
export ORACLE_BASE=/oracle
export ORACLE_HOME=$ORACLE_BASE/product/12.2
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$PATH
export ORACLE_SID=orcl

#STEP3: Close database
lsnrctl stop
sqlplus -s / as sysdba <<EOF
shutdown immediate
exit
EOF

#STEP4: Backup 
mkdir /oracle/backup/

## Backup $ORACLE_HOME 
tar -czvf /oracle/backup/oracle_home.tar.gz $ORACLE_HOME > /oracle/backup/oracle_home.tar.log

## Backup Database 
rman target / <<EOF 
startup mount;
run {
backup database format '/oracle/backup/rman_db_%t_set%s_piece%p_dbid%I';
backup current controlfile format '/oracle/backup/rman_cntl_%t_set%s_piece%p_dbid%I';
backup spfile format '/oracle/backup/rman_spf_%t_set%s_piece%p_dbid%I';
}
shutdown immediate;
exit
EOF

#STEP5: Update OPatch
cd $ORACLE_HOME
mv OPatch OPatch.old
unzip /oracle/software/p6880880_180000_Linux-x86-64.zip -d $ORACLE_HOME
opatch version 
opatch lsinv

#STEP6: Update $ORACLE_HOME
unzip /oracle/software/p27674384_122010_Linux-x86-64.zip -d /oracle/software/
cd /oracle/software/27674384
opatch prereq CheckApplicable -oh $ORACLE_HOME -ph /oracle/software/27674384
opatch apply
opatch lspatches

#STEP7: Open database
lsnrctl start
sqlplus -s / as sysdba <<EOF
startup
exit
EOF
 
#STEP8: Post Patches
$ORACLE_HOME/OPatch/datapatch -prereq
$ORACLE_HOME/OPatch/datapatch -verbose
sqlplus -s / as sysdba << EOF
@$ORACLE_HOME/rdbms/admin/utlrp.sql 
exit
EOF
sqlplus -s / as sysdba << EOF
SET LINESIZE 160
COLUMN action_time FORMAT A20
COLUMN action FORMAT A10
COLUMN status FORMAT A10
COLUMN description FORMAT A60
COLUMN version FORMAT A10
COLUMN bundle_series FORMAT A10
SELECT TO_CHAR(action_time, 'DD-MON-YYYY HH24:MI:SS') AS action_time,
 action,
 status,
 description,
 version,
 patch_id,
 bundle_series
FROM dba_registry_sqlpatch
ORDER by action_time;
EOF

Practical example output:

Read moreHow to install a release patch on database 12.1 or 12.2