{ Abhilash Kumar Bhattaram : Follow on LinkedIn }
ocidpatchdb
I have extensively worked on OCI CLI and have found a way to automate GI/RU Patches for OCI DB System class of databases. ocidpatchdb utilities are the perfect way to do this. The absolute power of ocidpatchdb is seen in the last section where you can see patches are seen applied for multiple databases at once.
The real motivation to create this utility is that DBA's struggle in operational efficiencies when this is done manually. Patching is an activity that must run every quarter for GI/RU.
Oracle provides Fleet Patching and Provisioning as seen here in an elegant way (but be prepared to pay $$$). My ocidtadbdb does the exact same thing , so I call mine poor man's Fleet Patching and Provisioning.
As a techincal consultant one needs to find cheaper ways to provide solutions with the same efficiency, this is one such example.
This is why I created the ocidtab utility a couple of years ago and now expanding it to multiple OCI automations like ocidpatchdb.
NOTE : Before we proceed any further this Blog assumes you are familiar with OCI CLI and the efficiency it provides. If you are new to OCI CLI I strongly suggest to reference my older article on
ocidtab
Where to find ocidpatchdb utilities ?
ocidpatchdb utilies are available in my github below
https://github.com/abhilash-8/ocidpatchdb
I strongly recommend to do through the README and understand how the script performs
Pre-requisites for running ocidpatch
Ideally ocidpatch must be running from a jumpbox where you have OCI CLI configured , the following prerequisites are needed to use the ocidpatchdb scripts.
1) OCI DB System Hostname [ as seen in OCI Web Console ]
2) OCI DB Name [ as seen in OCI Web Console ]
3) OCI VCN Name / relevant OCI CLI profile to be used
4) jq to be installed in Linux
$ sudo yum install jq
5) The OCI User in the profile will need to have the required IAM Policies for OCI Services to generate the OCID
6) ocidtab environment variable files , if not availble please refer : https://github.com/abhilash-8/ocidenv
Example for running GI/RU Patches
Once you are familiar with the
Let us assume that we have a DEV database which needs to apply 19.23 RU Patch , all you need to specify is the environment , hostname , name of the database , version and patch apply action
*Example of applying RU Patches *
# ./ocidpatch_ru.sh DEV devdb01 orcl 19.23.0.0.0 PRECHECK
# ./ocidpatch_ru.sh DEV devdb01 orcl 19.23.0.0.0 APPLY
*Example of applying GI Patches
*
# ./ocidpatch_gi.sh DEV devdb01 orcl 19.23.0.0.0 PRECHECK
# ./ocidpatch_gi.sh DEV devdb01 orcl 19.23.0.0.0 APPLY
Automating multiple GI/RU Patches
Once you have a fair grip on understanding how to PRECHECK/APPLY for one environment you could actually automate as below
Example of Automating RU PRECHECK for multiple database systems
#!/bin/bash
#
# Automating PRECHECK for all DEV Environments
~/ocidpatch_ru.sh DEV devdb01 orcl01 19.23.0.0.0 PRECHECK
~/ocidpatch_ru.sh DEV devdb02 orcl02 19.23.0.0.0 PRECHECK
~/ocidpatch_ru.sh DEV devdb03 orcl03 19.23.0.0.0 PRECHECK
~/ocidpatch_ru.sh DEV devdb04 orcl04 19.23.0.0.0 PRECHECK
~/ocidpatch_ru.sh DEV devdb05 orcl05 19.23.0.0.0 PRECHECK
#
# Automating PRECHECK for all TST Environments
~/ocidpatch_ru.sh TST tstdb01 orcl06 19.23.0.0.0 PRECHECK
~/ocidpatch_ru.sh TST tstdb02 orcl07 19.23.0.0.0 PRECHECK
~/ocidpatch_ru.sh TST tstdb03 orcl08 19.23.0.0.0 PRECHECK
~/ocidpatch_ru.sh TST tstdb04 orcl09 19.23.0.0.0 PRECHECK
~/ocidpatch_ru.sh TST tstdb05 orcl10 19.23.0.0.0 PRECHECK
#
# Automating PRECHECK for all UAT Environments
~/ocidpatch_ru.sh UAT tstdb01 orcl11 19.23.0.0.0 PRECHECK
~/ocidpatch_ru.sh UAT tstdb02 orcl12 19.23.0.0.0 PRECHECK
~/ocidpatch_ru.sh UAT tstdb03 orcl13 19.23.0.0.0 PRECHECK
~/ocidpatch_ru.sh UAT tstdb04 orcl14 19.23.0.0.0 PRECHECK
~/ocidpatch_ru.sh UAT tstdb05 orcl15 19.23.0.0.0 PRECHECK
Example of Automating RU APPLY for multiple database systems
#!/bin/bash
#
# Automating APPLY for all DEV Environments
~/ocidpatch_ru.sh DEV devdb01 orcl01 19.23.0.0.0 APPLY
~/ocidpatch_ru.sh DEV devdb02 orcl02 19.23.0.0.0 APPLY
~/ocidpatch_ru.sh DEV devdb03 orcl03 19.23.0.0.0 APPLY
~/ocidpatch_ru.sh DEV devdb04 orcl04 19.23.0.0.0 APPLY
~/ocidpatch_ru.sh DEV devdb05 orcl05 19.23.0.0.0 APPLY
#
# Automating APPLY for all TST Environments
~/ocidpatch_ru.sh TST tstdb01 orcl06 19.23.0.0.0 APPLY
~/ocidpatch_ru.sh TST tstdb02 orcl07 19.23.0.0.0 APPLY
~/ocidpatch_ru.sh TST tstdb03 orcl08 19.23.0.0.0 APPLY
~/ocidpatch_ru.sh TST tstdb04 orcl09 19.23.0.0.0 APPLY
~/ocidpatch_ru.sh TST tstdb05 orcl10 19.23.0.0.0 APPLY
#
# Automating APPLY for all UAT Environments
~/ocidpatch_ru.sh UAT tstdb01 orcl11 19.23.0.0.0 APPLY
~/ocidpatch_ru.sh UAT tstdb02 orcl12 19.23.0.0.0 APPLY
~/ocidpatch_ru.sh UAT tstdb03 orcl13 19.23.0.0.0 APPLY
~/ocidpatch_ru.sh UAT tstdb04 orcl14 19.23.0.0.0 APPLY
~/ocidpatch_ru.sh UAT tstdb05 orcl15 19.23.0.0.0 APPLY
Example of Automating GI PRECHECK for multiple database systems
#!/bin/bash
#
# Automating PRECHECK for all DEV Environments
~/ocidpatch_gi.sh DEV devdb01 orcl01 19.23.0.0.0 PRECHECK
~/ocidpatch_gi.sh DEV devdb02 orcl02 19.23.0.0.0 PRECHECK
~/ocidpatch_gi.sh DEV devdb03 orcl03 19.23.0.0.0 PRECHECK
~/ocidpatch_gi.sh DEV devdb04 orcl04 19.23.0.0.0 PRECHECK
~/ocidpatch_gi.sh DEV devdb05 orcl05 19.23.0.0.0 PRECHECK
#
# Automating PRECHECK for all TST Environments
~/ocidpatch_gi.sh TST tstdb01 orcl06 19.23.0.0.0 PRECHECK
~/ocidpatch_gi.sh TST tstdb02 orcl07 19.23.0.0.0 PRECHECK
~/ocidpatch_gi.sh TST tstdb03 orcl08 19.23.0.0.0 PRECHECK
~/ocidpatch_gi.sh TST tstdb04 orcl09 19.23.0.0.0 PRECHECK
~/ocidpatch_gi.sh TST tstdb05 orcl10 19.23.0.0.0 PRECHECK
#
# Automating PRECHECK for all UAT Environments
~/ocidpatch_gi.sh UAT tstdb01 orcl11 19.23.0.0.0 PRECHECK
~/ocidpatch_gi.sh UAT tstdb02 orcl12 19.23.0.0.0 PRECHECK
~/ocidpatch_gi.sh UAT tstdb03 orcl13 19.23.0.0.0 PRECHECK
~/ocidpatch_gi.sh UAT tstdb04 orcl14 19.23.0.0.0 PRECHECK
~/ocidpatch_gi.sh UAT tstdb05 orcl15 19.23.0.0.0 PRECHECK
Example of Automating GI APPLY for multiple database systems
#!/bin/bash
#
# Automating APPLY for all DEV Environments
~/ocidpatch_gi.sh DEV devdb01 orcl01 19.23.0.0.0 APPLY
~/ocidpatch_gi.sh DEV devdb02 orcl02 19.23.0.0.0 APPLY
~/ocidpatch_gi.sh DEV devdb03 orcl03 19.23.0.0.0 APPLY
~/ocidpatch_gi.sh DEV devdb04 orcl04 19.23.0.0.0 APPLY
~/ocidpatch_gi.sh DEV devdb05 orcl05 19.23.0.0.0 APPLY
#
# Automating APPLY for all TST Environments
~/ocidpatch_gi.sh TST tstdb01 orcl06 19.23.0.0.0 APPLY
~/ocidpatch_gi.sh TST tstdb02 orcl07 19.23.0.0.0 APPLY
~/ocidpatch_gi.sh TST tstdb03 orcl08 19.23.0.0.0 APPLY
~/ocidpatch_gi.sh TST tstdb04 orcl09 19.23.0.0.0 APPLY
~/ocidpatch_gi.sh TST tstdb05 orcl10 19.23.0.0.0 APPLY
#
# Automating APPLY for all UAT Environments
~/ocidpatch_gi.sh UAT tstdb01 orcl11 19.23.0.0.0 APPLY
~/ocidpatch_gi.sh UAT tstdb02 orcl12 19.23.0.0.0 APPLY
~/ocidpatch_gi.sh UAT tstdb03 orcl13 19.23.0.0.0 APPLY
~/ocidpatch_gi.sh UAT tstdb04 orcl14 19.23.0.0.0 APPLY
~/ocidpatch_gi.sh UAT tstdb05 orcl15 19.23.0.0.0 APPLY
If you have successfully come this far in the article and testing the same in your environments you have achieved Nirvana.
Top comments (0)