Creating a MySQL HeatWave Instance With the OCI CLI

In a previous series, we discussed how we can leverage the TypeScript/JavaScript SDK for Oracle Cloud Infrastructure (OCI) to manage MySQL HeatWave instances. This new series demonstrates how to use the OCI CLI to complete similar tasks. In this post, we will show how to create a MySQL HeatWave instance and retrieve reference information that can help create this new instance.
Prerequisites
Before you can run any of the examples below, you need to install the OCI CLI. If you do not have the CLI installed, follow the instructions here to install and configure the CLI.
Note: Many examples require a parameter named --compartment-id
. Because I am part of a tenancy shared by many colleagues, I must ensure I only ever touch resources in my ‘sandbox’. To make this easier, I followed the instructions here to set up default values for the CLI - including the compartment-id
for my ‘sandbox’.
Listing Reference Data
In my previous series, I put this part at the end, but I think it is better to talk about the ‘reference data’ in the beginning. When we manage MySQL HeatWave instances, we need to provide specific values for some parameters—three that come to mind are configuration
, shape
, and version
. When we provide these values, they need to be valid options. This section will show you how to get a list of all the valid options for each.
Configurations
To make provisioning MySQL HeatWave instances easier and more consistent, we can use a configuration
when creating an instance. The list of configurations we retrieve contains default and custom configurations we may create. The list of items that is returned is sorted by:
- Shape name - ascending
DEFAULT
beforeCUSTOM
- Display name - ascending
To see the complete list of configurations, use the following command.
The result will look similar to the text below.
If we use a configuration when creating a new instance, we would use the value of the id
property.
Check out the configuration list documentation to learn about other options.
Shapes
Every MySQL HeatWave instance must have a defined `shape. ’ This value can be defined in a configuration like we see above or provided as a separate parameter when creating a MySQL HeatWave instance. To see the list of valid shapes, we would use the command:
The output from this command should resemble this text:
When we specify a shape
when creating a new MySQL HeatWave instance, we use the value of the name
property.
Check out the shape list documentation to learn about other options.
Versions
When creating a new MySQL HeatWave instance, the latest version available will be used if a version is not specified. To retrieve a list of valid versions, use the following command:
The output from this command will resemble:
Note that there are two different version families - one for 8.0
and one for 8 - Innovation
. When specifying the version when creating a new instance, we would use the value of the version
property.
Check out the version list documentation to learn about other options.
Subnets
Another piece of information we need when creating a MySQL HeatWave instance is the subnet where it will be created. To see the list of available subnets in your compartment, use the following command:
The result will resemble the text below.
When creating a MySQL HeatWave instance, we use the value of the id
property as the subnet-id
.
Check out the subnet list documentation to learn about other options.
Availability Domains
One last piece of information we need is the availability domain where the MySQol HetWave instance will be deployed. We can get a list of availability domains by running the command:
The list will resemble the following:
When specifying an availability domain when creating a new MySQL HeatWave instance, we would use the value of the name
property.
Check out the availability-domain list documentation to learn about other options.
Creating the Instance
There are quite a few options when creating a new MySQL HeatWave instance. If you don’t believe me, go check out the documentation for creating a new MySQL db-system
.
I am a poor typist, and when a command has many parameters, and some of them have very long values, I often need help identifying typos. There is also an issue with running the command more than once. Yes, you can cycle through the command history, but this could also be difficult if there were typos in previous attempts to run the command.
There is a feature of the OCI CLI that was explicitly designed for people like me. Many commands have an option named --from-json
where you can specify a JSON file containing the instance’s configuration information. Another nifty feature is generating a sample JSON file for commands with the --from-json
option.
Generate Command JSON
To generate a JSON file that contains all the possible options we can use when creating a MySQL HeatWave instance, we use the following command:
This command will create a file named heatwave-create.json
in the directory where we executed the command. The content of the file will resemble:
Set Our Option Values
I will trim this file down to just the required fields and some other helpful ones and provide values for them. My file looks like this:
Let’s look at what options we are setting:
- The
adminPassword
andadminUsername
are the password and username for a MySQL admin (notroot
) user when the instance is created. - We specify the
availabilityDomain
. - We enable the
backupPolicy
and also turn on ‘point-in-time’ recovery (pitrPolicy
) and set theretentionPeriod
for the backups to 14 days. - We set the
compartmentId
. - We enable
crashRecovery
. - We set the
dataStorageSizeInGbs
to 50 (the lowest possible value for a MySQL HeatWave instance). - We enable
databaseManagement
. - We set the instance’s
description
anddisplayName
. - We set
isHighlyAvailable
tofalse
. - We set the
mysqlVersion
to8.3.0
. - We set the
shapeName
toVM.Standard.E2.1
- We specify the
subnetId
where the instance will reside. - We set the
waitForState
option to"SUCCEEDED"
.- This will cause the command to wait until it reaches a state of
SUCCEEDED
.
- This will cause the command to wait until it reaches a state of
If any values specified in this JSON file are also specified when the create
command is executed, the values in the command will override the values in the JSOn file.
Running the Command
Now that our options are configured in our JSON file, let’s create a new MySQL HeatWave instance. We use the following command to create a new instance using the JSON file we generated (and modified) earlier.
When we run this command, we should see the following text letting us know that the command has entered a state of SUCCEEDED
.
While waiting for the instance to be created, we can log in to Oracle Cloud and check the progress. You can see our new instance is being created.
The command may return as SUCCEEDED
before the instance is available. When the command is successful, we will see the output in the terminal similar to the text below:
You will see the following when the instance is fully available in Oracle Cloud.
Wrap-up
These few examples show that the OCI CLI offers extensive functionality for managing Oracle Cloud resources, including MySQL HeatWave instances. In future posts, I will explore the functionality for managing MySQL HeatWave resources.
Photo by Jake Walker on Unsplash
Related Entries
- Listing and Updating MySQL HeatWave Instances with the OCI CLI
- Backing up and Restoring a MySQL HeatWave Instance with the OCI CLI
- Creating a MySQL HeatWave Read Replica with the OCI CLI
- Creating a MySQL HeatWave Configuration with the OCI CLI
- Creating a MySQL HeatWave Replication Channel with the OCI CLI