jueves, 23 de abril de 2020

Applying Patch in a DB System – Oracle Cloud Classic

In the next article, I will show you how to apply the latest patch to an Oracle Cloud Infrastructure Classic Database System using the command line tool dbaascli.

As you know, OCI Classic was the first version of Oracle Cloud, is a secure, reliable, low cost, standards-based infrastructure service.

We have two ways of patching a database:
  1. Using the Oracle Cloud GUI trough an Internet browser.
  2. Using the console tool dbaascli.
Boot methods are secure and valid, but I always prefer to use the command console tool because I have direct access to the status and logs in case any issue during the process.

During this article I will use the Cloud GUI console for some tasks, so we need access to the cloud tenancy and access to the Database resource. So, let’s begin.

First step, not always needed but strongly recommended: Create a backup!

Go to the Database classic option and click on Instances option. Inside the Instance option, select the database instances you want to patch and click on the name to enter to the administration console.


On the Admin Console, the step is as simple as Click on the Backup Now button. A confirmation windows will ask if we want to keep the backup taken forever, select No (default) and click on Backup.



Wait until the backup finished. The time needed for the backup will depend on the database size. The database status will change to Backing up during the process and will change to Available when the backup finished.

The last step was the only action executed by the GUI console. Now, we access the server residing the database using the OPC user and the we change to the root user. All the actions performed now must be executed using the root user.

ssh opc@130.XXX.103.40
[opc@prd10dbe ~]$
[opc@prd10dbe ~]$ sudo su -
[root@prd10dbe ~]#

Now, Im going to update my command line tool dbaascli, this step is equivalent to update the Opatch tool when we are using on premise databases.

[root@prd10dbe ~]# dbaascli patch tools list
DBAAS CLI version 18.4.6.1.0
Executing command patch tools list
Current Patchid : 18.4.6.1.0_191003.1238
No applicable tools patches are available


In this case, we can see a message saying that there are no Applicable tools patches available. if updates are available a message will appear with the patch ID and the command needed to apply the update, the message will be similar than:


Next step. Validate the patch, this step is similar than run an opatch prereq command.

[root@prd10dbe ~]# dbaascli patch db prereq -- patchid LATEST
DBAAS CLI version 18.4.6.1.0
Executing command patch db prereq -- patchid LATEST
INFO: DBCS patching
This might take some time, please take a look at file /var/opt/oracle/log/dbpatchm/dbpatchm.log for progress
Use of uninitialized value $imgsize in string eq at /var/opt/oracle/patch/../perl_lib/DBAAS/oss_patch.pm line 1538.
Use of uninitialized value $imgsize in concatenation (.) or string at /var/opt/oracle/patch/../perl_lib/DBAAS/oss_patch.pm line 1540.
Use of uninitialized value $dbimgsize_in_gb in numeric lt (<) at /var/opt/oracle/patch/dbpatchm line 2547.
Prereq check completed successfully, ready to apply patch

On the file dbpatchm.log we will find the result of the analysis, in this case the prereq check was successful. Please check the next step if the analysis fails.

(Optional step) If an error had found during the prereq check. We can check the dbpatchm.log file to find the patch id that may cause conflict with the latest patch. The message will be similar than:

ZOP-47: The patch(es) has supersets with other patches installed in the Oracle Home (or) among themselves.

Prereq "checkConflictAgainstOHWithDetail" failed.

Summary of Conflict Analysis:

There are no patches that can be applied now.

Following patches have conflicts. Please contact Oracle Support and get the merged patch of the patches :

26272761, 28662603

Conflicts/Supersets for each patch are:


Patch : 28662603

        Conflict with 26272761

If this is the case, we need to rollback the patch that is causing the conflict. So, we are going to use an old friend to resolve this, follow the steps below:
  • Enter to the oracle user: su – oracle
  • Stop the listener: lsnrctl stop
  • Stop the database: sqlplus / as sysdba, shutdown immediate;
  • Go to the opatch location: cd $ORACLE_HOME/opatch
  • And rollback the conflicting patch: ./opatch rollback -id 26272761
If the prereq step finished well, we can continue with this step. If a rollback patch operation was needed repeat the step #4 to precheck the patch again until the operation succeeds. So, now we can apply the patch.


[root@prd10dbe ~]# dbaascli patch db apply --patchid LATEST

DBAAS CLI version 18.4.6.1.0
Executing command patch db apply --patchid LATEST
INFO: DBCS patching
This might take some time, please take a look at file /var/opt/oracle/log/dbpatchm/dbpatchm.log for progress

Use of uninitialized value $imgsize in string eq at /var/opt/oracle/patch/../perl_lib/DBAAS/oss_patch.pm line 1538.

Use of uninitialized value $imgsize in concatenation (.) or string at /var/opt/oracle/patch/../perl_lib/DBAAS/oss_patch.pm line 1540.

Use of uninitialized value $dbimgsize_in_gb in numeric lt (<) at /var/opt/oracle/patch/dbpatchm line 2547.

catcon: ALL catcom-related output will be written to [/var/opt/oracle/log/dbpatchm/cdb_utlrp_catcom_21532.lst]
catcon: See [/var/opt/oracle/log/dbpatchm/cdb_utlrp_*.log] files for output generated by script.
catcon: See [/var/opt/oracle/log/dbpatchm/cdb_utlrp_*.lst] files for spool files, if any
catcon.pl: completed successfully

Patch installed successfully

We can monitor the file /var/opt/oracle/log/dbpatchm/dbpatchm.log during the patching process.

Note: the patching process will run in background so, don’t worry if you have any issues with your ssh session the process will finish by itself and you can check the status with the log file.
  • Once the patch finished successfully, we can perform some database validations:
    • Listener status
    • PDB’s open mode
    • Opatch inventory
    • Object status
Summary:

Patching an Oracle Infrastructure Cloud Classic Database Service is a simple process (maybe more than the on premise) than can be done by multiple choices. The way you choose will depend of your preferences and the type of control you desire. Just remember always keep your database updated.

1 comentario:

Oracle ACE Director Award - Deiby Gómez

Thanks #OracleACE Program for this awesome certificate recognizing the work I have done in the community for the last year. Looking forwa...