Sunday, November 3, 2024

Oracle 23ai DB new feature - True Cache


    Oracle Database 23ai has come up with many new feature. One of the important feature is True cache. In general Database comes with many cache like DB Buffer cache, Library cache,  Redo log Buffer cache, PL/SQL Function result cache, Smart Flash cache, SubQuery caching, In Memory option. All the said caches above are built within the cache. True cache is different from these cache. It is getting build outside of database. 

True cache is a read only instance and its has its own buffer. It will collect the data from the source database and keeps updating the data to maintain sync with original data located in the source database.  The read only instance can be at source location or it can be at location closer to the customer region.

For example the database holds data of multiple region customers and database connection will be happening from different parts of the world. We need to provide same database performance to all customers. For application we have seen Redis cache which does this activity. But for database we need similar caching concept to aggregate database retrieval performance which is provided by True cache.

Consider the above scenario. Database is physically located in US and it is accessed by APAC customers. The data retrieval and performance should not be affected because of the distance between customer location and database. So we need to cache the data in  APAC region. But we need only APAC region customer's data. So caching needs to be done for subset of data. Also the cached data should be read consistent and also updates happening in Main database should be reflected immediately in Cache.

True cache provides all the above features. It may look similar to Active Data Guard. But it is different.



True cache Installation

True cache can be installed either using DBCA or Manual method.

DBCA:

For configuring True cache first we need to collect details of Primary or Source database and configure True cache using the collected details. We call the Primary database details as Blob. Kindly note it is not related to Blob data type 😀

First step is generating BLOB from source database.

$ORACLE_HOME/bin/dbca -configureDatabase -prepareTrueCacheConfigFile -sourceDB <primary_db_sid_or_db_unique_name> -trueCacheBlobLocation <primary_db_config_blob_path> -silent

PrepareTrueCacheConfig parameter directs DBCA to create Blob at the location mentioned in trueCacheBlobLocation parameter. DBCA will package the password file (and optional TDE wallet) into a configuration BLOB file. 
Once the blob got created, it can be copied to True cache instance creation location. It could be local or remote.

$ORACLE_HOME/bin/dbca -createTrueCache -gdbName true_cache_global_name -sid true_cache_sid -sourceDBConnectionString primary_db_easy_connect_string -trueCacheBlobFromSourceDB true_cache_config_blob_path -sgaTargetInMB sga_memory_size -pgaAggregateTargetInMB pga_memory_size -tdeWalletLoginType AUTO_LOGIN -listeners listener_name -silent

trueCacheBlobFromSourceDB parameter denotes the location of copied BLOB file.
sourceDBConnectionString parameter looks for Primary database connection string

True cache is an instance and requires SGA and PGA which can be specified through parameters.
sgaTargetInMB, pgaAggregateTargetInMB

Manual Method

The steps are similar to physical standby creation. Copy password file and  init parameter file to True cache instance. At true cache instance, the init parameter file will have entries similar to physical standby database. db_name, db_unique_name, fal_server, fal_client, instance_name, local_listener, remote_listener, sga_target parameters to be specified. 

true_cache=true  ===> Additional parameter to enable True cache behavior.


Configure local listener at primary and true cache (static entry in listener.ora file) instance to establish the connectivity.

Connect to the True Cache instance using SQL*Plus:

sqlplus / as SYSDBA

Start the instance in NOMOUNT state using the PFILE:

STARTUP NOMOUNT PFILE=<path_to_init_parameter_file>;

Create the True cache. This step will create the control files, mount the instance, and start the database in read-only mode.

SQL> CREATE TRUE CACHE;

Additional Configuration:

Create standby redo logs to receive redo log entries from the primary database.
Update the LOG_ARCHIVE_DEST parameter in the primary database to configure the destination for redo log transmission.


Tuesday, May 28, 2024

Oracle Database free 23ai installation on Linux 8.x (Redhat, Oracle Linux)


The Database Installation RPM can be downloaded from https://download.oracle.com/otn-pub/otn_software/db-free/oracle-database-free-23ai-1.0-1.el8.x86_64.rpm

For other Linux versions the download link is available at https://www.oracle.com/database/free/get-started/


[root@oralinux87 oracle]# ll

total 1345920

-rw-r--r--. 1 root   root     1378076936 May 27 17:46 oracle-database-free-23ai-1.0-1.el8.x86_64.rpm

-rw-r--r--. 1 oracle oinstall     141655 May 27 17:34 wget-log


Install Database 23ai using dnf command.


[root@oralinux87 oracle]# dnf install -y oracle-database-free-23ai-1.0-1.el8.x86_64.rpm

Last metadata expiration check: 0:05:29 ago on Mon 27 May 2024 05:42:05 PM CDT.

Dependencies resolved.

=============================================================================================================================================================================================================================================

 Package                                                                Architecture                                  Version                                                     Repository                                            Size

=============================================================================================================================================================================================================================================

Installing:

 oracle-database-free-23ai                                              x86_64                                        1.0-1                                                       @commandline                                         1.3 G

