Objective: How to delete/remove Non-CDB or 11g database or database home from ExaCC Prerequisite: Should have Non-CDB or 11g home and database on ... Read More
Automation – Deploy DBCS in Oracle Cloud Infrastrucute using REST API
I was working on automation using REST API (Representational State Transfer – Application Programming Interface) and found it very interesting and easy to implement with a simple command to deploy services on OCI (Oracle Cloud Infrastructure). In this blog, I will show you how to deploy DBCS (Oracle Database Cloud Service) using REST API.
I know you are thinking why I need to deploy using REST API if I have the console. You can schedule a job to stop/start DBCS and save costs. Especially when you doing any testing, auto stop/start will help, it will save time and money.
There are many ways to use APIs, I am using oci-curl function in this blog available by the OCI team. OCI_CURL will sign and encrypt your APIs so they are not sent in clear over the internet. OCI-CURL can be used on Linux and windows, I am using windows here.
You can use the below link to copy oci-curl script.
You only have to change these 4 parameters in this script as per your environment.
Tenancy OCID, USER OCID, KeyFingerprint, and private key .pem file location. You can easily get it from the OCI console.
- I am assuming you already have VCN (Virtual Cloud Network), subnet, security rules, and compartment
- Also, you need to generate a key pair using ssh-keygen so you can use the public key in JSON configuration file later
To Deploy the DB System we need below 4 things:
- OCI-CURL – I have it above
- API endpoint for the database: I used database.ca-toronto-1.oraclecloud.com , if your cloud database is located somewhere else you can use that. full list here… API Endpoints
- Config File: I also need to create a small JSON file for a configuration containing information like availability domain, compartment id, db-related info, and public key to access the node
- DB System API command POST /20160918/DB systems
here is my JSON file here…
Now I have everything, so I just created a small shell script
So to deploy the DB System, I just need to run the shell script like ./createdbsystem.sh and magically starts to begin 🙂
Here is the output:
And when I go to the console, I can see its provisioning…
You can go to the work request to see how much was completed…
It will take like 20-30 mins to complete and then you can connect to the node using your private key.
Delete or terminating the DB System is, even more, simpler because you don’t need any configuration file, you need the OCID of the DB System.
Here is the script I created for termination…
Now we can schedule these jobs in crontab or windows scheduler to automate start/stop.
More from this Author
Introduction: In this blog, I will show you how to use Ansible to automate Oracle database patching. I applied the latest Oracle 19c RU Patch ... Read More