Monday, September 27, 2021

Oracle Cloud -- Applying Patch on OCI

 There are multiple ways to apply patch

1) Using Console 
2) Using dbcli 
3) For exacloud we can use dbaascli   or  exadbcpatchmulti  

In this Blog we will mainly discuss about applying patch using console and dbcli . This was tested by my friend i still need to test it . 


Using OCI  Console :

The one-off patches (now they are call interim patches) can be applied via the Console, API or even manually. To apply an interim patch manually, you can use the Opatch utility. The detailed steps are provided in the Applying one-off patches on Oracle Database 21c documentation. The patches can be applied in any order.

Here is how simple and easy it is:

1. For the database on which you want to apply the patches, just click its name to display details and under Resources, click Updates:

2. Click on “Apply a one-off patch“:

3. Then, in the Apply one-off patch dialog, enter the patch numbers. Use a comma-separated list to enter more than one patch. I did apply them one after each other. Paste the patch number and then click Apply.

While the patch is being applied, the database’s status displays as Updating:

A work request is created for the patching operation allowing us to monitor the progress of the operation.

If the operation completes successfully, the database’s status changes to Available:



Using dbcli 

Prerequisites
The /u01 directory has at least 15 GB of free space.
The Oracle Clusterware is up and running on the DB system.
All nodes of the DB system are up and running.
Before starting the patching, we need to upgrade the DBCLI utility. For that perform the below steps


Login to OPC user with Public IP/Private IP by using private key. Switch the user to root.
 
[opc@abdu1 ~]$ sudo su -
[root@abdu1 bin]# export PATH=/opt/oracle/dcs/bin:$PATH
  • Update the CLI by using the cliadm update-dbcli command.
[root@abdu1 bin]# cliadm update-dbcli
[root@abdu1 bin]# dbcli list-jobs
[root@abdu1 bin]# dbcli describe-component

  • Display the latest patch versions available in Object Storage by using the dbcli describe-latestpatch command.
[root@abdu1 bin]# dbcli describe-latestpatch
  • Now, we can perform the prechecks on the server components (Grid InfraStruture) by using the dbcli update-server command with -p argument. Note the Job Id.

[root@abdu1 bin]# dbcli update-server --precheck
[root@abdu1 bin]# dbcli list-jobs

  • Apply the patch by using the dbcli update-server command. Note the Job Id
 

[root@abdu1 log]# dbcli update-server

[root@abdu1 log]#

[root@abdu1 log]# dbcli describe-job -i fa0996a6-7f99-48b2-92dc-5c1fb8e20481
[root@abdu1 log]# dbcli list-jobs
[root@abdu1 log]# dbcli describe-component

  • Now, we can start the precheck for the database home by using the dbcli update-dbhome command with -p argument . Note the Job Id.

[root@abdu1 log]# dbcli list-dbhomes
[root@abdu1 log]# dbcli update-dbhome -i c177404f-d22e-46b5-95ac-28ed5b2da50d -p
[root@abdu1 log]# dbcli list-jobs


  • Apply the patch by using the dbcli update-dbhome command. Note the Job Id.

[root@abdu1 log]# dbcli update-dbhome -i c177404f-d22e-46b5-95ac-28ed5b2da50d

[root@abdu1 log]#

 [root@abdu1 log]# dbcli describe-job -i 1de24101-07e0-4031-835d-de912c35656f
[root@abdu1 log]#
 
[root@abdu1 log]# dbcli list-jobs
[root@abdu1 log]# dbcli describe-job -i 1de24101-07e0-4031-835d-de912c35656f
 [root@abdu1 log]# dbcli describe-component
 
[root@abdu1 log]# dbcli list-databases




Exacloud patching using exadbcpatchmulti

1)  list patches:
/var/opt/oracle/exapatch/exadbcpatchmulti -list_patches -oh=sphw1-oz9nd1:/u02/app/oracle/product/19.0.0.0/dbhome_10
 
2)  take tar backup of onbuatc on both nodes in /acfs02/JULY_PSU_DBBACKUP:

node1:
nohup tar -pcvzf /acfs02/JULY_PSU_DBBACKUP/db19000_home_10_sphw1-oz9nd1_$(date "+%m-%d-%Y:%R:%S").tar.gz  /u02/app/oracle/product/19.0.0.0/dbhome_10 > /acfs02/JULY_PSU_DBBACKUP/db19000_dbhome_10_sphw1-oz9nd1.log &
 
