Tuesday, August 29, 2023

Patching Oracle Grid Infrastructure 19c using out-of-place SwitchGridHome

Suppose your currnt grid and rdbms home is 19.19 and you want to apply 19.20 ( released on July 2023) using out-of-place patching method.

So You donwload,

1. GI RELEASE UPDATE 19.20.0.0.0(Patch 35319490) for Linux x86-64 for Oracle Database 19.0.0.0.0

2. Latest OPatch from My Oracle Support (6880880).

3. Download the base release of Oracle Grid Infrastructure (LINUX.X64_193000_grid_home.zip) and database LINUX.X64_193000_db_home.zip


Steps Inovled

Suppose you have a 2 node cluster with hostname node1 and node2

1) Create necessary directory for the new home and change the permission,

As root run below commands on node1 and node2

mkdir -p /u01/app/19.20.0/grid

chown -R grid:oinstall  /u01/app/19.20.0

chmod -R 775 /u01/app/19.20.0


2) Copy the software.

As grid owner run below commands on node1(only)

cp LINUX.X64_193000_grid_home.zip /u01/app/19.20.0/grid

cp p6880880_190000_Linux-x86-64.zip  /u01/app/19.20.0/grid


As I want to apply 19.20.0 Release Update while I install the Grid home, extract the 19.20.0 patch.


cd /u01/software

mkdir 19.20_Patch

mv p35319490_190000_Linux-x86-64.zip 19.20_Patch

cd 19.20_Patch

unzip p35319490_190000_Linux-x86-64.zip


3)As grid user, Unzip the grid softwares on Node1

As grid user ,


cd /u01/app/19.20.0/grid

unzip LINUX.X64_193000_grid_home.zip

Once Zip is done for the base software, remove the Opatch directory

rm -rf OPatch

and unzip the latest OPatch 

unzip p6880880_190000_Linux-x86-64.zip


4) As grid user, Export the new grid home and run the prerequisites check for the new home.


 export NEWGRIDHOME=/u01/app/19.20.0/grid

 export ORACLE_HOME=$NEWGRIDHOME

 $ORACLE_HOME/gridSetup.sh -executePrereqs -silent


5) As grid user, from node1, install the Grid software.

export NEWGRIDHOME=/u01/app/19.20.0/grid

export ORACLE_HOME=$NEWGRIDHOME

export ORACLE_BASE=/u01/app/grid

export ORA_INVENTORY=/u01/app/oraInventory

export CLUSTER_NAME=$(olsnodes -c)

export CLUSTER_NODES=$(olsnodes | tr '\n' ','| sed 's/,\s*$//')

cd $ORACLE_HOME 

./gridSetup.sh -ignorePrereq -waitforcompletion -silent \

   -applyRU /u01/software/19.20_Patch/35319490 \

   -responseFile $ORACLE_HOME/install/response/gridsetup.rsp \

   INVENTORY_LOCATION=$ORA_INVENTORY \

   ORACLE_BASE=$ORACLE_BASE \

   SELECTED_LANGUAGES=en \

   oracle.install.option=CRS_SWONLY \

   oracle.install.asm.OSDBA=asmdba \

   oracle.install.asm.OSOPER=asmoper \

   oracle.install.asm.OSASM=asmadmin \

   oracle.install.crs.config.ClusterConfiguration=STANDALONE \

   oracle.install.crs.config.configureAsExtendedCluster=false \

   oracle.install.crs.config.clusterName=$CLUSTER_NAME \

   oracle.install.crs.config.gpnp.configureGNS=false \

   oracle.install.crs.config.autoConfigureClusterNodeVIP=false \

   oracle.install.crs.config.clusterNodes=$CLUSTER_NODES


* If you have one-off patches to install, you can use the -applyOneOffs parameter.


* Above script will copy the grid software to node2 and once it finish it will ask you to execute the root.sh 


/u01/app/19.20.0/grid/root.sh ( on node1 and node2 ) -- this will quick 


6) Once root.sh executed on all nodes, as grid user switch to the new grid home (Needs to execute from each node)


export ORACLE_HOME=/u01/app/19.20.0/grid

export CURRENT_NODE=$(hostname)

$ORACLE_HOME/gridSetup.sh \

   -silent -switchGridHome \

   oracle.install.option=CRS_SWONLY \

   ORACLE_HOME=$ORACLE_HOME \

   oracle.install.crs.config.clusterNodes=$CURRENT_NODE \

   oracle.install.crs.rootconfig.executeRootScript=false


Above script will ask you to execute /u01/app/19.20.0/grid/root.sh --> this will takes time.

* Actual downtime of first node starts here.

* Here root.sh brings down the clusterware stack from the old home and then bring it up from the new home.

* Once root.sh brings up the clusterware stack from the new home, go to node2 and repeat step 6


RDBMS Home Patching 

1) As oracle user create direcotory for new home on node1 and node2


mkdir -p /u01/app/oracle/product/19.20/dbhome_1


2) Copy the database and Opatch software to the newly created db home.


cp LINUX.X64_193000_db_home.zip  /u01/app/oracle/product/19.20/dbhome_1


cp p6880880_190000_Linux-x86-64.zip /u01/app/oracle/product/19.20/dbhome_1


3) Unzip the database software 


cd /u01/app/oracle/product/19.20/dbhome_1


unzip LINUX.X64_193000_db_home.zip


Once Zip is done for the base software, remove the Opatch directory


rm -rf OPatch


and unzip the latest OPatch 


unzip p6880880_190000_Linux-x86-64.zip


4)Export new Oracle HOme and install the new software 


export ORACLE_HOME=/u01/app/oracle/product/19.20/dbhome_1

cd $ORACLE_HOME

./runInstaller -applyRU /u01/software/19.20_Patch/35319490 \

-silent -ignorePrereqFailure -waitforcompletion \

oracle.install.option=INSTALL_DB_SWONLY \

UNIX_GROUP_NAME=oinstall \

INVENTORY_LOCATION=/u01/app/oraInventory \

ORACLE_BASE=/u00/app/oracle \

ORACLE_HOME=/u01/app/oracle/product/19.20/dbhome_1 \

oracle.install.db.InstallEdition=EE \

oracle.install.db.OSDBA_GROUP=dba \

oracle.install.db.OSOPER_GROUP=oper \

oracle.install.db.OSBACKUPDBA_GROUP=backupdba \

oracle.install.db.OSDGDBA_GROUP=dgdba \

oracle.install.db.OSKMDBA_GROUP=kmdba \

oracle.install.db.OSRACDBA_GROUP=dba \

SECURITY_UPDATES_VIA_MYORACLESUPPORT=false \

oracle.install.db.CLUSTER_NODES=node1,node2 \

DECLINE_SECURITY_UPDATES=true


** runInstaller will ask you to run root.sh from node1 and node2


run /u01/app/oracle/product/19.20/dbhome_1/root.sh on node1 and node2

5) update /etc/oratab (on all nodes) and then modifty the database properties 


srvctl config database -d MYDB

srvctl modify database -d MYDB -o /u01/app/oracle/product/19.20/dbhome_1

srvctl stop database -d MYDB

srvctl start database -d MYDB


6) Finally run the datapatch 

col action for a24

col version for a35

col bundle_series for a50

col comments for a99


select action,action_time,version,bundle_series,comments from dba_registry_history;


cd $ORACLE_HOME/OPatch


export ORACLE_HOME=/u01/app/oracle/product/19.20/dbhome_1

export ORACLE_SID=MYDB

cd $ORACLE_HOME/OPatch

./datapatch -verbose