Install Cassandra on Ubuntu 16.04 and Run a Single-Node Cassandra Cluster on Ubuntu

Install Cassandra on Ubuntu 16.04
Install Cassandra on Ubuntu 16.04

Cassandra is (also known as Apache Cassandra) an open-source distributed database management system, it was developed to handle large amounts of data across commodity hardware or cloud infrastructure. Cassandra provides high availability with no single point of failure.

Cassandra supports linear scalability by adding a new machine to it with no downtime or interruption to applications, also increases Read and Write throughput of the Cassandra.

Every Cassandra node in the cluster will have the same role. Data is distributed across the cluster which means each node holds different data. Cassandra supports replication and multi-data center replication for redundancy, failover, and disaster recovery.

In this article, I’ll show you how to install Cassandra on Ubuntu 16.04 and configure it to run a single node cluster.


Apache Cassandra requires Java be installed on the server. Please follow the steps to install Java 8, if needed.

Add Oracle Java PPA to your system before proceeding with the installation of Java.

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

Update the repository database.

sudo apt-get update

Install Java 8 using the following command.

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

Verify the version of Java.

java -version

You should get similar output like below.

java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)

Install Cassandra on Ubuntu 16.04:

We will install Cassandra using official package available on Apache Software Foundation, so add Cassandra repository to make the package available to your system.

This Cassandra 3.6 is the latest version at the time of writing this article. Replace 36x to match the current latest version. For example, use 37x if the Cassandra 3.7 is the latest version.
echo "deb 36x main" | sudo tee -a /etc/apt/sources.list.d/cassandra.list

Add the public key for Cassandra repo so that you won’t encounter GPG error.

gpg --keyserver --recv-keys 749D6EEC0353B12C
gpg --export --armor 749D6EEC0353B12C | sudo apt-key add -

Update the repositories.

sudo apt-get update

Install Cassandra.

sudo apt-get install cassandra

Controlling Cassandra:

Start Cassandra using the following command.

sudo service cassandra start

To stop Cassandra, you can use the following command.

sudo service cassandra stop

Verify Cassandra is running successfully.

sudo service cassandra status

You might get a similar output like below.

● cassandra.service - LSB: distributed storage system for structured data
   Loaded: loaded (/etc/init.d/cassandra; bad; vendor preset: enabled)
   Active: active (running) since Sat 2016-10-08 12:34:05 UTC; 24s ago
     Docs: man:systemd-sysv-generator(8)
   CGroup: /system.slice/cassandra.service
           └─5009 java -Xloggc:/var/log/cassandra/gc.log -ea -XX:+UseThreadPriorities -XX:ThreadPriorityPolicy=4

Oct 08 12:34:05 instance-7 systemd[1]: Starting LSB: distributed storage system for structured data...
Oct 08 12:34:05 instance-7 systemd[1]: Started LSB: distributed storage system for structured data.
Oct 08 12:34:25 instance-7 systemd[1]: Started LSB: distributed storage system for structured data.

Verify Cassandra Cluster:

If your previous command came with an expected output, you could verify the Cassandra cluster by executing the below command.

sudo nodetool status

Below output confirms the cluster is up and running.

Datacenter: datacenter1
|/ State=Normal/Leaving/Joining/Moving
--  Address    Load       Tokens       Owns (effective)  Host ID                               Rack
UN  139.38 KiB  256          100.0%            08c3f485-f72e-4fb9-85f2-ee82f27dfb6e  rack1


U – Cluster is UP

N – Cluster is Normal

Connect to Cassandra cluster using its command line interface cqlsh


You will now connect to the cluster.

Connected to Test Cluster at
[cqlsh 5.0.1 | Cassandra 3.6 | CQL spec 3.4.2 | Native protocol v4]
Use HELP for help.

Troubleshooting cqlsh:

Follow the troubleshooting guide, in case If you get any error like below while connecting to an interactive command line.

Connection error: ('Unable to connect to any servers', {'': TypeError('ref() does not take keyword arguments',)})

Perform below actions.

sudo apt install python-pip
pip install cassandra-driver
export CQLSH_NO_BUNDLED=true

Now, you should be able to connect to Cassandra cluster.


Cassandra’s configuration files are found in /etc/cassandra, log and data are stored in /var/log/cassandra/ and /var/lib/cassandra respectively.

That’s All. Why not visit Cassandra project’s website for more information.


TheLastPickle – Troubleshooting cqlsh

You might also like