Step by Step Apply Patch on Oracle DB Home (January 2021)

January 29, 2021
()

Step-by-Step Approach For Applying PSU Patch in Oracle 12c For Single-Instance


In this article, we are going to see Oracle12c Step-by-Step Applying PSU Patch For Single-Instance database.


List of the steps to follow during the activity :

  • Check the current version of Opatch Tool
  • Upgrade the Opatch utility if needed
  • Take the backup of ORACLE_HOME
  • Shutdown the Database and Listener running from the ORACLE_HOME to be patched
  • Apply PSU patch on ORACLE_HOME
  • Validate applied ORACLE_HOME patch in inventory
  • Execute Post-installation Steps (datapatch)
  • Startup the Database and Listener services associated to patched Oracle home.
  • Verify the status of the patch applied from dba_registry_sqlpatch.


Pre-requisites :

[oracle@machine1 lab03]$ mkdir -p /oradata/12.2.0.1_patch_jan2021
[oracle@machine1 lab03]$ cd /oradata/12.2.0.1_patch_jan2021

[oracle@machine1 12.2.0.1_patch_jan2021]$ ls -lrt
total 836072
-rw-r--r--. 1 oracle oinstall 856130787 Jan 25 11:06 p32228578_122010_Linux-x86-64.zip
  • Download patch as required and make sure you have downloaded the correct patch version for specific OS type & Database version. Here I am showing for Linux 64 Bit and database version is 12.2.0.1.
[oracle@machine1 12.2.0.1_patch_jan2021]$ unzip p32228578_122010_Linux-x86-64.zip


[oracle@machine1 12.2.0.1_patch_jan2021]$ ls -lrt
total 836416
drwxr-xr-x. 5 oracle oinstall      4096 Jan  9 09:42 32228578
-rw-rw-r--. 1 oracle oinstall    341808 Jan 19 04:21 PatchSearch.xml
-rw-r--r--. 1 oracle oinstall 856130787 Jan 25 11:06 p32228578_122010_Linux-x86-64.zip
  • Capture information of running instances, listener, patch inventory, oratab & backup of associated ORACLE_HOME.
oracle@machine1 12.2.0.1_patch_jan2021]$ mkdir prechecks_12.2.0.1_jan2021

ps -ef |grep pmon > /oradata/12.2.0.1_patch_jan2021/prechecks_12.2.0.1_jan2021/current_instance.txt
ps -ef |grep tns > /oradata/12.2.0.1_patch_jan2021/prechecks_12.2.0.1_jan2021/current_tns.txt
cat /etc/oratab > /oradata/12.2.0.1_patch_jan2021/prechecks_12.2.0.1_jan2021/current_oratab.txt 
$ORACLE_HOME/OPatch/opatch lsinventory > /oradata/12.2.0.1_patch_jan2021/prechecks_12.2.0.1_jan2021/before_current_lsinventory.txt 

=========Pre-Checks Output Files============
[oracle@machine1 prechecks_12.2.0.1_jan2021]$ ls -lrt
total 36
-rw-r--r--. 1 oracle oinstall   197 Jan 26 17:52 current_instance.txt
-rw-r--r--. 1 oracle oinstall   242 Jan 26 17:53 current_tns.txt
-rw-r--r--. 1 oracle oinstall   925 Jan 26 17:53 current_oratab.txt
-rw-r--r--. 1 oracle oinstall 23038 Jan 26 17:53 before_current_lsinventory.txt

[oracle@machine1 12.2.0.1_patch_jan2021]$ . oraenv
ORACLE_SID = [lab01] ? lab01
The Oracle base remains unchanged with value /u01/app/oracle

[oracle@machine1 12.2.0.1_patch_jan2021]$ export PATH=$ORACLE_HOME/OPatch:$PATH
[oracle@machine1 12.2.0.1_patch_jan2021]$ opatch version
OPatch Version: 12.2.0.1.23

OPatch succeeded.

  • Determine whether any currently installed interim patches conflict with the patch being installed.