Installing dependencies:

 compat-openssl10                                                       x86_64                                        1:1.0.2o-4.el8_6                                            ol8_appstream                                        1.1 M

 ksh                                                                    x86_64                                        20120801-267.0.1.el8                                        ol8_appstream                                        923 k

 oracle-database-preinstall-23ai                                        x86_64                                        1.0-2.el8                                                   ol8_appstream                                         30 k


Transaction Summary

=============================================================================================================================================================================================================================================

Install  4 Packages


Total size: 1.3 G

Total download size: 2.1 M

Installed size: 3.6 G

Downloading Packages:

(1/3): oracle-database-preinstall-23ai-1.0-2.el8.x86_64.rpm                                                                                                                                                  172 kB/s |  30 kB     00:00

(2/3): compat-openssl10-1.0.2o-4.el8_6.x86_64.rpm                                                                                                                                                            2.2 MB/s | 1.1 MB     00:00

(3/3): ksh-20120801-267.0.1.el8.x86_64.rpm                                                                                                                                                                   373 kB/s | 923 kB     00:02

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Total                                                                                                                                                                                                        848 kB/s | 2.1 MB     00:02

Running transaction check

Transaction check succeeded.

Running transaction test

Transaction test succeeded.

Running transaction

  Preparing        :                                                                                                                                                                                                                     1/1

  Installing       : ksh-20120801-267.0.1.el8.x86_64                                                                                                                                                                                     1/4

  Running scriptlet: ksh-20120801-267.0.1.el8.x86_64                                                                                                                                                                                     1/4

  Installing       : compat-openssl10-1:1.0.2o-4.el8_6.x86_64                                                                                                                                                                            2/4

  Running scriptlet: compat-openssl10-1:1.0.2o-4.el8_6.x86_64                                                                                                                                                                            2/4

  Installing       : oracle-database-preinstall-23ai-1.0-2.el8.x86_64                                                                                                                                                                    3/4

  Running scriptlet: oracle-database-free-23ai-1.0-1.x86_64                                                                                                                                                                              4/4

  Installing       : oracle-database-free-23ai-1.0-1.x86_64                                                                                                                                                                              4/4

  Running scriptlet: oracle-database-free-23ai-1.0-1.x86_64                                                                                                                                                                              4/4

[INFO] Executing post installation scripts...

[INFO] Oracle home installed successfully and ready to be configured.

To configure Oracle Database Free, optionally modify the parameters in '/etc/sysconfig/oracle-free-23ai.conf' and then run '/etc/init.d/oracle-free-23ai configure' as root.


  Running scriptlet: oracle-database-preinstall-23ai-1.0-2.el8.x86_64                                                                                                                                                                    4/4

  Running scriptlet: oracle-database-free-23ai-1.0-1.x86_64                                                                                                                                                                              4/4

  Verifying        : compat-openssl10-1:1.0.2o-4.el8_6.x86_64                                                                                                                                                                            1/4

  Verifying        : ksh-20120801-267.0.1.el8.x86_64                                                                                                                                                                                     2/4

  Verifying        : oracle-database-preinstall-23ai-1.0-2.el8.x86_64                                                                                                                                                                    3/4

  Verifying        : oracle-database-free-23ai-1.0-1.x86_64                                                                                                                                                                              4/4


Installed:

  compat-openssl10-1:1.0.2o-4.el8_6.x86_64                   ksh-20120801-267.0.1.el8.x86_64                   oracle-database-free-23ai-1.0-1.x86_64                   oracle-database-preinstall-23ai-1.0-2.el8.x86_64


Complete!

[root@oralinux87 oracle]#



Configure the database using /etc/init.d/oracle-free-23ai. It will create a PDB called FREEPDB1 in 23ai database and the ask for the password. The given password is common for sys, system and pdbadmin users.

The configuration with default settings as below. If we want to modify the settings then edit the /etc/sysconfig/oracle-free-23ai.conf file.

# LISTENER PORT used Database listener, Leave empty for automatic port assignment
LISTENER_PORT=

# Character set of the database
CHARSET=AL32UTF8

# Database file directory
# If not specified, database files are stored under Oracle base/oradata
DBFILE_DEST=

# DB Domain name
DB_DOMAIN=

# Configure TDE
CONFIGURE_TDE=false

# Encrypt Tablespaces list, Leave empty for user tablespace alone or provide ALL for encrypting all tablespaces
# For specific tablespaces use SYSTEM:true,SYSAUX:false
ENCRYPT_TABLESPACES=

# SKIP Validations, memory, space
SKIP_VALIDATIONS=FALSE


[root@oralinux87 oracle]# ls -lrt /etc/init.d/

total 48

-rw-r--r--. 1 root root 18434 Aug 10  2022 functions

-rw-r--r--. 1 root root  1161 Nov  9  2022 README

-r-xr-xr-x. 1 root root 20518 Apr 24 14:46 oracle-free-23ai

[root@oralinux87 oracle]# /etc/init.d/oracle-free-23ai configure

Specify a password to be used for database accounts. Oracle recommends that the password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9]. Note that the same password will be used for SYS, SYSTEM and PDBADMIN accounts:

Confirm the password:

Configuring Oracle Listener.

Listener configuration succeeded.

Configuring Oracle Database FREE.

Enter SYS user password:

**************

