How to Set Up Apache Cassandra on Ubuntu 16.04

By Hitesh Jethva, Alibaba Cloud Tech Share Author. Tech Share is Alibaba Cloud’s incentive program to encourage the sharing of technical knowledge and best practices within the cloud community.

Apache Cassandra is a free and open source NoSQL database management system intended for storing large amounts of data in a decentralized, highly available cluster. It is specially designed to handle large amounts of data across many servers and providing high availability with no single point of failure. Cassandra data model is inspired by Google Bigtable and developed by Facebook for its Facebook inbox search feature. It differs sharply from relational database management systems.

Features

  1. Data is distributed across the cluster. So each node contains different data and no single point of failure. Failed nodes can be replaced with no downtime.
  2. Designed to have read and write throughput. So you can add new nodes without any downtime or interruption.
  3. Supports MapReduce and Hadoop integration.
  4. Cassandra is designed as a distributed system. So you can deploy large numbers of nodes across multiple data centers.
  5. Support for strong or eventual data consistency across a widely distributed cluster.
  6. It performs fast writes and stores hundreds of terabytes of data, without sacrificing the read efficiency.

In this tutorial, we will install and configure a single node Apache Cassandra on Ubuntu 16.04 with an Alibaba Cloud Elastic Compute Service (ECS) instance.

Prerequisites

  1. A fresh Alibaba Cloud Ubuntu 16.04 instance with minimum 2GB RAM.
  2. A static IP address 192.168.0.103 is configured on the instance.
  3. A Root password is setup on the server.

Launch Alibaba Cloud ECS Instance

First, log in to your https://ecs.console.aliyun.com">Alibaba Cloud ECS Console. Create a new ECS instance, choosing Ubuntu 16.04 as the operating system with at least 2GB RAM. Connect to your ECS instance and log in as the root user.

Once you are logged into your Ubuntu 16.04 instance, run the following command to update your base system with the latest available packages.

Install Java

Apache Cassandra is a cross-platform application written in Java. So you will need to install the latest version of Java to your server. By default, the latest version of Java is not available in the Ubuntu 16.04 default repository. So you will need to add the repository for that,

You can do it by running the following command:

Next, update the repository and install java with the following command:

Once the Java is installed, check the Java version with the following command:

Output:

Install Apache Cassandra

By default, Apache Cassandra is not available in the Ubuntu16.04 repository. So you will need to add Apache Software Foundation repository to your server.

First, add the repository with the following command:

Next, add public key for Cassandra with the following command:

Next, update the repository and install Cassandra using the following command:

Once Cassandra is installed, start Cassandra service and enable it to start on boot time with the following command:

You can check the status of Cassandra with the following command:

You should see the following output:

Test Cassandra Cluster

Apache Cassandra is now installed, it’s time to verify Cassandra Cluster. You can test it using the nodetool:

You should see the following output:

Cassandra comes with built-in command line interface tool cqlsh. Before using cqlsh tool, you will need to install Cassandra driver to your system. You can install it with the following command:

Now, you can connect the Cassandra Cluster using the following command:

After connecting Cassandra Cluster, you should see the following output:

Use Cassandra

Cassandra is now installed, it’s time to use Cassandra.

Let’s create a test database and keyspace. First, connect the Cassandra Cluster using the following command:

Next, create a test database and keyspace:

Next, use the keyspace testdb:

Next, create a table name mybooks:

Next, describe the table using the following command:

Output:

Related Alibaba Cloud Products

You can combine your newly deployed Cassandra database with Alibaba Cloud products for big data development.

ECS Bare Metal Instance is based on next-generation virtualization technology independently developed by Alibaba Cloud, featuring both the elasticity of a virtual server and the high-performance and comprehensive features of a physical server.Super Computing Cluster, based on Elastic Bare Metal (EBM) instances and high-speed interconnectivity of RDMA (Remote Direct Memory Access) technology, provides ultimate computing performance and parallel computing cluster services for high-performance computing.

Reference:

https://www.alibabacloud.com/blog/how-to-set-up-apache-cassandra-on-ubuntu-16-04_593967?spm=a2c4.11999923.0.0

Follow me to keep abreast with the latest technology news, industry insights, and developer trends.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store