[oracle@machine1 32228578]$ . oraenv
ORACLE_SID = [lab01] ? lab01
The Oracle base remains unchanged with value /u01/app/oracle
[oracle@machine1 32228578]$ export PATH=$ORACLE_HOME/OPatch:$PATH
[oracle@machine1 32228578]$ opatch version
OPatch Version: 12.2.0.1.23

OPatch succeeded.

[oracle@machine1 32228578]$ opatch prereq CheckConflictAgainstOHWithDetail -ph ./
Oracle Interim Patch Installer version 12.2.0.1.23
Copyright (c) 2021, Oracle Corporation.  All rights reserved.

PREREQ session

Oracle Home       : /u01/app/oracle/product/12.2.0.1/db_1
Central Inventory : /u01/app/oraInventory
   from           : /u01/app/oracle/product/12.2.0.1/db_1/oraInst.loc
OPatch version    : 12.2.0.1.23
OUI version       : 12.2.0.1.4
Log file location : /u01/app/oracle/product/12.2.0.1/db_1/cfgtoollogs/opatch/opatch2021-01-27_13-13-02PM_1.log

Invoking prereq "checkconflictagainstohwithdetail"

Prereq "checkConflictAgainstOHWithDetail" passed.

OPatch succeeded.


Patch Installation:

  • Set environment
[oracle@machine1 32228578]$ . oraenv
ORACLE_SID = [lab01] ? lab01
The Oracle base remains unchanged with value /u01/app/oracle
[oracle@machine1 32228578]$ export PATH=$ORACLE_HOME/OPatch:$PATH
  • Ensure that you shut down all the services running from the Oracle home where you are performing patch activity. Shutdown databases and Listener running associated from same ORACLE HOME where we are applying the patch
[oracle@machine1 32228578]$ ps -ef|grep pmon
oracle    8177  1991  0 18:34 pts/0    00:00:00 grep --color=auto pmon
[oracle@machine1 32228578]$ ps -ef|grep tns
root        15     2  0 17:25 ?        00:00:00 [netns]
oracle    8185  1991  0 18:34 pts/0    00:00:00 grep --color=auto tns
[oracle@machine1 32228578]$ ps -ef|grep exp
oracle    8203  1991  0 18:34 pts/0    00:00:00 grep --color=auto exp
[oracle@machine1 32228578]$ ps -ef|grep rman
oracle    8210  1991  0 18:34 pts/0    00:00:00 grep --color=auto rman
  • Set your current directory to the location where the patch is located and then run the opatch utility by entering the following commands:
[oracle@machine1 12.2.0.1_patch_jan2021]$ cd 32228578
[oracle@machine1 32228578]$ pwd
/oradata/12.2.0.1_patch_jan2021/32228578
[oracle@machine1 32228578]$ . oraenv
ORACLE_SID = [lab01] ? lab01
The Oracle base remains unchanged with value /u01/app/oracle
[oracle@machine1 32228578]$ export PATH=$ORACLE_HOME/OPatch:$PATH
[oracle@machine1 32228578]$ opatch version
OPatch Version: 12.2.0.1.23

OPatch succeeded.
[oracle@machine1 32228578]$ opatch apply
Oracle Interim Patch Installer version 12.2.0.1.23
Copyright (c) 2021, Oracle Corporation.  All rights reserved.


Oracle Home       : /u01/app/oracle/product/12.2.0.1/db_1
Central Inventory : /u01/app/oraInventory
   from           : /u01/app/oracle/product/12.2.0.1/db_1/oraInst.loc
OPatch version    : 12.2.0.1.23
OUI version       : 12.2.0.1.4
Log file location : /u01/app/oracle/product/12.2.0.1/db_1/cfgtoollogs/opatch/opatch2021-01-28_10-27-14AM_1.log

Verifying environment and performing prerequisite checks...
OPatch continues with these patches:   32228578

Do you want to proceed? [y|n]
y
User Responded with: Y
All checks passed.