Enter SYSTEM user password:

*************

Enter PDBADMIN User Password:

************

Prepare for db operation

7% complete

Copying database files

29% complete

Creating and starting Oracle instance

30% complete

33% complete

36% complete

39% complete

43% complete

Completing Database Creation

47% complete

49% complete

50% complete

Creating Pluggable Databases

54% complete

71% complete

Executing Post Configuration Actions

93% complete

Running Custom Scripts

100% complete

Database creation complete. For details check the logfiles at:

 /opt/oracle/cfgtoollogs/dbca/FREE.

Database Information:

Global Database Name:FREE

System Identifier(SID):FREE

Look at the log file "/opt/oracle/cfgtoollogs/dbca/FREE/FREE.log" for further details.


Connect to Oracle Database using one of the connect strings:

     Pluggable database: oralinux87/FREEPDB1

     Multitenant container database: oralinux87


We need to set ORACLE environment variables to access the executables. For that we need to Oracle database home location.

It can be identified from Central inventory and its location can be found using /etc/oraInst.loc file.


[root@oralinux87 oracle]# cat /etc/oraInst.loc

inventory_loc=/opt/oracle/oraInventory    -----------> Central Inventory location.

inst_group=oinstall


[root@oralinux87 oracle]# cd /opt/oracle/oraInventory

[root@oralinux87 oraInventory]# ls -lrt

total 12

-rwxrwx---. 1 oracle oinstall 1644 May 27 17:53 orainstRoot.sh

-rw-rw----. 1 oracle oinstall   59 May 27 17:53 oraInst.loc

drwxrwx---. 2 oracle oinstall 4096 May 27 17:53 logs

drwxrwx---. 2 oracle oinstall   60 May 27 17:53 ContentsXML

[root@oralinux87 oraInventory]# cd ContentsXML/

[root@oralinux87 ContentsXML]# ll

total 12

-rw-rw----. 1 oracle oinstall 300 May 27 17:53 comps.xml

-rw-rw----. 1 oracle oinstall 479 May 27 17:53 inventory.xml   ---> It has all oracle home details.

-rw-rw----. 1 oracle oinstall 292 May 27 17:53 libs.xml

[root@oralinux87 ContentsXML]# cat inventory.xml

<?xml version="1.0" standalone="yes" ?>

<!-- Copyright (c) 1999, 2024, Oracle and/or its affiliates.

All rights reserved. -->

<!-- Do not modify the contents of this file by hand. -->

<INVENTORY>

<VERSION_INFO>

   <SAVED_WITH>12.2.0.9.0</SAVED_WITH>

   <MINIMUM_VER>2.1.0.6.0</MINIMUM_VER>

</VERSION_INFO>

<HOME_LIST>

<HOME NAME="OraDBHome23aiFree" LOC="/opt/oracle/product/23ai/dbhomeFree" TYPE="O" IDX="1"/>      ---> We could see Oracle 23ai Installation location.

</HOME_LIST>

<COMPOSITEHOME_LIST>

</COMPOSITEHOME_LIST>

</INVENTORY>


[root@oralinux87 ContentsXML]# cd /opt/oracle/product/23ai/dbhomeFree

[root@oralinux87 dbhomeFree]# pwd

/opt/oracle/product/23ai/dbhomeFree

[root@oralinux87 dbhomeFree]# echo $ORACLE_HOME


[root@oralinux87 dbhomeFree]# sudo su - oracle

[oracle@oralinux87 ~]$ export ORACLE_HOME=/opt/oracle/product/23ai/dbhomeFree

[oracle@oralinux87 ~]$ export PATH=$ORACLE_HOME/bin:$PATH

[oracle@oralinux87 ~]$ sqlplus sys@localhost:1521/FREEPDB1 as sysdba


SQL*Plus: Release 23.0.0.0.0 - Production on Mon Version 23.4.0.24.05

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

Enter password:

Connected to:

Oracle Database 23ai Free Release 23.0.0.0.0 - Develop, Learn, and Run for Free

Version 23.4.0.24.05


SQL> show pdbs


    CON_ID CON_NAME                       OPEN MODE  RESTRICTED

---------- ------------------------------ ---------- ----------

         3 FREEPDB1                       READ WRITE NO

SQL>


Tuesday, April 23, 2024

OCI - Automatic Scale Up/Down shape of DBCS 2 Node RAC instance 


DBCS provides a managed environment where tasks such as backup, patching, and database parameter configuration are handled seamlessly. Depending on the allocated Oracle CPU (OCPU), DBCS automatically configures the database memory parameters to optimize performance.
Along with GUI, OCI has commands to perform all desired functionalities. Through OCI commands we can perform Scale up/down of DBCS capacity.
https://docs.oracle.com/en-us/iaas/Content/API/SDKDocs/cliinstall.htm

In accordance with the requirement, the configuration (OCPU) of DBCS needs to be adjusted based on business hours. This adjustment aims for improved cost optimization and resource utilization. When the OCPU is modified, it triggers a server reboot. Here the database is set up with RAC (Real Application Cluster), ensuring high availability at the instance level. Server reboots occur sequentially on the mapped servers, minimizing downtime during OCPU changes.

