Create and Manage Exadata Cloud Clusters with CLI

Data Voyage by Jigar Doshi
5 min readApr 19, 2023

--

Create Exadata Cloud service Infrastructure and VM clusters using OCI CLI. Scale Exadata Cluster CPU & Memory online using OCI CLI

OCI Exadata Cloud Service (ExaCS) allows you to harness the power of Exadata in public cloud minus all the pains of physically managing the infrastructure and software stack.

With the release of X8M & X9M Exadata Cloud models, creating and scaling Exadata cluster is real breeze. The latest release of ExaCS also supports multiple VM clusters including Autonomous DB within same Infrastructure. This makes it very easy and convenient to manage and maintain multiple VM clusters. I often find myself creating Exadata infrastructure and VM clusters for customers or assisting customers in the process.

If you need to do something more than once, automate it. That’s the mantra of life.

On-demand scaling of CPU/Memory/Storage is one of the key features of the ExaCS. Instead of performing all the tasks from console, I have scripted them using OCI CLI without having to provide any OCID’s explicitly. This makes the script easy to use in day to day operations.

In this article I will describe steps and scripts to

  1. Create Exadata Infrastructure
  2. Create Exadata VM Cluster
  3. Online Scaling of CPU and Memory for Exadata VM Cluster

Create Exadata Infrastructure

Creating Exadata Infrastructure is the first step. VM cluster for hosting the databases can be created once Infrastructure is ready.

This script takes 4 command line input parameters namely Compartment Name, Display Name, Number of Compute and Storage servers (Min. 2 and 3 respectively)

create_exa.sh <CompartmentName> <Displayname> <Compute Count> <Storage Count>

Next step is to collect Compartment OCID and Availability Domain name

export Compocid=`oci iam compartment list --compartment-id-in-subtree true \
--all |jq -r ".data[] | select(.name == \"${compname}\") | .id"`

export ADname=`oci iam availability-domain list --all \
--compartment-id $Compocid --raw-output --query 'data[0].name'`

Next accept system shape name as user input. This can be parameterized if required. Due to various different shapes, I find it easier to select based on dynamic list displayed on screen.

oci db system-shape list --compartment-id $Compocid --output table \
--query 'data[?"shape-family"==`EXADATA`].{shapeFamily:"shape-family",shape:"shape"}'
echo "Enter Shape"
read shapename

Once all values are configured, final step is to create the Exadata Infrastructure. Creation process is very fast and typically completes in few minutes.

export WorkReqOCID=`oci db cloud-exa-infra create --availability-domain $ADname \
--compartment-id $Compocid --display-name $Dispname --shape $shapename \
--compute-count $compcnt --storage-count $strgcnt|jq -r '."opc-work-request-id"'`

Create Exadata VM Cluster

Before executing the VM Cluster creation script, create a .json file with DB Server’s OCID as shown below. This is the only step which requires user to provide the OCID manually. At the time of writing this article, I was not able to generate this file with CLI using the below command. I will revise the article if I come across a way to automate this step.

# This command should work but it does not work :-( 
oci db cloud-vm-cluster create --generate-param-json-input db-server

Error Message from above command -

Option db-servers is not a recognized complex type, so no example JSON can be
produced. Invoke help for this command (--help/-h/-?) to see available
documentation on this option

sample dbservers.json

[
"ocid1.dbserver.oc1.xxxxxxxuv32pjq",
"ocid1.dbserver.oc1.xxxxxgkajy3vzq"
]

We need few inputs from user to create the VM cluster . This is the script syntax

create_exa_cluster.sh <Displayname> <Clustername> <CPUCount> <Hostname> \
<Path to key file> <GIVersion> <storage TB> <memory GB> <ListenerPort>

User is prompted to select from list of available Exadata infrastructure

export Compocid=`oci iam compartment list --compartment-id-in-subtree true \
--all |jq -r ".data[] | select(.name == \"${Compname}\") | .id"`

oci db cloud-exa-infra list --compartment-id $Compocid \
--query 'data[].{Displayname:"display-name",NumDBServers:"compute-count",StorageNode:"activated-storage-count",InfraStatus:"lifecycle-state"}' --output table

echo "Enter Infrastructure Name for Cluster Creation"
read exainfraname

Next, user is prompted to provide VCN and Subnet’s for client and backup network.

oci network vcn list --compartment-id $Compocid --query 'data[].{Displayname:"display-name",CIDRBlock:"cidr-block"}' --output table
echo "Enter VCN for Cloud Exadata Cluster creation"
read vcnname

export Vcnocid=`oci network vcn list --compartment-id $Compocid --all \
--query "data[?contains(\"display-name\",'$vcnname')].id"|jq -r '.[]'`
echo $Vcnocid

oci network subnet list --compartment-id $Compocid \
--all |jq -r '.data[] | select (."vcn-id"=='\"$Vcnocid\"') | "SubnetName"+" "+."display-name"+"----CIDR----"+."cidr-block" '

echo "Select Client Subnet"
read ClientSub

oci network subnet list --compartment-id $Compocid \
--all |jq -r '.data[] | select (."vcn-id"=='\"$Vcnocid\"') | "SubnetName"+" "+."display-name"+"----CIDR----"+."cidr-block" '

export ClientSubOCID=`oci network subnet list --compartment-id $Compocid \
--all --query "data[?contains(\"display-name\",'$ClientSub')].id"|jq -r '.[]'`
echo $ClientSubOCID

echo "Select Backup Subnet"
read BackupSub

export BackupSubOCID=`oci network subnet list --compartment-id $Compocid --all \
--query "data[?contains(\"display-name\",'$BackupSub')].id"|jq -r '.[]'`
echo $BackupSubOCID

Finally, it’s time to create the VM cluster. This operation can easily take anywhere from 4–6 hours.

oci db cloud-vm-cluster create --cloud-exa-infra-id $Exainfraocid \
--compartment-id $Compocid --display-name $Clusterdispname \
--cluster-name $ClusterName --backup-subnet-id $BackupSubOCID \
--subnet-id $ClientSubOCID --cpu-core-count $CPUcount --gi-version $GIVer \
--hostname $Hostname --ssh-authorized-keys-file $KeyPath \
--scan-listener-port-tcp $Listport --data-storage-size-in-tbs $DataStorageTB \
--memory-size-in-gbs $MemGB --time-zone $Timezone \
--db-servers file:///home/scripts/dbservers.json \
--db-node-storage-size-in-gbs 500

Online CPU and Memory scaling

This script accepts 4 parameters from command line prompt

update_exa_cluster.sh <CompartmentName> <Displayname> <CPU/Memory> <New Value>

Executing this script with CPU count of 0 shuts down the cluster. Any other value in multiples of 2 will execute the scaling operation

Based on user input the script extracts compartment OCID and starts the scaling operation

# CPU scaling
export WorkReqOCID=`oci db cloud-vm-cluster update --cloud-vm-cluster-id \
$ExaClusterocid --cpu-core-count $Newval |jq -r '."opc-work-request-id"'`

#Memory Scaling
export WorkReqOCID=`oci db cloud-vm-cluster update --cloud-vm-cluster-id \
$ExaClusterocid --memory-size-in-gbs $Newval |jq -r '."opc-work-request-id"'`

As you can see from above examples, CLI makes scripting routine tasks very easy. You can access all the latest and greatest scripts in my GitHub repo.

Happy reading. Please share your thoughts, comments or experiences on my approach . If you have a better way, I would love to hear from you.

--

--

Data Voyage by Jigar Doshi

Master Principal Cloud Architect @ Oracle Singapore. Data enthusiast. Sharing my adventures in world of data