- Consulting
- Training
- Partners
- About Us
x
This blog is a 3-part series for Apache Cassandra’s No-SQL database. In the first part of my blog, I have given a brief overview of Open-Source Apache Cassandra in Part 1. This next part of the series deals with Azure Managed Instance for Apache Cassandra – its features, Use case, Installation, and Connectivity.
Azure Managed Instance for Apache Cassandra is one of the many managed services offered by Microsoft Azure Cloud. Since this service went GA in November of 2021, there have been continuous feature additions to the service. I was a part of the team that worked closely with the Microsoft Cosmos DB team to evaluate the Cassandra MI features for Production use. I have mostly referred to Datastax, Apache, and Microsoft official web pages to produce the content in this blog.
Happy Reading!!
Cassandra MI or Azure Managed Instance for Apache Cassandra is a highly scalable, highly available service entirely managed by Azure. The cluster can be deployed automatically, and Microsoft Azure takes the cluster updates, patching, replication, and cluster health. Customers can use all the features of open-source Cassandra in Cassandra MI. They can create hybrid deployment by extending their on-premises Cassandra Cluster to the Azure cloud and running their data centers with the least maintenance overhead.
Cassandra MI deployment pre-requisites:
Azure Services Needed:
IAM Permissions and NSG Settings:
1 2 3 4 5 6 7 8 9 10 |
1. Install Java Runtime Environment Packages: Sudo apt-get update Sudo apt install openjdk-8-jdk openjdk-8-jre 2. Download the Python 2.7 or above: wget https://www.python.org/ftp/python/2.7.18/Python-2.7.18.tgz sudo apt install python 2.7.18 3. Download the "cqlsh" tar files and extract it to a designated folder: wget https://files.pythonhosted.org/packages/3e/5e/aca7db53c59f1113cb191772c5006d41ed763831104c27baf3db7a3f4ab7/cqlsh-6.0.0.tar.gz tar -xzvf cqlsh-6.7.tar.gz |
1 2 3 4 5 6 7 8 9 10 11 |
Install Azure CLI: sudo apt-get update sudo apt-get install ca-certificates curl apt-transport-https lsb-release gnupg curl -sL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/microsoft.gpg > /dev/null AZ_REPO=$(lsb_release -cs) echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ $AZ_REPO main" | sudo tee /etc/apt/sources.list.d/azure-cli.list sudo apt-get update sudo apt-get install azure-cli=2.30.0-1~bullseye |
1 2 3 4 5 6 7 8 |
1. Export the SSL variables: export SSL_VERSION=TLSv1_2 export SSL_VALIDATE=false 2. Connect to CQLSH (replace <IP> with the private IP addresses of a node in your Datacenter): host=("<node IP>") initial_admin_password="Password provided when creating the cluster" cqlsh $host 9042 -u cassandra -p $initial_admin_password --ssl |
Azure CLI command for Datacenter and Cluster creation:
az managed-cassandra < cluster> <verb> –cluster-name <name> –resource-group <name> — location <az location>
Example: az managed-cassandra cluster create –cluster-name cassandracls01 –resource-group Cassandra-RG –location ap-south-1
az managed-cassandra <datacenter> <verb> –cluster-name <name> –resource-group <name> –data-center-name <name> –data-center-location <az location> —-node-count <no.of node>
Example: az managed-cassandra datacenter create –cluster-name cassandracls01 –resource-group Cassandra-RG –data-center-name datacenter01 –data-center-location ap-south-1 —-node-count 3
CREATE KEYSPACE <keyspace name> WITH replication = {‘class’: ‘NetworkTopologyStrategy/SimpleStrategy,’ <datacenter_name>: <replication_factor> / ‘replication_factor’ : <RF no.> }
AND durable_writes = false;
b. Alter a Keyspace:
CREATE KEYSPACE <keyspace name> WITH replication = {‘class’: ‘NetworkTopologyStrategy/SimpleStrategy’, ‘replication_factor’: <RF no.>};
c. Delete a Keyspace:
DROP KEYSPACE <keyspace name> WITH replication = {‘class’: ‘NetworkTopologyStrategy/SimpleStrategy’, ‘replication_factor’: <RF no.>};
d. Other Commands:
i. USE KEYSPACE <keyspacename>; – to use a particular keyspace
3. Viewing the Keyspace:
a. System Keyspaces:
DESCRIBE keyspaces;
SELECT * FROM <systemdb.keyspaces>;
4. Commands to Create, Alter and Delete Columns from Tables:
CREATE TABLE keyspace_name.table_name (<column_name data_type PRIMARY_KEY);
ALTER TABLE <table_name> ALTER <created_date> TYPE <data_type>; – to change the type of column
ALTER TABLE <table_name> ADD <column_name> <data_type>; – to add a column to a table
ALTER TABLE <table_name> DROP <column_name>; – to remove a column
DROP TABLE <table_name>;
TRUNCATE <keyspace_name.table_name>;
5. Insert, Update, Delete data into/from Keyspaces:
a. INSERT INTO <keyspace_name.table_name> (<column_name1>, <column_name2>…) VALUES (‘value1’, ‘value2’…);
Example: INSERT INTO CloudThat (emp_id, first_name, last_name, age, email_id, ‘city’) VALUES (‘00230’, ‘Naman’, ‘24’, ‘naman.b@cloudthat.com’);
b. UPDATE < keyspace_name.table_name> SET <column_name> = ‘<old_value>’ WHERE <column_name> = ‘<primary_key_value>’;
Example: UPDATE CloudThat SET last_name = ‘Sharma’ WHERE emp_id = ‘00230’;
c. DELETE < column_name> FROM <keyspace_name.table_name> WHERE <row_details>;
Example: DELETE age FROM CloudThat WHERE emp_id = ‘00230’;
To summarize, Azure Managed Instance for Apache Cassandra can be set up and managed with great ease within seconds on Azure cloud, or it can be extended from on-premises Cassandra cluster to cloud using Hybrid connectivity. The above blog focused on setting up a Cassandra MI cluster using Azure CLI and Azure Portal. We also saw how to connect to the cluster and perform CRUD operations on the Database. The next and final blog will focus on Data Migration options onto Cassandra Cluster using native and third-party tools.
We here at CloudThat are the official Microsoft gold partner, AWS (Amazon Web Services) Advanced Consulting Partner, and Training partner helping people develop knowledge on the cloud and help their businesses aim for higher goals using best in industry cloud computing practices and expertise. We are on a mission to build a robust cloud computing ecosystem by disseminating knowledge on technological intricacies within the cloud space. Our blogs, webinars, case studies, and white papers enable all the stakeholders in the cloud computing sphere.
Drop a query if you have any questions regarding Apache Cassandra’s utilization, and I will get back to you quickly. To get started, go through our Expert Advisory page and Managed Services Package that is CloudThat’s offerings.
Voiced by Amazon Polly |
Saritha is a Subject Matter Expert - Kubernetes working as a lead at CloudThat. She has relentlessly kept upskilling with the latest trending technologies and delivering the best cloud-native solutions to Businesses in all sectors. She is a Microsoft Certified Solution Architect, Certified Windows Server Administrator, and Windows Networking professional and strives towards providing the best cloud experience to our customers through transparent communication, methodical approach, and diligence.
Our support doesn't end here. We have monthly newsletters, study guides, practice questions, and more to assist you in upgrading your cloud career. Subscribe to get them all!
R
Aug 16, 2022
Great vlog! Ho do you connect to the cqlsh for this cluster ? Since it is in a vnet, how do you connect to it from local system ?
Saritha
Aug 18, 2022
Thanks for the question!!
For connecting to the cluster using cqlsh, you need to create a vm in the sane vnet as the cluster which will act as a jump server, install the cqlsh and from this vm you need to connect to the cluster.
Sagar
Jun 7, 2022
Excellent blog, very well explained
Click to Comment