Managing Clusters on Hazelcast Viridian Cloud Using the Hazelcast CLC
In this tutorial, you’ll learn the basics of managing clusters on Hazelcast Viridian Cloud using the Hazelcast CLC. You’ll see how to create, list, and delete clusters, and how to download their logs. You’ll also learn how to perform pause/resume operations on the clusters using the Hazelcast CLC.
To allow the Hazelcast CLC to perform cluster operations, you must generate a Viridian Cloud token.
Execute the following command to retrieve the token.
clc viridian login
When prompted, enter your API key and secret. If both are correct, the output looks like this.
Viridian token was fetched and saved. OK
If an error is displayed, make sure that your API key and secret are correct and try again.
Next, execute the following command to create a development cluster called
clc viridian create-cluster --name my-cluster
You should see the following output.
Imported configuration: my-cluster
To check that the
my-cluster is up and running, use the following command.
clc viridian list-clusters
The details of all clusters linked to your Viridian Cloud account are returned, including the Cluster ID, Cluster Name, Current Status, Hazelcast Version.
x1qvpphn my-cluster RUNNING 5.3.5
Next, write some data to a map on
Creating your cluster using the Hazelcast CLC means that the connection details for the cluster, also called
my-cluster, are made available to the CLC. If you created the cluster in the console, you would need to import the cluster’s configuration to connect to it.
Let’s add an entry to a map called
my-mapusing a key of
my-keyand a value of
clc -c my-cluster map set -n my-map my-key my-value
Now, let’s retrieve the value of the key that you just set.
clc -c my-cluster map get -n my-map my-key
You should see the following output.
You can download logs from your cluster to your local machine. Hazelcast CLC gives the cluster logs a standard name, which means that they are overwritten every time you download them to the same location.
Run the following command to download the logs of
my-clusterto your working directory.
clc viridian download-logs my-cluster
In this command
my-clusteris the cluster name rather than the configuration name.
Use the following command to quickly check the location of your working directory.
Now, try downloading the logs to a directory of your choice by adding the
--output-dirflag. Replace the placeholder
$DIRECTORY_PATHwith the absolute or relative path to your chosen directory.
clc viridian download-logs my-cluster --output-dir $DIRECTORY_PATH
To avoid charges accumulating in your account, you can stop a running cluster.
Try pausing your cluster. You can use either the cluster name or ID.
clc viridian stop-cluster my-cluster
When you’re ready to resume the cluster, run the following command.
clc viridian resume-cluster my-cluster
You can also delete an existing cluster on Viridian Cloud using its name or ID.
Run the following command to delete
my-clusterreplacing the placeholder
CLUSTER_ID. See Step 3, for details of how to look up a cluster ID.
clc viridian delete-cluster $CLUSTER_ID
A confirmation message is displayed.
Cluster will be deleted irreversibly, proceed? (y/n)
yto proceed with the deletion.
To avoid receiving a confirmation message on cluster deletion, add
--yesto your command. This may be useful if you are scripting the deletion of multiple clusters.
clc viridian delete-cluster my-cluster --yes
In this tutorial, you learned how to do the following:
Authenticate with Viridian Cloud.
Create a cluster and check that it is running.
Write and retrieve some data from a map.
Download cluster logs for analysis.
Pause, resume and delete a cluster.