Prerequisites

1)     A Bastion host which has connectivity with DBCS server. The Scale up/down script will be scheduled in this server.

2)     OCI command line utility will be installed in the Bastion host. Scale up/down activity will be done via command line.

3)     OCI Command line utility will be configured with User credentials who has access to DBCS environment with privileges to scale up/down.

Creation of Bastion Host

Bastion host is a compute instance. In this example we will consider Linux compute instance. This instance should be running 24*7, hence it could be a Free tier instance or an instance with minimal OCPU and memory configuration, that will optimize the cost. We need this instance to install OCI command line and schedule the script execution.

OCI Command Line Installation

OCI Command line (CLI) utility is the platform to execute all OCI commands. First we need to install OCI CLI and then configure it.

Here’s the example of OCI CLI installation in Linux instance. The installation has proceeded with default settings (Press Enter key to go with default settings for the installation.). In the below output Bold font denotes where our input or Enter key (for default settings) is expected.

[opc@hub-inst ~]$ sudo su -

Last login: Sun Jul 30 12:21:29 GMT 2023 on pts/0

 

[root@hub-inst ~]# bash -c "$(curl -L https://raw.githubusercontent.com/oracle/oci-cli/master/scripts/install/install.sh)"

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current

                                 Dload  Upload   Total   Spent    Left  Speed

100 16926  100 16926    0     0  29539      0 --:--:-- --:--:-- --:--:-- 29487

 

    ******************************************************************************

    You have started the OCI CLI Installer in interactive mode. If you do not wish

    to run this in interactive mode, please include the --accept-all-defaults option.

    If you have the script locally and would like to know more about

    input options for this script, then you can run:

    ./install.sh -h

    If you would like to know more about input options for this script, refer to:

    https://github.com/oracle/oci-cli/blob/master/scripts/install/README.rst

    ******************************************************************************

Downloading Oracle Cloud Infrastructure CLI install script from https://raw.githubusercontent.com/oracle/oci-cli/v3.2.1/scripts/install/install.py to /tmp/oci_cli_install_tmp_btaB.

 

curl: (35) OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to raw.githubusercontent.com:443

######################################################################### 100.0%

Falling back to previous install.py script URL - https://raw.githubusercontent.com/oracle/oci-cli/v2.22.0/scripts/install/install.py

Running install script.

python3 /tmp/oci_cli_install_tmp_btaB

-- Verifying Python version.

-- Python version 3.6.8 okay.

 

===> In what directory would you like to place the install? (leave blank to use '/root/lib/oracle-cli'):

-- Creating directory '/root/lib/oracle-cli'.

-- We will install at '/root/lib/oracle-cli'.

 

===> In what directory would you like to place the 'oci' executable? (leave blank to use '/root/bin'):

-- Creating directory '/root/bin'.

-- The executable will be in '/root/bin'.

 

===> In what directory would you like to place the OCI scripts? (leave blank to use '/root/bin/oci-cli-scripts'):

-- Creating directory '/root/bin/oci-cli-scripts'.

-- The scripts will be in '/root/bin/oci-cli-scripts'.

 

===> Currently supported optional packages are: ['db (will install cx_Oracle)']

What optional CLI packages would you like to be installed (comma separated names; press enter if you don't need any optional packages)?:

-- The optional packages installed will be ''.

-- Trying to use python3 venv.

-- Executing: ['/usr/bin/python3', '-m', 'venv', '/root/lib/oracle-cli']

-- Executing: ['/root/lib/oracle-cli/bin/pip', 'install', '--upgrade', 'pip']

Collecting pip

  Downloading https://files.pythonhosted.org/packages/a4/6d/6463d49a933f547439d6b5b98b46af8742cc03ae83543e4d7688c2420f8b/pip-21.3.1-py3-none-any.whl (1.7MB)

    100% |████████████████████████████████| 1.7MB 931kB/s

Installing collected packages: pip

  Found existing installation: pip 9.0.3

    Uninstalling pip-9.0.3:

      Successfully uninstalled pip-9.0.3

Successfully installed pip-21.3.1

You are using pip version 21.3.1, however version 23.2.1 is available.

You should consider upgrading via the 'pip install --upgrade pip' command.

-- Executing: ['/root/lib/oracle-cli/bin/pip', 'install', '--cache-dir', '/tmp/tmpv97gabpx', 'wheel', '--upgrade']

Collecting wheel

  Downloading wheel-0.37.1-py2.py3-none-any.whl (35 kB)

Installing collected packages: wheel

Successfully installed wheel-0.37.1

-- Executing: ['/root/lib/oracle-cli/bin/pip', 'install', '--cache-dir', '/tmp/tmpv97gabpx', 'oci_cli', '--upgrade']

Collecting oci_cli

  Downloading oci_cli-3.33.3-py3-none-any.whl (40.8 MB)

     |████████████████████████████████| 40.8 MB 39.3 MB/s           

Collecting cryptography<42.0.0,>=3.2.1

  Downloading cryptography-40.0.2-cp36-abi3-manylinux_2_28_x86_64.whl (3.7 MB)

     |████████████████████████████████| 3.7 MB 84.9 MB/s           

Collecting PyYAML<=6.0.1,>=5.4

  Downloading PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (677 kB)

     |████████████████████████████████| 677 kB 86.3 MB/s           

Collecting pyOpenSSL<24.0.0,>=17.5.0

  Downloading pyOpenSSL-23.2.0-py3-none-any.whl (59 kB)

     |████████████████████████████████| 59 kB 13.0 MB/s           

Collecting six>=1.15.0

  Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)

