How to: Setup Cassandra & Run a Single-Node Cluster on Ubuntu 16.04.

Khaled Naser

Khaled Naser

Apache Cassandra is an open source distributed database management system designed to handle large amounts of data across many commodity servers, providing high availability with no single point of failure. Cassandra offers capabilities that relational databases and other NoSQL databases simply cannot match such as continuous availability, linear scale performance, operational simplicity and easy data distribution across multiple data centers and cloud availability zones. Cassandra’s architecture is responsible for its ability to scale, perform, and offer continuous uptime. Rather than using a legacy master-slave or a manual and difficult-to-maintain shared architecture, Cassandra has a masterless “ring” design that is elegant, easy to set up, and easy to maintain.

Let’s see how we are going to install and use it to run a single-node cluster on Ubuntu 16.04.

System Update:

Update our system to the latest updates and security patches available before installing other prerequisites and Cassandra, . You can run the command below to get the latest updates.

$ sudo apt-get update

Installing JDK 8:

Apache Cassandra is run on top of Java Virtual Machine (JVM). We’ll install Oracle JDK 8 on the system before we install Apache Cassandra. Apache Cassandra can also run on OpenJDK, IBM JVM and Azul Zing JVM.

We will install Oracle JDK using the Webupd8 team PPA repository. The first step is to add the webupd8team PPA repository using the below command.

$ sudo add-apt-repository ppa:webupd8team/java

Press [ENTER] to continue or ctrl-c to cancel adding it.

You need to press enter to continue adding the webupd8team PPA repository. Then update the package database and install JDK 8 by flowing the below command.

$ sudo apt-get update


Now install the Oracle JRE package, this will not only installs but also makes it the default JRE.

$ sudo apt-get -y install oracle-java8-installer

Accept the license agreement when prompted.


Then accepting the Oracle Binary Code License Terms by Choosing the ‘Yes’ option.


Once installation of Java 8 complete, you can check the current java version by running the command below

ubuntu@ubuntu-16:~$ java -version
java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)

Installing Apache Cassandra:

Now we can start installing Apache Cassandra, from the official Apache Software Foundation repositories, so start by adding the repo so that the packages are available to the system by adding the repo’s source.

<pre$ echo “deb http://www.apache.org/dist/cassandra/debian 37x main” | sudo tee -a /etc/apt/sources.list.d/cassandra.sources.list


$ echo "deb-src http://www.apache.org/dist/cassandra/debian 37x main" | sudo tee -a /etc/apt/sources.list.d/cassandra.sources.list

Then add the following three public keys from the Apache Software Foundation associated with the package repositories to avoid package signature warnings.

$ gpg --keyserver pgp.mit.edu --recv-keys F758CE318D77295D
$ gpg --export --armor F758CE318D77295D | sudo apt-key add -

Add the second key using the below commands.

$ gpg --keyserver pgp.mit.edu --recv-keys 2B5C1B00
$ gpg --export --armor 2B5C1B00 | sudo apt-key add -

To add the third keys run the below commands.

$ gpg --keyserver pgp.mit.edu --recv-keys 0353B12C
$ gpg --export --armor 0353B12C | sudo apt-key add -

After this once again update your system, so that ‘apt-get’ can read the metadata of Cassandra repository.


After system updates, now let’s install Cassandra 37x on your Ubuntu 14 LTS. This is the latest stable version of Cassandra.

Run the below command to install Cassandra on your Ubuntu system and press ‘y’ key to continue.

$ sudo apt-get install cassandra


Starting Cassandra service:

Now Cassandra’s service should be up and running on your system.

To confirm that it’s not running, use the below command to check its status.

$ sudo service cassandra status

If you did not get the running status, then flow the command below in your command line terminal to start its service.

$ sudo service cassandra start

Connecting to the Cluster:

Once your Cassandra service is up and running, check the status of the cluster using the below command.

$ sudo nodetool status
Datacenter: datacenter1
|/ State=Normal/Leaving/Joining/Moving
--  Address    Load       Tokens       Owns (effective)  Host ID                               Rack
UN  103.01 KiB  256          100.0%            da43244b-b1f1-4426-9b24-9ea3cb31ecb4  rack1

In the output, UN means it’s Up and Normal. Then connect to it using its interactive command-line interface ‘cqlsh’.

$ cqlsh


Using Apache Cassandra:

Let’s try our Cassandra installation by creating a test database. First of all, let’s create a keyspace, this is a namespace for tables. The keyspace name below is ‘mydb’.

cqlsh> CREATE KEYSPACE mydb WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };

Use the keyspace that we just created.

cqlsh> use mydb;

Create a movie’s table.

cqlsh:moviedb> CREATE TABLE books (id int PRIMARY KEY, title text, year text);

Let’s describe the table that we just created.

cqlsh:mydb> DESC books;

using cassandra

The table is ready, now you can add some data to it.


Cassandra’s data model offers the convenience of column indexes with the performance of log-structured updates, strong support for denormalization and materialized views, and powerful built-in caching. In this article, we learned about the installation of Apache Cassandra from its official repository. Now you can start exploring this single node installation of Apache Cassandra after some basic configuration and usage of Apache Cassandra.

Would you like to know about Zuul, a CI/CD project gating tool? Download our white paper and get reading!

How to up your DevOps game with Project Gating

Share on Social Media:


Cluster API driver for OpenStack Magnum

Khaled Naser

Public Cloud

9000 MTUs (jumbo frames) in all Public Cloud Regions

Khaled Naser


OpenInfra Summit Berlin 2022 VEXXHOST Recap

Khaled Naser

Go to Top