This document will cover the basic steps to apply Oracle patches (single node) under Amazon Web Services EC2 instances running Oracle Enterprise Linux 7.4.

Prerequisites to execute this procedure:
– Server internet connection
– AWS CLI credentials configured

1) Download

For downloading I use mos.sh by Jeffrey M. Hunter. This is a quick way to download any Oracle patches directly from Oracle to the Amazon EC2 instance.

Example:

mos.sh \
<patch_name>.zip \
<mos_user_e-mail> \
<mos_user_password

 2) Create snapshots

Discover the volumes of your current EC2 instance that need to be backed up. This is the basic command and you can use whatever you want to format the output.
export INSTANCE_ID=$(wget -q -O – http://169.254.169.254/latest/meta-data/instance-id)
aws ec2 describe-instances –instance-id $INSTANCE_ID |egrep ‘DeviceName*|Vol-*’
<mos_user_password

Decide each volumes you will do the snapshots

Example:
aws ec2 create-snapshot –description “DD/MON/YYYY Snapshot taken before Oracle DBRU April 2018 – DeviceName: /dev/sdx – /uxx” –volume-id vol-xxxxxxxxxxxxxxxxx

 3) Check snapshots

Once you have taken the snapshots check if all of them were successfully completed.

Parameters:
?StartTime >= `YYYY-MM-DD`
?contains(Description, `<part of your snapshot description>`

Example:
aws ec2 describe-snapshots –query ‘Snapshots[?StartTime >= `2018-05-11`]|[?contains(Description, `/dev`) == `true`].{id:SnapshotId,desc:Description,bkp_time:StartTime,Status:State}’ –output table

4) Shutdown Oracle components

su oracle
lsnrctl stop
ps -ef|grep smon
export ORACLE_SID=<sid>
sqlplus / as sysdba
shutdown immediate;
exit;

5) OPatch

Check if your OPatch version is suitable for the Oracle patch version.
$ORACLE_HOME/OPatch/opatch version

Generate a backup of your lsinventory before applying the patch.
$ORACLE_HOME/OPatch/opatch lsinventory -detail > /tmp/DRU-Apr-2018-lsinventory_before.txt

Determine whether any currently installed one-off patches conflict with the new patch.
$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -ph ./

Multiple patch mode.
cd $ORACLE_HOME /OPatch/<patch-id>
$ORACLE_HOME/OPatch/opatch napply -id (sub-patch_id-1, sub-patch_id-2)

Single patch mode

cd $ORACLE_HOME /OPatch/<patch-id>
$ORACLE_HOME/OPatch/opatch apply

For Oracle 12c – Postinstallation for DBRU. I recommend to follow each REAME.html regarding to the datapatch. The basics we have this:

Standalone DB
sqlplus /nolog
connect / as sysdba
startup upgrade
quit
cd $ORACLE_HOME/OPatch
./datapatch -verbose
sqlplus /nolog
Connect / as sysdba
shutdown
startup
exit
cd $ORACLE_HOME/rdbms/admin
sqlplus /nolog
connect / as sysdba
@utlrp.sql

Single/Multitenant (CDB/PDB) DB
sqlplus /nolog
Connect / as sysdba
startup upgrade
alter pluggable database all open upgrade;
quit
cd $ORACLE_HOME/OPatch
./datapatch -verbose
sqlplus /nolog
connect / as sysdba
shutdown
startup
alter pluggable database all open;
exit
cd $ORACLE_HOME/rdbms/admin
sqlplus /nolog
connect / as sysdba
@utlrp.sql

Check the results to see if the patch was successfully applied.
$ORACLE_HOME/OPatch/opatch lsinventory -detail > /tmp/DRU-Apr-2018-lsinventory_after.txt

In case of problems you can rollback the applied patches
$ORACLE_HOME/OPatch/opatch rollback -id <patch_id>

6) Restore from snapshot

In case of problems with your rollback patch there is an option to restore your volume from the snapshot (that one taken in step 2)

Describe snapshots
aws ec2 describe-snapshots –snapshot-id <snapshot-id-taken-before-patch>

Create a new volume from the snapshot that has been taken
aws ec2 create-volume –availability-zone=eu-west-1a –size=50 –volume-type=gp2 –snapshot-id <snapshot-id-taken-before-patch>

Detach the current volume associated with your Oracle files
aws ec2 detach-volume –volume-id vol-xxxxxxxxxxxxxxxxx

Attach the new volume according to the device that was mapped
aws ec2 attach-volume –volume-id vol-xxxxxxxxxxxxxxxxx –instance-id i-xxxxxxxx –device /dev/sdx

7) Start Oracle components

export ORACLE_SID=<sid>
sqlplus / as sysdba
startup;
@$ORACLE_HOME/rdbms/admin/utlrp
exit;
lsnrctl start

Documentation reference:

– 12.2.0.1 Database Release Update – List of Fixes in each RU/RUR (Doc ID 2245178.1)
– Conflict Checker Overview [VIDEO] (Doc ID 1941934.1)
– Conflict Checker Tool (Doc ID 2254812.1)
– Master note for OPatch (Doc ID 293369.1)
– Oracle Recommended Patches (Doc ID 756671.1)
– Overview of Database Patch Delivery Methods (Doc ID 1962125.1)
– Release Update Introduction and FAQ (Doc ID 2285040.1)
– Revision, PSU, SPU(CPU), Bundle Patches, Patchsets and Base Release (Doc ID 2118136.2)
– Differences between PSU / BP / RU and RUR: https://mikedietrichde.com/2017/10/24/differences-psu-bp-ru-rur 

Regards,

Leonardo Bissoli.

leonardo.bissoli

View all posts

Latest videos