Collecting prompt-toolkit==3.0.29

  Downloading prompt_toolkit-3.0.29-py3-none-any.whl (381 kB)

     |████████████████████████████████| 381 kB 81.2 MB/s           

Collecting click==8.0.4

  Downloading click-8.0.4-py3-none-any.whl (97 kB)

     |████████████████████████████████| 97 kB 14.2 MB/s           

Collecting pytz>=2016.10

  Downloading pytz-2023.3.post1-py2.py3-none-any.whl (502 kB)

     |████████████████████████████████| 502 kB 81.2 MB/s           

Collecting oci==2.112.3

  Downloading oci-2.112.3-py3-none-any.whl (23.0 MB)

     |████████████████████████████████| 23.0 MB 83.5 MB/s           

Collecting certifi

  Downloading certifi-2023.7.22-py3-none-any.whl (158 kB)

     |████████████████████████████████| 158 kB 88.5 MB/s           

Collecting python-dateutil<3.0.0,>=2.5.3

  Downloading python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)

     |████████████████████████████████| 247 kB 77.1 MB/s           

Collecting jmespath==0.10.0

  Downloading jmespath-0.10.0-py2.py3-none-any.whl (24 kB)

Collecting arrow>=1.0.0

  Downloading arrow-1.2.3-py3-none-any.whl (66 kB)

     |████████████████████████████████| 66 kB 9.8 MB/s            

Collecting terminaltables==3.1.0

  Downloading terminaltables-3.1.0.tar.gz (12 kB)

  Preparing metadata (setup.py) ... done

Collecting importlib-metadata

  Downloading importlib_metadata-4.8.3-py3-none-any.whl (17 kB)

Collecting circuitbreaker<2.0.0,>=1.3.1

  Downloading circuitbreaker-1.4.0.tar.gz (9.7 kB)

  Preparing metadata (setup.py) ... done

Collecting wcwidth

  Downloading wcwidth-0.2.8-py2.py3-none-any.whl (31 kB)

Collecting typing-extensions

  Downloading typing_extensions-4.1.1-py3-none-any.whl (26 kB)

Collecting cffi>=1.12

  Downloading cffi-1.15.1-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (402 kB)

     |████████████████████████████████| 402 kB 80.3 MB/s           

Collecting pycparser

  Downloading pycparser-2.21-py2.py3-none-any.whl (118 kB)

     |████████████████████████████████| 118 kB 91.5 MB/s           

Collecting zipp>=0.5

  Downloading zipp-3.6.0-py3-none-any.whl (5.3 kB)

Building wheels for collected packages: terminaltables, circuitbreaker

  Building wheel for terminaltables (setup.py) ... done

  Created wheel for terminaltables: filename=terminaltables-3.1.0-py3-none-any.whl size=15355 sha256=0245771b1bb2c8736599f7b51b5e4c74bab7be3947d94682ee6a465b4da07ad9

  Stored in directory: /tmp/tmpv97gabpx/wheels/86/1b/58/c23af2fe683acd8edc15d5a1268f0242be1ff2cf827fe34737

  Building wheel for circuitbreaker (setup.py) ... done

  Created wheel for circuitbreaker: filename=circuitbreaker-1.4.0-py3-none-any.whl size=7506 sha256=e2f78db636915df68f248a876f198e30c4ab352e67608d876f114b64bbaf6e3c

  Stored in directory: /tmp/tmpv97gabpx/wheels/46/17/98/db2eb826e4a98da672cffe66ec16838182cde0cf19ad2c0c70

Successfully built terminaltables circuitbreaker

Installing collected packages: pycparser, cffi, zipp, typing-extensions, six, cryptography, wcwidth, pytz, python-dateutil, pyOpenSSL, importlib-metadata, circuitbreaker, certifi, terminaltables, PyYAML, prompt-toolkit, oci, jmespath, click, arrow, oci-cli

Successfully installed PyYAML-6.0.1 arrow-1.2.3 certifi-2023.7.22 cffi-1.15.1 circuitbreaker-1.4.0 click-8.0.4 cryptography-40.0.2 importlib-metadata-4.8.3 jmespath-0.10.0 oci-2.112.3 oci-cli-3.33.3 prompt-toolkit-3.0.29 pyOpenSSL-23.2.0 pycparser-2.21 python-dateutil-2.8.2 pytz-2023.3.post1 six-1.16.0 terminaltables-3.1.0 typing-extensions-4.1.1 wcwidth-0.2.8 zipp-3.6.0

 

===> Modify profile to update your $PATH and enable shell/tab completion now? (Y/n):

 

===> Enter a path to an rc file to update (file will be created if it does not exist) (leave blank to use '/root/.bashrc'):

-- Backed up '/root/.bashrc' to '/root/.bashrc.backup'

