MPatcher

Mike's Patcher

TODO

MPatcher aims to automate Oracle patching (Release Updates). This page includes a reference for the various scripts that make up the tool.

Install

Patcher should be installed in /u01/dba/mpatcher.

It relies on the following variables from .profile/.bash_profile...

P_OS

PTAR

..and expects the following alias script to be called at the end of  .profile/.bash_profile...

. /u01/dba/mpatcher/.alias

Add aliases to /u01/dba/mpatcher/.alias to quickly switch between ORACLE_SIDs on the same server (if necessary)... Examples called ORCL1, ORCL2, ORCL3 and ORCL4 are included for reference. E.g.

alias ORCL1='. /home/oracle/.bash_profile.ORCL1'

Create missing patch variable files in /u01/dba/mpatcher/var.

The following lines should be in /etc/sudoers...

## Allow oracle to run /u01/dba/mpatcher/perms.sh as root

oracle   localhost = (root) NOPASSWD: /u01/dba/mpatcher/perms.sh

Command Reference

Queries patch information from registry$patch. 

checkreg

ACTION     ACTION_TIME                 PATCH_ID DESCRIPTION---------- ------------------------- ---------- --------------------------------------------------------------------------------APPLY      29-NOV-18 11.17.10.095426   28440711 Database PSU 12.1.0.2.181016, Oracle JavaVM Component (OCT2018)APPLY      29-NOV-18 11.17.15.394019   28259867 DATABASE BUNDLE PATCH 12.1.0.2.181016ROLLBACK   11-FEB-19 12.49.51.295706   28440711 Database PSU 12.1.0.2.181016, Oracle JavaVM Component (OCT2018)APPLY      11-FEB-19 12.49.51.305002   28790654 Database PSU 12.1.0.2.190115, Oracle JavaVM Component (JAN2019)APPLY      11-FEB-19 12.49.51.346465   28731800 DATABASE BUNDLE PATCH 12.1.0.2.190115ROLLBACK   15-MAY-19 14.55.51.429707   28790654 Database PSU 12.1.0.2.190115, Oracle JavaVM Component (JAN2019)APPLY      15-MAY-19 14.55.51.443547   29251241 Database PSU 12.1.0.2.190416, Oracle JavaVM Component (APR2019)APPLY      15-MAY-19 14.55.51.969957   29141038 DATABASE BUNDLE PATCH 12.1.0.2.190416ROLLBACK   24-JUL-19 15.03.41.870700   29251241 Database PSU 12.1.0.2.190416, Oracle JavaVM Component (APR2019)APPLY      24-JUL-19 15.03.41.877401   29774383 Database PSU 12.1.0.2.190716, Oracle JavaVM Component (JUL2019)APPLY      24-JUL-19 15.03.42.378778   29496791 DATABASE BUNDLE PATCH 12.1.0.2.190716APPLY      07-FEB-20 18.32.39.081655   30502018 OJVM RELEASE UPDATE 12.2.0.1.200114APPLY      07-FEB-20 18.32.43.262137   30593149 DATABASE JAN 2020 RELEASE UPDATE 12.2.0.1.200114APPLY      07-FEB-20 18.32.43.370304   29213893 DBMS_STATS FAILING WITH ERROR ORA-01422 WHEN GATHERING STATS FOR USER$ TABLEROLLBACK   18-MAY-20 07.02.43.981488   30502018 OJVM RELEASE UPDATE 12.2.0.1.200114APPLY      18-MAY-20 07.02.43.993687   30805580 OJVM RELEASE UPDATE 12.2.0.1.200414APPLY      18-MAY-20 07.02.44.730169   30886680 DATABASE APR 2020 RELEASE UPDATE 12.2.0.1.200414

Returns the total number of invalid objects in the database.

invobjcnt

  COUNT(*)----------       291

Runs opatch prereq checks

prereq

Prints/sets patch variables used by MPatcher.

