Apache Cassandra database is the right choice when you need scalability and high availability without compromising performance. Cassandra consistently outperforms popular NoSQL alternatives in benchmarks and real applications, primarily because of fundamental architectural choices. Linear scalability and proven fault-tolerance on commodity hardware or cloud infrastructure make it the perfect platform for mission-critical data.

Prerequisites:
Cassandra requires that the latest version of Java 8, either the Oracle Java Standard Edition 8 or OpenJDK 8 be installed. To verify that you have the correct version of java installed, type java -version. If you don't have Java installed, you can check out our guide on installing Java on Ubuntu

Also, in order to use cqlsh, the latest version of Python 2.7 is required. To verify that you have the correct version of Python installed, type python --version.

Step 1: Add the package software-properties-common:

sudo apt install software-properties-common

Step 2: Add the Apache repository of Cassandra for the latest 3.11 version:

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

Step 3: Add the Apache Cassandra repository keys:

curl https://www.apache.org/dist/cassandra/KEYS | sudo apt-key add -

Step 4: Update the repositories:

sudo apt-get update

If you encounter the error below:

GPG error: http://www.apache.org 311x InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY A278B781FE4B2BDA

Add the public key A278B781FE4B2BDA as follows:

 sudo apt-key adv --keyserver pool.sks-keyservers.net --recv-key A278B781FE4B2BDA

Next, issue the command sudo apt-get update again.

Step 5: Install Cassandra:

 sudo apt-get install cassandra

Step 6: Start and Enable Cassandra

 sudo systemctl start cassandra
 sudo systemctl enable cassandra
 sudo systemctl status cassandra

Verify that Cassandra is running by issuing the command below:

nodetool status 

If you received the error below while checking nodetool status;

Failed to connect to ‘127.0.0.1:7199’: Connection refused (Cassandra)

Open the cassandra-env.sh file as shown below:

sudo nano /etc/cassandra/cassandra-env.sh

Search for -Djava.rmi.server.hostname= in the file. Uncomment this line and add your loopback address or public IP address by replacing at the end of the line.

Restart Cassandra with the command below:

sudo systemctl restart cassandra 

Then check node status using nodetool status.

You can read the documentation of Apache Cassandra for more information