Please shutdown Oracle instances running out of this ORACLE_HOME on the local system.
(Oracle Home = '/u01/app/oracle/product/12.2.0.1/db_1')


Is the local system ready for patching? [y|n]
y
User Responded with: Y
Backing up files...
Applying interim patch '32228578' to OH '/u01/app/oracle/product/12.2.0.1/db_1'
ApplySession: Optional component(s) [ oracle.swd, 12.2.0.1.0 ] , [ oracle.swd.opatchautodb, 12.2.0.1.0 ] , [ oracle.swd.oui, 12.2.0.1.0 ] , [ oracle.rdbms.drdaas, 12.2.0.1.0 ] , [ oracle.ons.daemon, 12.2.0.1.0 ] , [ oracle.oid.client, 12.2.0.1.0 ] , [ oracle.ons.eons.bwcompat, 12.2.0.1.0 ] , [ oracle.network.cman, 12.2.0.1.0 ] , [ oracle.ons.cclient, 12.2.0.1.0 ]  not present in the Oracle Home or a higher version is found.

Patching component oracle.rdbms.util, 12.2.0.1.0...

Patching component oracle.rdbms.rsf, 12.2.0.1.0...

Patching component oracle.network.rsf, 12.2.0.1.0...

Patching component oracle.rdbms, 12.2.0.1.0...

------------------TRIMMED DATA------------------

Patching component oracle.ldap.rsf.ic, 12.2.0.1.0...

Patching component oracle.install.deinstalltool, 12.2.0.1.0...

Patching component oracle.rdbms.oci, 12.2.0.1.0...

Patching component oracle.precomp.lang, 12.2.0.1.0...

Patching component oracle.precomp.common, 12.2.0.1.0...

Patching component oracle.jdk, 1.8.0.91.0...
Patch 32228578 successfully applied.
Sub-set patch [31741641] has become inactive due to the application of a super-set patch [32228578].
Please refer to Doc ID 2161861.1 for any possible further required actions.
Log file location: /u01/app/oracle/product/12.2.0.1/db_1/cfgtoollogs/opatch/opatch2021-01-28_10-27-14AM_1.log

OPatch succeeded.


Post Patch Installation:

[oracle@machine1 32228578]$ opatch lsinventory > /oradata/12.2.0.1_patch_jan2021/prechecks_12.2.0.1_jan2021/after_current_lsinventory.txt

OR

[oracle@machine1 32228578]$ opatch lsinventory


  • Start the services from the Oracle home
[oracle@machine1 32228578]$ sqlplus /nolog

SQL*Plus: Release 12.2.0.1.0 Production on Thu Jan 28 11:36:31 2021

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

SQL> conn / as sysdba
Connected to an idle instance.
SQL> startup
ORACLE instance started.

Total System Global Area  998244352 bytes
Fixed Size                  8628064 bytes
Variable Size             356518048 bytes
Database Buffers          629145600 bytes
Redo Buffers                3952640 bytes
Database mounted.
Database opened.
SQL>
SQL> alter pluggable database all open; ==> Applicable only to Multitenant (CDB/PDB) used.
SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
[oracle@machine1 32228578]$
[oracle@machine1 32228578]$
[oracle@machine1 32228578]$ cd /u01/app/oracle/product/12.2.0.1/db_1/OPatch
[oracle@machine1 OPatch]$
[oracle@machine1 OPatch]$ ls -lrt datapatch
-rwxr-x---. 1 oracle oinstall 589 Nov  5 14:46 datapatch
[oracle@machine1 OPatch]$
[oracle@machine1 OPatch]$ ./datapatch -verbose
SQL Patching tool version 12.2.0.1.0 Production on Thu Jan 28 11:44:06 2021
Copyright (c) 2012, 2021, Oracle.  All rights reserved.

Log file for this invocation: /u01/app/oracle/cfgtoollogs/sqlpatch/sqlpatch_11513_2021_01_28_11_44_07/sqlpatch_invocation.log

Connecting to database...OK
Bootstrapping registry and package to current versions...done
Determining current state...done