-- Tab completion set up complete.

-- If tab completion is not activated, verify that '/root/.bashrc' is sourced by your shell.

--

-- ** Run `exec -l $SHELL` to restart your shell. **

--

-- Installation successful.

-- Run the CLI with /root/bin/oci --help

[root@hub-inst ~]#

 

Currently only command line utility is installed. It needs to be configured with appropriate credentials. Below information is required to configure it.

User OCID

Tenancy OCID

SSH Public Key/Private Key pair

Home region

User OCID can be collected from user settings

 


 





In the user settings page you can find OCID of the user.

 

In the tenancy details page we can find Tenancy OCID

 


SSH key pair can be created using SSH-Keygen utility or Lets the CLI configuration create it for us and we can upload it to our profile later.

At this stage we have required details. Lets proceed with CLI configuration.

Configuration can be invoked via oci setup config.

[root@hub-inst ~]# oci setup config

/root/lib/oracle-cli/lib64/python3.6/site-packages/oci/_vendor/httpsig_cffi/sign.py:10: CryptographyDeprecationWarning: Python 3.6 is no longer supported by the Python core team. Therefore, support for it is deprecated in cryptography. The next release of cryptography will remove support for Python 3.6.

  from cryptography.hazmat.backends import default_backend  # noqa: F401

    This command provides a walkthrough of creating a valid CLI config file.

 

    The following links explain where to find the information required by this

    script:

 

    User API Signing Key, OCID and Tenancy OCID:

 

        https://docs.cloud.oracle.com/Content/API/Concepts/apisigningkey.htm#Other

 

    Region:

 

        https://docs.cloud.oracle.com/Content/General/Concepts/regions.htm

 

    General config documentation:

 

        https://docs.cloud.oracle.com/Content/API/Concepts/sdkconfig.htm

 

 

Enter a location for your config [/root/.oci/config]:

Enter a user OCID: ocid1.user.oc1..aaaaaaaazvaaftljvqenwdcwxxxxxxxxxxxxxxxxxxxxxxxx

Enter a tenancy OCID: ocid1.tenancy.oc1..aaaaaaaalylrk6bjiuxqryukd6jrlxgfbwxxxxxxxxxxxxxx

Enter a region by index or name(e.g.

1: af-johannesburg-1, 2: ap-chiyoda-1, 3: ap-chuncheon-1, 4: ap-dcc-canberra-1, 5: ap-hyderabad-1,

6: ap-ibaraki-1, 7: ap-melbourne-1, 8: ap-mumbai-1, 9: ap-osaka-1, 10: ap-seoul-1,

11: ap-singapore-1, 12: ap-sydney-1, 13: ap-tokyo-1, 14: ca-montreal-1, 15: ca-toronto-1,

16: eu-amsterdam-1, 17: eu-dcc-dublin-1, 18: eu-dcc-dublin-2, 19: eu-dcc-milan-1, 20: eu-dcc-milan-2,

21: eu-dcc-rating-1, 22: eu-dcc-rating-2, 23: eu-frankfurt-1, 24: eu-frankfurt-2, 25: eu-jovanovac-1,

26: eu-madrid-1, 27: eu-madrid-2, 28: eu-marseille-1, 29: eu-milan-1, 30: eu-paris-1,

31: eu-stockholm-1, 32: eu-zurich-1, 33: il-jerusalem-1, 34: me-abudhabi-1, 35: me-dcc-muscat-1,

36: me-dubai-1, 37: me-jeddah-1, 38: mx-monterrey-1, 39: mx-queretaro-1, 40: sa-santiago-1,

41: sa-saopaulo-1, 42: sa-vinhedo-1, 43: uk-cardiff-1, 44: uk-gov-cardiff-1, 45: uk-gov-london-1,

46: uk-london-1, 47: us-ashburn-1, 48: us-chicago-1, 49: us-gov-ashburn-1, 50: us-gov-chicago-1,

51: us-gov-phoenix-1, 52: us-langley-1, 53: us-luke-1, 54: us-phoenix-1, 55: us-sanjose-1): us-ashburn-1

 

Do you want to generate a new API Signing RSA key pair? (If you decline you will be asked to supply the path to an existing key.) [Y/n]:

Enter a directory for your keys to be created [/root/.oci]:

Enter a name for your key [oci_api_key]:

Public key written to: /root/.oci/oci_api_key_public.pem

Enter a passphrase for your private key ("N/A" for no passphrase):

Repeat for confirmation:

Private key written to: /root/.oci/oci_api_key.pem

Fingerprint: 34:0b:9f:1d:f8:6a:9a:ab:4e:39:f3:04:52:df:de:71

Config written to /root/.oci/config

 

 

    If you haven't already uploaded your API Signing public key through the

    console, follow the instructions on the page linked below in the section

    'How to upload the public key':

 

        https://docs.cloud.oracle.com/Content/API/Concepts/apisigningkey.htm#How2

 

In the above example we provided user OCID, tenancy OCID and then asked CLI to create public and private key pair. This pair is required to authenticate with OCI before executing commands to make changes in OCI. The key pairs are stored in the default location /root/.oci/config directory.

