Apache Cassandra is a free, open-source NoSQL database designed for high availability and linear scalability with no single point of failure. It achieves this by distributing data across multiple nodes with no master node, so any node can handle any request. If one node goes down, other nodes continue serving traffic without interruption.
Cassandra is trusted at scale by organizations like Apple, Netflix, and eBay. It is a solid choice when you need a database that can grow horizontally and stay available under heavy load.
This guide shows you how to install Cassandra on Ubuntu 18.04, verify the installation, connect with the CQL shell, and rename the cluster. The same steps work on Ubuntu 16.04, Kubuntu, and Linux Mint.
<strong>Prerequisite:</strong> You need sudo access.
Cassandra 3.11 requires OpenJDK 8. Install it first:
bashsudo apt updatesudo apt install openjdk-8-jdk
Verify with java -version. The output should show openjdk version "1.8.0_191" or similar.
Add the Cassandra repository. Install the HTTPS transport package so apt can reach the repository over HTTPS:
bashsudo apt install apt-transport-https
Import the Apache Cassandra GPG key:
bashwget -q -O - https://www.apache.org/dist/cassandra/KEYS | sudo apt-key add -
The command prints OK to confirm the key was imported successfully. Add the Cassandra 3.11 repository to your apt sources:
bashsudo sh -c 'echo "deb https://archive.apache.org/dist/cassandra/debian/ 311x main" > /etc/apt/sources.list.d/cassandra.list'
Update the package list and install Cassandra:
bashsudo apt updatesudo apt install cassandra
The Cassandra service starts automatically after installation.
Check that Cassandra is running with the nodetool utility:
bashnodetool status
The output lists the cluster nodes and their status. A healthy node shows UN in the first column. The U means the node is Up and the N means its state is Normal. If you see 100.0% in the Owns column, the single node owns the full data range.
Key file locations. Cassandra stores its data in /var/lib/cassandra. Configuration files are in /etc/cassandra, and Java startup options live in /etc/default/cassandra. By default, Cassandra listens on localhost only, which is fine if your application runs on the same server.
Connect with cqlsh. Cassandra ships with cqlsh, a command-line interface for the Cassandra Query Language:
bashcqlsh
A successful connection shows the Cassandra version and the cluster name (Test Cluster by default), followed by the cqlsh> prompt. Type exit to leave the shell.
The default cluster name “Test Cluster” is fine for development but should be changed before using Cassandra in production. Renaming requires three steps.
Step 1. Open cqlsh and update the cluster name in the system table:
sqlUPDATE system.local SET cluster_name = 'YourClusterName' WHERE KEY = 'local';
Type exit to close the shell.
Step 2. Update the cluster name in the Cassandra configuration file /etc/cassandra/cassandra.yaml:
yamlcluster_name: 'YourClusterName'
Replace YourClusterName with the same name you used in Step 1. The names must match exactly.
Step 3. Clear the system cache so Cassandra reads the new name cleanly on restart:
bashnodetool flush system
Then restart the service:
bashsudo systemctl restart cassandra
Run nodetool status again to confirm the cluster is still showing UN after the restart.
Apache Cassandra is now installed and configured on your Ubuntu 18.04 server. Visit the Apache Cassandra documentation to learn how to create keyspaces, define tables, and query data with CQL. Leave a comment below if you run into any issues.
Rocket.Chat is a free, open-source team communication platform built with the Meteor framework. It is a…
MySQL is the most popular open-source relational database management system. It is fast, reliable, and scales…
Apache is the most widely used web server in the world. It is free, open-source, and…
NetBeans is a free, open-source, cross-platform IDE developed by the Apache Software Foundation. It was one…
Pip is the official package manager for Python and the standard way to install libraries from…
R is an open-source programming language and environment built for statistical computing and data visualization. It…