Deploying an Open Source Apache Cassandra Database using the GCP Marketplace
- Vignesh Sivakumar

Deploying an Open Source Apache Cassandra Database using the GCP Marketplace

Objectives

  • Deploy Apache Cassandra using the GCP marketplace
  • Connect to Apache Cassandra using CQL
  • Create keyspaces and tables using CQL 
  • Insert and Query data using CQL
  • Destroy Apache Cassandra 

Prerequisites

  • Google Cloud Platform Account
  • A Project with billing enabled

Google Products

  • Google Cloud Marketplace
  • Compute Engine
  • Cloud Deployment Manager
  • Cloud Shell

Deploy Apache Cassandra using the GCP marketplace

1. Open Google Console https://console.cloud.google.com/

2. On the left side of browse on the Navigation Menu and click on the Marketplace https://console.cloud.google.com/marketplace

Marketplace

3. Search for “Cassandra Certified by Bitnami” and click on the result Cassandra Certified by Bitnami.

Cassandra Certified by Bitnami

4. Click on the LAUNCH button.

No alt text provided for this image

It may take a few minutes to configure APIs and launch.

5. Give the name for the deployment in Deployment Name and select Zone where you want to deploy the application. Choose the Machine type, Boot disk size, and Networking based on the need. Select the Checkbox for accepting the GCP Marketplace Terms of Service. And Click on the Deploy button.

No alt text provided for this image

When you click on the deploy button you will be redirected to the Deployment Manager Page. It may take a few minutes. Once deployed you will see a Green Checkbox with your deployment name. Ex. cassandra-1 has been deployed

Connect to Apache Cassandra using CQL 

1. Note the Admin user and Admin password on the right-hand side.

No alt text provided for this image

2. To connect to the database, click on the drop-down menu in the SSH button and select Open in browser window.

No alt text provided for this image

3. Type the below comment with the username and password you have copied on Step 1 to connect to the instance.

cqlsh -u <username> -p <password>

Ex: cqlsh -u cassandra -p tMXGUr2piqcr

No alt text provided for this image

Create a keyspace and table using CQL

1. After login into the Cassandra database, create a keyspace using the below command.

CREATE KEYSPACE thecloudnuggets WITH replication = {'class':'SimpleStrategy', 'replication_factor' : 1};

You can set the replication factor bases on your need. The replication option is to specify the Replica Placement Strategy and the number of replicas wanted.

No alt text provided for this image

2. Create a table in the keyspace using the below command.

CREATE TABLE thecloudnuggets.nuggets ( nuggets_id int PRIMARY KEY, nuggets_name text, nuggets_city text, nuggets_sal varint, nuggets_phone varint );

You can view the created Keyspace using the below command.

DESCRIBE KEYSPACE thecloudnuggets;

No alt text provided for this image

Insert and Query data using CQL

1. Insert Sample Data into the created table using the following command.

INSERT INTO <tablename> (<column1 name>, <column2 name>....) VALUES (<value1>, <value2>....)

Example:

INSERT INTO thecloudnuggets.nuggets ( nuggets_id, nuggets_name, nuggets_city, nuggets_phone, nuggets_sal) VALUES(1,'The', 'TN', 9848022338, 50000);

INSERT INTO thecloudnuggets.nuggets ( nuggets_id, nuggets_name, nuggets_city, nuggets_phone, nuggets_sal) VALUES(2,'Cloud', 'TN', 9848022338, 50000);


INSERT INTO thecloudnuggets.nuggets ( nuggets_id, nuggets_name, nuggets_city, nuggets_phone, nuggets_sal) VALUES(3,'Nuggets', 'TN', 9848022338, 50000);

2. Query the table to view the data from the created table.

select * from thecloudnuggets.nuggets;

No alt text provided for this image

3. Exit the CQL shell using the below command

cqlsh> exit


Destroy Apache Cassandra 

1. On the left side of browse on the Navigation Menu and click on the Deployment Manager under the Tools section.

No alt text provided for this image

2. Select the checkbox of your deployment name and click Delete on the top.

No alt text provided for this image

After Clicking on the Delete button you will get a pop in that select Delete and all resources created by it,... and Click DELETE ALL. This will completely destroy the environment you created above.

No alt text provided for this image

Congratulations!

In this article, we deployed an Apache Cassandra database, connected to the database using CQL Shell, and run some simple DDL commands to create a table, load some data, and query it. Finally, we destroyed the environment that created.

要查看或添加评论,请登录

Vignesh Sivakumar的更多文章

社区洞察

其他会员也浏览了