[root@hub-inst ~]# cd /root/.oci

[root@hub-inst .oci]# ls -lrt

total 12

-rw-------. 1 root root  451 Oct  5 09:51 oci_api_key_public.pem

-rw-------. 1 root root 1704 Oct  5 09:51 oci_api_key.pem

-rw-------. 1 root root  296 Oct  5 09:51 config

[root@hub-inst .oci]# cat config

[DEFAULT]

user= ocid1.user.oc1..aaaaaaaazvaaftljvqenwdcwxxxxxxxxxxxxxxxxxxxxxxxx

fingerprint=34:0b:9f:1d:f8:6a:9a:ab:4e:39:f3:04:52:df:de:71

key_file=/root/.oci/oci_api_key.pem

tenancy= ocid1.tenancy.oc1..aaaaaaaalylrk6bjiuxqryukd6jrlxgfbwxxxxxxxxxxxxxx

region=us-ashburn-1

[root@hub-inst .oci]# cat oci_api_key_public.pem

-----BEGIN PUBLIC KEY-----

MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA1qfhu/XMxICzyB4eh3Vm

Bz3k9yiNZ7IGXu/F06Sb7XWw9bNBib/WzUFmZ3IdoRrGQX0jA0/ZJNhOkCdYFDKt

za3BprhyPMc8sIzukBDaNDS8EUX/HxeQ95KLhWpb/q3iXQfkxxP66QD0fj++tQHJ

nOMkNi2zOp0A7stvdePE4jBHmxDiggPdXYtxTzwah9A9v9NoqeD/UE2RcMqqLcLQ



yq8l0rgRBy1p/myN4uz4wmTGZtz8KpX1LGhZxzEDF4ezziqGpWN4MnB2wT51XtGT

Fy2r5XaYsdiIUr+xlPPBY859Ma2HXvl6qpBf2pgWowZ8SyrF00cIRWJGAGX+8o9L

8QIDAQAB

-----END PUBLIC KEY-----

Copy the public key (oci_api_key_public.pem) contents. Move to OCI user settings again, there we could find API keys in the resource section.


 

Click API Keys, in the right side we can find button  to add new API key.

Click Add API Key button and paste the copied Public key.

 


 

Click Add button, you can find Configuration File Preview.

 


 

The fingerprint value will be same as the value stored in /root/.oci/config file.

[root@hub-inst .oci]# cat config

[DEFAULT]

user= ocid1.user.oc1..aaaaaaaazvaaftljvqenwdcwxxxxxxxxxxxxxxxxxxxxxxxx

fingerprint=34:0b:9f:1d:f8:6a:9a:ab:4e:39:f3:04:52:df:de:71

key_file=/root/.oci/oci_api_key.pem

tenancy= ocid1.tenancy.oc1..aaaaaaaalylrk6bjiuxqryukd6jrlxgfbwxxxxxxxxxxxxxx

region=us-ashburn-1

At this stage we have configured the OCI command line, now lets execute the command to scale up/down DBCS. Right now a DBCS instance has 8 cores (2 node each with 4 OCPU), we are scaling down it by 6 cores (2 node each with 3 OCPU)

[root@scaleup-script ~]# oci db system update   --db-system-id ocid1.dbsystem.oc1.ap-hyderabad-1.anuhsljr43cggciaxxxxxxxxxxxx --cpu-core-count

6

 

Db-system-id is the OCID of the DBCS system

Output of above command

 

[root@scaleup-script ~]# oci db system update   --db-system-id ocid1.dbsystem.oc1.ap-hyderabad-1.anuhsljr43cggciaxxxxxxxxxxxxxxxx --cpu-core-count

6

/root/lib/oracle-cli/lib64/python3.6/site-packages/oci/_vendor/httpsig_cffi/sign.py:10: CryptographyDeprecationWarning: Python 3.6 is no longer supported by the Python core team. Therefore, support for it is deprecated in cryptography. The next release of cryptography will remove support for Python 3.6.

  from cryptography.hazmat.backends import default_backend  # noqa: F401

