How to Install Apache Cassandra on Ubuntu 16.04

 


Apache Cassandra is a NoSQL database management system which is free and open-source. It allows managing large amounts of data with high availability without compromising the performance. In this tutorial we are going to show you how to install Apache Cassandra on a Linux VPS running Ubuntu 16.04 as an operating system.

Apache Cassandra Prerequisites

Before installing Apache Cassandra on your server make sure that the following prerequisites are met:

– The latest version of Java 8, either the Oracle Java Standard Edition 8 or OpenJDK 8 is installed. If not, you can follow the instructions in this tutorial and we will show you how to install Java 8 on your Ubuntu VPS too.
– If you are going to use cqlsh, make sure that the latest version of Python 2.7 is installed on your server.

Updating the Software on Ubuntu 16.04

First of all, connect to your Linux server via SSH, update the package index and upgrade all your installed software to the latest version available. You can do that by using the following commands:

sudo apt-get update
sudo apt-get upgrade

Install Java 8 on Ubuntu 16.04

To install Java 8 on your Ubuntu 16.04 VPS run the following command:

sudo apt-get install default-jdk

To verify that Java 8 is installed you can use:

java -version

The output should be very similar to the one below:

openjdk version "1.8.0_131"
OpenJDK Runtime Environment (build 1.8.0_131-8u131-b11-0ubuntu1.16.04.2-b11)
OpenJDK 64-Bit Server VM (build 25.131-b11, mixed mode)

Install Apache Cassandra on Ubuntu 16.04

To install Apache Cassandra on your server, first you need to add the Cassandra repository. At the moment of writing this tutorial, the latest stable release of Cassandra is 3.11.0. Therefore, run the following command to add the Cassandra repository on your server:

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

Next, add the Cassandra repository keys:

curl https://www.apache.org/dist/cassandra/KEYS | sudo apt-key add -
sudo apt-key adv --keyserver pool.sks-keyservers.net --recv-key A278B781FE4B2BDA

Update the package index:

sudo apt-get update

Finally, install Apache Cassandra using the following command:

sudo apt-get install cassandra

Start, Stop and Enable Apache Cassandra on Ubuntu 16.04

To start the Apache Cassandra service on your server, you can use the following command:

sudo systemctl start cassandra.service

To stop the service, you can use the command below:

sudo systemctl stop cassandra.service

If the service is not already enabled on system boot, you can enable it by using the command below:

sudo systemctl enable cassandra.service

What’s Next?

If you are new to Apache Cassandra it is recommended to use the official documentation as a starting point. The documentation is available at http://cassandra.apache.org/doc/latest/ and will help you to learn how to configure and use the service for your projects.

 

Source