pvars

 It reads from the latest file matching the Target version in /u01/dba/patcher/var and sets the variables.
     Target Version: 122010       Combo Patch#: 30783641 DB Release Update#: 30886680JVM Release Update#: 30805580

Configuration

.profile/.bash_profile

# DBA Patch Variables
case $(uname) in  AIX)   export P_OS=AIX64-5L         export AIXTHREAD_SCOPE=S         ;;  Linux) export P_OS=Linux-x86-64         ;;esacexport PATCH_SERVE=mylms001        # Local Management Serverexport PTAR=122010                 # This is the number that appears in patch download files
. /u01/dba/patcher/.alias          # Set aliases (used to simplify patching)

/u01/dba/patcher/.alias

alias menu='/home/oracle/menu.sh'
alias applyoff='/u01/dba/patcher/apply.sh off'alias applyon='/u01/dba/patcher/apply.sh on'alias applystat='/u01/dba/patcher/apply.sh stat'alias applylag='/u01/dba/patcher/apply.sh lag'alias bostart='${EMAGENT_HOME}/bin/emctl start blackout Patch_${PCOM} -nodeLevel'alias bostop='${EMAGENT_HOME}/bin/emctl stop blackout Patch_${PCOM}'alias bostat='${EMAGENT_HOME}/bin/emctl status blackout'alias dbopenresetlogs='sqlplus -s / as sysdba @/u01/dba/patcher/sql/dbopenresetlogs.sql'alias dbmount='sqlplus -s / as sysdba @/u01/dba/patcher/sql/dbmount.sql'alias dbstart='sqlplus -s / as sysdba @/u01/dba/patcher/sql/dbstart.sql'alias dbupgrd='sqlplus -s / as sysdba @/u01/dba/patcher/sql/dbstartupg.sql'alias dbshut='sqlplus -s / as sysdba @/u01/dba/patcher/sql/dbshutdown.sql'alias checkreg='sqlplus -s / as sysdba @/u01/dba/patcher/sql/checkreg.sql'alias grpset='sqlplus -s / as sysdba @/u01/dba/patcher/sql/grpset.sql "Patch_${PCOM}"'alias grpdrop='sqlplus -s / as sysdba @/u01/dba/patcher/sql/grpdrop.sql "Patch_${PCOM}"'alias grpshow='sqlplus -s / as sysdba @/u01/dba/patcher/sql/grpshow.sql'alias grpfback='sqlplus -s / as sysdba @/u01/dba/patcher/sql/grpfback.sql "Patch_${PCOM}"'alias invobjcnt='sqlplus -s / as sysdba @/u01/dba/patcher/sql/invobjcnt.sql'alias invobjowncnt='sqlplus -s / as sysdba @/u01/dba/patcher/sql/invobjowncnt.sql'alias invobjown='sqlplus -s / as sysdba @/u01/dba/patcher/sql/invobjown.sql'alias invobj='sqlplus -s / as sysdba @/u01/dba/patcher/sql/invobj.sql'alias listlist='ps -ef | grep tnslsnr | grep -v grep | awk '\''{ print $5, $8, $9 }'\'''alias lsinv='opatch lsinventory | grep -E "${RJVM}|${DBRU}"'alias opdbru='/u01/dba/patcher/opapply.sh dbru'alias opojvm='/u01/dba/patcher/opapply.sh ojvm'alias perms='sudo /u01/dba/patcher/perms.sh'alias pvars='. /u01/dba/patcher/pvars.sh'alias prereq='/u01/dba/patcher/prereq.sh'alias showlist='lsnrctl stat ${LISTENER_NAME}'alias startlist='lsnrctl start ${LISTENER_NAME}'alias stoplist='lsnrctl stop ${LISTENER_NAME}'
alias ORCL1='. ~/.bash_profile.ORCL1'alias ORCL2='. ~/.bash_profile.ORCL2'alias ORCL3='. ~/.bash_profile.ORCL3'alias ORCL4='. ~/.bash_profile.ORCL4'