{

  "data": {

    "availability-domain": "VPLM:AP-HYDERABAD-1-AD-1",

    "backup-network-nsg-ids": null,

    "backup-subnet-id": null,

    "cluster-name": "BDB01",

    "compartment-id": "ocid1.compartment.oc1..aaaaaaaaezwwi6bptaaiz6y3x4ykh25xnhhrqxsni5rozgaoptqee56azgsa",

    "cpu-core-count": 8,

    "data-collection-options": {

      "is-diagnostics-events-enabled": true,

      "is-health-monitoring-enabled": false,

      "is-incident-logs-enabled": true

    },

    "data-storage-percentage": 80,

    "data-storage-size-in-gbs": 256,

    "database-edition": "ENTERPRISE_EDITION_EXTREME_PERFORMANCE",

    "db-system-options": {

      "storage-management": "ASM"

    },

    "defined-tags": {

      "Oracle-Tags": {

        "AutoDeleteAfterDays": "14",

        "CreatedBy": "oracleidentitycloudservice/XXXXXXXXX",

        "CreatedOn": "2023-09-05T05:46:51.934Z",

        "Purpose": "Personal Learning"

      }

    },

    "disk-redundancy": "HIGH",

    "display-name": "Trial_Base_DBCS_RAC",

    "domain": "sgtechsubnet.XXXXXXXX",

    "fault-domains": [

      "FAULT-DOMAIN-3",

      "FAULT-DOMAIN-2"

    ],

    "freeform-tags": {},

    "hostname": "bdb",

    "id": "ocid1.dbsystem.oc1.ap-hyderabad-1.anuhsljr43cggxxxxxxxxxxxxxxxxxxxxxxx",

    "iorm-config-cache": null,

    "kms-key-id": null,

    "last-maintenance-run-id": null,

    "last-patch-history-entry-id": null,

    "license-model": "LICENSE_INCLUDED",

    "lifecycle-details": null,

    "lifecycle-state": "UPDATING",

    "listener-port": 1521,

    "maintenance-window": null,

    "memory-size-in-gbs": 128,

    "next-maintenance-run-id": null,

    "node-count": 2,

    "nsg-ids": null,

    "os-version": null,

    "point-in-time-data-disk-clone-timestamp": null,

    "reco-storage-size-in-gb": 256,

    "scan-dns-name": "bdb-scan.sgtechsubnet.sgtechstudiovcn.oraclevcn.com",

    "scan-dns-record-id": "ocid1.vcndnsrecord.oc1.ap-hyderabad-1.abuhsljrdwnaywqyfloefxxxxxxxxxxxxx",

    "scan-ip-ids": [

      "ocid1.privateip.oc1.ap-hyderabad-1.aaaaaaaafq3byvycpyqc55244gk26exxxxxxxxxxxxxxxq",

      "ocid1.privateip.oc1.ap-hyderabad-1.aaaaaaaaahy6am5zqv2rivwgc6berz7gxxxxxxxxxxxxxq",

      "ocid1.privateip.oc1.ap-hyderabad-1.aaaaaaaasuq5xt7rj2umtnd7khv66vxxxxxxxxxxxxxxq"

    ],

    "shape": "VM.Standard.E4.Flex",

    "source-db-system-id": null,

    "sparse-diskgroup": null,

    "ssh-public-keys": [

      "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCZYwfG0aNB7aeL1kTyvEP8PuPoKXkq+P6XIqCHWM+i0FLIcrvcuO+1NmQYA+80FdIhScdW65gDz95ljga6hymJvPVd2W2rQuV+8TtuEXNDUqj5L5hwKU9VaoBv7yjOmFjMe/bfwiNe+4SXSuavlTkKGQhOOybHFS68+ZjLQX6e5K6wsfDKAuwMG1G24xzvHFhBybtvoLwBwYQXRhJ8wC8T/9mvjxrJdSgdfSZCVEozxleCclbXfAFxtHIRAgnyPC/QONvad+efVZGObSvdzUfhAIJz3xz9YkQhhX2FR8AlwHyvEofZRLgxJNfekPr1XcFEluO04MpkiEHIetIvnWAr ssh-key-2023-09-05"

    ],

    "storage-volume-performance-mode": "HIGH_PERFORMANCE",

    "subnet-id": "ocid1.subnet.oc1.ap-hyderabad-1.aaaaaaaauntg44nn67lmmyjrgbnsslxxxxxxxxxxxxxxxxxxxa",

    "time-created": "2023-09-05T05:46:52.417000+00:00",

    "time-zone": "UTC",

    "version": "19.20.0.0.0",

    "vip-ids": [

      "ocid1.privateip.oc1.ap-hyderabad-1.aaaaaaaaqymkk3euyc36ypchyxxxxxxxxxxxxxxxxja",

      "ocid1.privateip.oc1.ap-hyderabad-1.aaaaaaaa7xvxxk4sgoj755lu2d5xxxxxxxxxxxxa"

    ],

    "zone-id": "ocid1.dns-zone.oc1.ap-hyderabad-1.aaaaaaaa5zdzgqk6sre5gy4fmpxxxxxxxxxxxxxxxxxxxxxxxxsiq"

  },

  "etag": "83319cfa"

}

It will take maximum of 25 minutes to update the Core values in both the nodes. The above OCI command can be scripted as a batch file and scheduled via cron job.

[root@scaleup-script ~]# cat /root/scaleup.sh

/root/bin/oci db system update   --db-system-id ocid1.dbsystem.oc1.ap-hyderabad-1.anuhsljr43cggciapuy2nd2cfbblkxlzf2fgmpgyctohlfjhvkwg7dl3p7pa --cpu-core-count 8

 

[root@scaleup-script ~]# cat /root/scaledown.sh

/root/bin/oci db system update   --db-system-id ocid1.dbsystem.oc1.ap-hyderabad-1.anuhsljr43cggciapuy2nd2cfbblkxlzf2fgmpgyctohlfjhvkwg7dl3p7pa --cpu-core-count 4

Schedule it via cronjob for the desired timing.

[root@scaleup-script ~]# crontab -l

30 4 * * * /root/scaleup.sh

30 14 * * * /root/scaledown.sh
















 OCI IAM - OCI Command line - Uploading API Keys to User in Default and Custom Domain In our previous post, we explored how to create users ...