Three main ways you can scale the number of OCPUs in Exadata Cloud Service or Cloud at Customer:
- OCI Console
- REST api
- OCI Command Line Interface.
Here are four examples on how to script this scaling using either the REST api via Curl or the OCI CLI.
- "Auto Scaling" Script
- Curl
- OCI CLI
- dbaascli
Below you find details on each of the examples.
1. "Auto Scaling" Script
Oracle DynamicScaling utility can be executed as standalone executable or as daemon on one or more ExaCS compute nodes or ExaC@C vmcluster nodes. By default DynamicScaling is monitoring the CPUs with very limited host impact and if the load goes over the Maximum CPU threshold ("--maxthreshold") for an interval of time ("--interval"), it will automatically will scale-up the OCPU by a factor ("--ocpu") till a maximum limit ("--maxocpu"). If the load goes under the Minimum CPU threshold ("--minthreshold") for an interval of time ("--interval") scale down will be executed util the minimum limit ("--minocpu") of ocpu. If a valid cluster filesystem (ACFS) is provided, DynamicScaling will consider the load of all nodes (where DynamicScaling is running) and it will perform a scale-UP/DOWN based on the cluster node load (average/max). There are several examples in this doc.
2. Curl bash scriptWith using curl I find it easier to start with a "http get" method and make sure this works before moving on to using a "http put". This is a
nice blog article on describing where to find each of these values. This is the api documentation for
cloudVmClusters and
UpdateCloudVmCluster.
Below is example "http get" script where you will need to change the tenancy_ocid, user_ocid, privateKeyPath, fingerprint, rest_api and host.
#!/bin/bash
########################## Fill these in with your values ##########################
#OCID of the tenancy calls are being made in to
tenancy_ocid="ocid1.tenancy.oc1..aaaaaaaactsgmdorji3bujtx6gbchuvbblbr3ddpqxxp5o3f2dxxxxxxxxxx"
# OCID of the user making the rest call
user_ocid="ocid1.user.oc1..aaaaaaaagt7makfurd57pdcwdtqh3l3yxbvymvwiei63ut3sqpxxxxxxxxxx"
# path to the private PEM format key for this user
privateKeyPath="/home/opc/greg.pem"
# fingerprint of the private key for this user
fingerprint="d2:7d:2e:22:3e:a8:8a:df:b7:d4:12:xx:xx:xx:xx:xx"
# The REST api you want to call, with any required paramters.
rest_api="/20160918/cloudVmClusters/ocid1.cloudvmcluster.oc1.phx.abyhqljrchvzy3scg4i5c4vykzrjszncnramcftjwymxkiaznixxxxxxxxxx"
# The host you want to make the call against
host="database.us-phoenix-1.oraclecloud.com"
####################################################################################
date=`date -u "+%a, %d %h %Y %H:%M:%S GMT"`
date_header="date: $date"
host_header="host: $host"
request_target="(request-target): get $rest_api"
# note the order of items. The order in the signing_string matches the order in the headers
signing_string="$request_target\n$date_header\n$host_header"
headers="(request-target) date host"
#echo "====================================================================================================="
printf '%b' "signing string is $signing_string \n"
signature=`printf '%b' "$signing_string" | openssl dgst -sha256 -sign $privateKeyPath | openssl enc -e -base64 | tr -d '\n'`
printf '%b' "Signed Request is \n$signature\n"
echo "====================================================================================================="
set -x
curl -v -X GET -sS https://$host$rest_api -H "date: $date" -H "Authorization: Signature version=\"1\",keyId=\"$tenancy_ocid/$user_ocid/$fingerprint\",algorithm=\"rsa-sha256\",headers=\"$headers\",signature=\"$signature\""
Here is a curl script example for a "HTTP PUT". This script changes the number of OCPUs (cores) at the VM cluster level.
#!/bin/bash
########################## Fill these in with your values ##########################
#OCID of the tenancy calls are being made in to
tenancy_ocid="ocid1.tenancy.oc1..aaaaaaaactsgmdorji3bujtx6gbchuvbblbr3ddpqxxp5o3f2dxxxxxxxxxx"
# OCID of the user making the rest call
user_ocid="ocid1.user.oc1..aaaaaaaagt7makfurd57pdcwdtqh3l3yxbvymvwiei63ut3sqpxxxxxxxxxx"
# path to the private PEM format key for this user
privateKeyPath="/home/opc/greg.pem"
# fingerprint of the private key for this user
fingerprint="d2:7d:2e:22:3e:a8:8a:df:b7:d4:12:xx:xx:xx:xx:xx"
# The REST api you want to call, with any required paramters.
rest_api="/20160918/cloudVmClusters/ocid1.cloudvmcluster.oc1.phx.abyhqljrchvzy3scg4i5c4vykzrjszncnramcftjwymxkiaznixxxxxxxxxx"
# The host you want to make the call against
host="database.us-phoenix-1.oraclecloud.com"
# the json file containing the data you want to POST to the rest endpoint
body="./request.json"
####################################################################################
# extra headers required for a POST/PUT request
body_arg=(--data-binary @${body})
content_sha256="$(openssl dgst -binary -sha256 < $body | openssl enc -e -base64)";
content_sha256_header="x-content-sha256: $content_sha256"
content_length="$(wc -c < $body | xargs)";
content_length_header="content-length: $content_length"
headers="(request-target) date host"
# add on the extra fields required for a POST/PUT
headers=$headers" x-content-sha256 content-type content-length"
content_type_header="content-type: application/json";
date=`date -u "+%a, %d %h %Y %H:%M:%S GMT"`
date_header="date: $date"
host_header="host: $host"
request_target="(request-target): put $rest_api"
# note the order of items. The order in the signing_string matches the order in the headers, including the extra POST fields
signing_string="$request_target\n$date_header\n$host_header"
# add on the extra fields required for a POST/PUT
signing_string="$signing_string\n$content_sha256_header\n$content_type_header\n$content_length_header"
echo "====================================================================================================="
printf '%b' "signing string is $signing_string \n"
signature=`printf '%b' "$signing_string" | openssl dgst -sha256 -sign $privateKeyPath | openssl enc -e -base64 | tr -d '\n'`
printf '%b' "Signed Request is \n$signature\n"
echo "====================================================================================================="
set -x
curl -v --data-binary "@./request.json" -X PUT -sS https://$host$rest_api -H "date: $date" -H "x-content-sha256: $content_sha256" -H "content-type: applica tion/json" -H "content-length: $content_length" -H "Authorization: Signature version=\"1\",keyId=\"$tenancy_ocid/$user_ocid/$fingerprint\",algorithm=\"rsa- sha256\",headers=\"$headers\",signature=\"$signature\""
This is the file request.json:
{
"cpuCoreCount" : 6
}
3. OCI Command Line Interface (OCI CLI)
This is the example script:
#!/bin/bash
export OCI_CLI_AUTH=instance_principal
oci db cloud-vm-cluster update --cloud-vm-cluster-id ocid1.cloudvmcluster.oc1.phx.abyhqljrchvzy3scg4i5c4vykzrjszncnramcftjwymxkiaznis5xxxxxxxx --cpu-core-count 6 --auth instance_principal
You will need to modify the vm cluster ocid. This script changes the vm cluster to 6 OCPUs(cores).
4. dbaascli
On ExaCC only, you can change the OCPUs(cores) with dbaascli. Login into one of the compute nodes within the VM Cluster you would like to modify and issue the command below. Here is the documentation.
dbaascli cpuScale update --coreCount 3
This will change each node within the cluster to 3 OCPUs(cores).