In this article, we’ll install Apache Cassandra on Ubuntu 20.04.
Apache Cassandra is a free and open-source, distributed, wide column store, NoSQL database management system designed to handle large amounts of data across many commodity servers, providing high availability with no single point of failure. Apache Cassandra is used by many companies that have large, active data sets, including Reddit, NetFlix, Instagram, and Github.
Let’s start with the installation.
- A Ubuntu 20.04 installed server or KVM VPS.
- A root user access or normal user with administrative privileges.
1. Keep the server up to date
# apt upgrade -y
# apt upgrade -y
2. Install Java
We’ll install Java 8 which is requires for Apache Cassandra 3.11 and for Apache Cassandra 4.0, Java 11 added as a Experimental support.
# apt install openjdk-8-jdk -y
Verify the installation by following command:
# java -version
openjdk version “1.8.0_275”
OpenJDK Runtime Environment (build 1.8.0_275-8u275-b01-0ubuntu1~20.04-b01)
OpenJDK 64-Bit Server VM (build 25.275-b01, mixed mode)
3. Install Apache Cassandra
First, install the dependencies necessary:
# apt install apt-transport-https
Import the repository’s GPG key and add the Cassandra repository to the system:
# wget -q -O – https://www.apache.org/dist/cassandra/KEYS | sudo apt-key add –
# sudo sh -c ‘echo “deb http://www.apache.org/dist/cassandra/debian 311x main” > /etc/apt/sources.list.d/cassandra.list’
Once the repository is enabled, update the packages list and install the latest version of Apache Cassandra:
# apt update
# apt install cassandra
Apache Cassandra service will automatically start after the installation process is complete. You can verify it by typing:
# nodetool status
You should see something similar to this:
— Address Load Tokens Owns (effective) Host ID Rack
UN 127.0.0.1 70.67 KiB 256 100.0% eb8aaf49-9b32-4e7a-a8f4-d603f42bc0e5 rack1
That’s it. Apache Cassandra installed on Ubuntu server.
4. Configuring Apache Cassandra
Apache Cassandra data is stored in the /var/lib/cassandra directory, configuration files are located in /etc/cassandra, and Java start-up options can be configured in the /etc/default/cassandra file.
By default, Cassandra is configured to listen on localhost only. If the client connecting to the database is also running on the same host, you don’t need to change the default configuration file.
To interact with Cassandra through CQL (the Cassandra Query Language) you can use a command-line tool named cqlsh that is shipped with the Cassandra package.
The default Cassandra cluster is named “Test Cluster”. If you want to change the cluster name, perform the steps below:
Login to the Cassandra CQL terminal with cqlsh:
Run the following command to change the cluster name to “Linuxize Cluster”:
UPDATE system.local SET cluster_name = ‘Linuxize Cluster’ WHERE KEY = ‘local’;
Change “Linuxize Cluster” with your desired name.
Once done, type exit to exit the console.
Open the cassandra.yaml configuration file:
# vi /etc/cassandra/cassandra.yaml
Enter your new cluster name.
cluster_name: ‘Linuxize Cluster’
Save and close the file.
Clear the system cache:
nodetool flush system
Restart the Cassandra service:
# systemctl restart cassandra
That’s it. The installation and configuration has been completed successfully.
In this article, we have seen how to install Apache Cassandra on Ubuntu 20.04.