In this post, I'm trying to design the best practice to install OPatch. In fact, the procedure means to replace the old OPatch utility with the new one, either in single-instance or RAC databases.
Assuming that you have downloaded the newest OPatch utility from Oracle before proceeding.
Single-Instance Databases
Suppose you have upload the newest opatch zip file to /sources/patches. Here are the steps that can replace current OPatch.
Check Version of Old OPatch
[oracle@test ~]$ opatch version
OPatch Version: 12.2.0.1.17
OPatch succeeded.
Rename Old OPatch
That is, move the old OPatch to step aside.
[oracle@test ~]$ mv $ORACLE_HOME/OPatch $ORACLE_HOME/OPatch-12.2.0.1.17
With the version number, we can tell the directory is the old opatch utility 12.2.0.1.17 in practice.
Unzip the New OPatch
We start to unzip the new OPatch utility to the destination which is under $ORACLE_HOME.
[oracle@test ~]$ unzip -q /sources/patches/p6880880_190000_Linux-x86-64.zip -d $ORACLE_HOME
Option -q calls unzip in quiet mode.
Check Version of New OPatch
[oracle@test ~]$ opatch version
OPatch Version: 12.2.0.1.28
OPatch succeeded.
Now, the OPatch version is 12.2.0.1.28.
RAC Databases
Replacing OPatch with a new one in RAC databases would be a more complicated than in single-instance databases, this is because we can't directly replace it by user grid or oracle. Furthermore, everything we did in node 1 should be also done in node 2, which doubles our workload.
In the following steps, we replace grid's OPatch first, then replace oracle's.
Replace Gird's OPatch
We have to login into the server as root.
Set as Gird's Environment
[root@primary01 ~]# . /home/grid/.bash_profile
Make Sure ORACLE_HOME is Correct
[root@primary01 ~]# echo $ORACLE_HOME
/u01/app/19.0.0/grid
Check Version of Old OPatch
[root@primary01 ~]# opatch version
OPatch Version: 12.2.0.1.17
OPatch succeeded.
Backup Old OPatch
[root@primary01 ~]# mv $ORACLE_HOME/OPatch $ORACLE_HOME/OPatch-12.2.0.1.17
Deploy New OPatch
[root@primary01 ~]# unzip -q /sources/patches/p6880880_190000_Linux-x86-64.zip -d $ORACLE_HOME
Change Owner to Grid
[root@primary01 ~]# chown -R grid:oinstall $ORACLE_HOME/OPatch
Check Version of New OPatch
[root@primary01 ~]# opatch version
OPatch Version: 12.2.0.1.28
OPatch succeeded.
Replace Oracle's OPatch
Initiate another root shell
We initiate a new root session for the following steps.
[root@primary01 ~]# su -
Set as Oracle's Environment
[root@primary01 ~]# . /home/oracle/.bash_profile
Make Sure ORACLE_HOME is Correct
[root@primary01 ~]# echo $ORACLE_HOME
/u01/app/oracle/product/19.0.0/db_1
Check Version of Old OPatch
[root@primary01 ~]# opatch version
OPatch Version: 12.2.0.1.17
OPatch succeeded.
Backup Old OPatch
[root@primary01 ~]# mv $ORACLE_HOME/OPatch $ORACLE_HOME/OPatch-12.2.0.1.17
Deploy New OPatch
[root@primary01 ~]# unzip -q /sources/patches/p6880880_190000_Linux-x86-64.zip -d $ORACLE_HOME
Change Owner to Oracle
[root@primary01 ~]# chown -R oracle:oinstall $ORACLE_HOME/OPatch
Check Version of New OPatch
[root@primary01 ~]# opatch version
OPatch Version: 12.2.0.1.28
OPatch succeeded.
Then we exit all root shell.
For Windows platform, you should go for: How to Install OPatch on Windows.