Current state of SQL patches:
Bundle series DBRU:
  ID 210119 in the binary registry and ID 201020 in the SQL registry

Adding patches to installation queue and performing prereq checks...
Installation queue:
  Nothing to roll back
  The following patches will be applied:
    32228578 (DATABASE JAN 2021 RELEASE UPDATE 12.2.0.1.210119)

Installing patches...
Patch installation complete.  Total patches installed: 1

Validating logfiles...
Patch 32228578 apply: SUCCESS
  logfile: /u01/app/oracle/cfgtoollogs/sqlpatch/32228578/24008225/32228578_apply_LAB01_2021Jan28_11_45_20.log (no errors)
SQL Patching tool complete on Thu Jan 28 11:45:38 2021
  • Validate patch applied in database.
SQL*Plus: Release 12.2.0.1.0 Production on Thu Jan 28 12:27:08 2021

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

Enter user-name: / as sysdba

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> SET LINESIZE 400
COLUMN action_time FORMAT A20
COLUMN action FORMAT A10
COLUMN status FORMAT A10
COLUMN description FORMAT A40
COLUMN version FORMAT A10
COLUMN bundle_series FORMAT A10

SQL> SELECT TO_CHAR(action_time, 'DD-MON-YYYY HH24:MI:SS') AS action_time,
action,status,description, version,patch_id,bundle_series
FROM sys.dba_registry_sqlpatch ORDER by action_time;

ACTION_TIME          ACTION     STATUS     DESCRIPTION                              VERSION      PATCH_ID BUNDLE_SER
-------------------- ---------- ---------- ---------------------------------------- ---------- ---------- ----------
23-OCT-2020 03:19:06 APPLY      SUCCESS    DATABASE OCT 2020 RELEASE UPDATE 12.2.0. 12.2.0.1     31741641 DBRU
                                           1.201020

28-JAN-2021 11:45:38 APPLY      SUCCESS    DATABASE JAN 2021 RELEASE UPDATE 12.2.0. 12.2.0.1     32228578 DBRU



Click here for various options to validate applied patches in ORACLE HOME & DATABASE.

  • Startup database
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
[oracle@machine1 OPatch]$
[oracle@machine1 OPatch]$ sqlplus

SQL*Plus: Release 12.2.0.1.0 Production on Thu Jan 28 12:33:38 2021

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

Enter user-name: / as sysdba
Connected to an idle instance.

SQL> startup
ORACLE instance started.

Total System Global Area  998244352 bytes
Fixed Size                  8628064 bytes
Variable Size             356518048 bytes
Database Buffers          629145600 bytes
Redo Buffers                3952640 bytes
Database mounted.
Database opened.


SQL> select name,open_mode from v$database;

NAME      OPEN_MODE
--------- --------------------
LAB01     READ WRITE


NOTE: Follow post-installation steps for all databases running from the same ORACLE_HOME where we applied the patch.

Make sure all services are up & running from patched ORACLE HOME.

Click here for more patch-related articles.

This document is only for learning purposes and always validate in the LAB environment first before applying in the LIVE environment.


Hope so you like this article!
Please share your valuable feedback/comments/subscribe and follow us below and don’t forget to click on the bell icon to get the most recent update. Click here to know more about our pursuit.

Related Articles


Loading

How useful was this post?

Click on a star to rate it!

Average rating / 5. Vote count:

No votes so far! Be the first to rate this post.

As you found this post useful...

Follow us on social media!

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

Hello and welcome to DBsGuru, I am Sruti Banerjee, having experience of 3 years as an Oracle DBA, I have good interpersonal skills that can help in attaining the desired level of team coordination, self-starter & quick learner. I am having rich experience in Oracle database management, Backup and Recovery, Security, Installation, Up-gradation, Patching, Migration, Cloning of databases, Dataguard (Physical), and a wide range of other database administration activities.Thanks for the visits!Share Learn Grow!

Leave a Reply

Your email address will not be published. Required fields are marked *