Prerequisites

To follow this installation, you will need:

  • Ubuntu 20.04 server set up,  including a sudo non-root user and a firewall.


Installing JDK

The simplest option for installing Java is to use the version packaged with Ubuntu. By default, Ubuntu 20.04 includes Open JDK 11,  which is an open-source variant of the JRE and JDK.

To install this version, first update the package index:

sudo apt update
Bash
 

Next, check if Java is already installed:

java -version
Bash
 

If Java is not currently installed, you’ll see the following output:

Output
Command 'java' not found, but can be installed with:


You may need the Java Development Kit (JDK):

sudo apt install openjdk-8-jdk
Bash
 

Verify that the JDK is installed by checking the version of javac, the Java compiler:

javac -version
Bash
 

You should see the following output:

  • Output
javac 1.8.0_282


Installing the Cassandra packages

In order to install form the .deb  packages add the Apache repository of Cassandra to apt sources

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


You may need to add the GPG key:

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


Update the repositories again:
sudo apt update

Installing Cassandra:
sudo apt install cassandra 


You can start the Cassandra service with:

sudo systemctl start cassandra


Check the status of Cassandra service with:

sudo systemctl status cassandra


You should see an output similar to:

Output
* cassandra.service - LSB: distributed storage system for structured data Loaded: loaded (/etc/init.d/cassandra; generated) Active: active (running) since Tue 2021-04-20 08:41:14 BST; 2min 15s ago Docs: man:systemd-sysv-generator(8) Process: 26925 ExecStart=/etc/init.d/cassandra start (code=exited, status=0/SUCCESS) Tasks: 65 (limit: 37702) Memory: 8.1G CGroup: /system.slice/cassandra.service `-27026 java -Xloggc:/var/log/cassandra/gc.log -ea -XX:+UseThreadPriorities -XX:ThreadPriorityPolicy=42 -XX:+HeapDumpOnOutOfMemoryError -Xss256k -XX:StringTableSize=1000003 -XX:+AlwaysPreTou> Apr 20 08:41:14 AppChassis5B1S1 systemd[1]: Starting LSB: distributed storage system for structured data... Apr 20 08:41:14 AppChassis5B1S1 systemd[1]: Started LSB: distributed storage system for structured data.


To ensure that the service remains persistent after a reboot:

sudo systemctl enable cassandra


Verify the installation with the 'cqlsh' command:

Output
* Connected to Test Cluster at 127.0.0.1:9042. [cqlsh 5.0.1 | Cassandra 3.11.10 | CQL spec 3.4.4 | Native protocol v4] Use HELP for help. cqlsh>