node2:
nohup tar -pcvzf /acfs02/JULY_PSU_DBBACKUP/db19000_home_10_sphw1-oz9nd2_$(date "+%m-%d-%Y:%R:%S").tar.gz  /u02/app/oracle/product/19.0.0.0/dbhome_10 > /acfs02/JULY_PSU_DBBACKUP/db19000_dbhome_10_sphw1-oz9nd2.log &
 

3)  perform prechecks as root user:(do not perform prechecks at the same time on both nodes   

node1:
/var/opt/oracle/exapatch/exadbcpatchmulti -precheck_async 32895426 -instance1=sphw1-oz9nd1:/u02/app/oracle/product/19.0.0.0/dbhome_10
node2:
/var/opt/oracle/exapatch/exadbcpatchmulti -precheck_async 32895426 -instance1=sphw1-oz9nd2:/u02/app/oracle/product/19.0.0.0/dbhome_10
 
If any conflicting patch is there, we need to first check why and when that patch is applied, if it is removable and latest version of it available in 
support, we can rollback that conflicting patch rollback patch in rolling fashion:
on node1:
->make db down 
->rollback command: 
/u02/app/oracle/product/19.0.0.0/dbhome_10/OPatch/opatch rollback -id 33144001
->up the db nd check services
->perform same on n2
and 
try running precheck again on both nodes one after the other.
 
 
4) Put blackout for ONBUATC on both nodes for 6-8 hrs:
 


5)  Apply patch as root user:
nohup /var/opt/oracle/exapatch/exadbcpatchmulti -apply_async 32895426 -instance1=10.18.160.252:/u02/app/oracle/product/19.0.0.0/dbhome_10 &
node2:
nohup /var/opt/oracle/exapatch/exadbcpatchmulti -apply_async 32895426 -instance1=10.18.160.243:/u02/app/oracle/product/19.0.0.0/dbhome_10 &
(-run_datasql=1    --> to be added only for primary dbs not for standbys)
 
node1:
6) check 'list patches', patch must be applied
opatch lspatches
 


7)  now check db service nd pdb services
srvctl status database -d PRDFIKC_phx2fn
srvctl status service -d PRDFIKC_phx2fn
 

8)  proceed patch apply on node 2 and check services post patching



Below is  out of Box Patching Method Used . 

1) List Patch Images 
[root@hostname1 ~]# dbaascli cswlib showImages

2) Create New Home 
[root@hostname1 ~]# dbaascli dbhome create --version 19000

3) Patch Pre check on New Home 
[root@hostname1 ~]# dbaascli dbhome patch --oracleHome /u02/app/oracle/product/19.0.0.0/dbhome_12 --targetVersion 19.11.0.0.0 --executePrereqs

4) Patch New Home 
[root@hostname1 ~]# dbhome patch --oracleHome /u02/app/oracle/product/19.0.0.0/dbhome_12 --targetVersion 19.11.0.0.0 --skipDatapatch

5) Move Database to New Home
[root@hostname1 ~]# dbaascli database move --dbname testdb01 --ohome /u02/app/oracle/product/19.0.0.0/dbhome_12

6) Apply data patch
[oracle@hostname1 OPatch]$  $ORACLE_HOME/OPatch/datapatch -verbose

7) Purge Old Home .
[root@hostname1 ~]# dbaascli dbhome purge



References : 

https://docs.oracle.com/en/cloud/paas/exadata-cloud/csexa/apply-patch.html#GUID-50BDEF7D-A30E-4B32-BAE7-486538413E2D
https://docs.oracle.com/en-us/iaas/Content/Database/Tasks/patchingDatabase.htm
https://docs.oracle.com/en-us/iaas/Content/Database/Tasks/exapatching.htm
https://docs.oracle.com/en-us/iaas/Content/Database/Tasks/examanagingpatching.htm
https://docs.oracle.com/en-us/iaas/Content/Database/Tasks/patchingDB.htm
https://docs.oracle.com/en/cloud/cloud-at-customer/exadata-cloud-at-customer/exacc/patching.html


No comments:

Post a Comment