---
title: "How to Install Apache Cassandra NoSQL Database on Linux"
description: "Learn how to provision a powerful NoSQL database with Apache Cassandra!"
canonical: "https://adamtheautomator.com/apache-cassandra/"
---

# How to Install Apache Cassandra NoSQL Database on Linux

> Learn how to provision a powerful NoSQL database with Apache Cassandra!

Source: https://adamtheautomator.com/apache-cassandra/

---

ATA Learning

Tap to hide

[

ATA Learning

](/)

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Search for:  

*   [](https://twitter.com/adbertram)
*   [](https://github.com/Adam-the-Automator)
*   [](https://www.linkedin.com/company/adam-the-automator-llc)
*   [](/feed/)

![How to Install Apache Cassandra Cluster on Linux](https://adamtheautomator.com/wp-content/uploads/2021/12/How-to-Install-Apache-Cassandra-NoSQL-Database-on-Linux.jpg)

# How to Install Apache Cassandra Cluster on Linux

[![](https://secure.gravatar.com/avatar/572a248f516b6d0cd566cb44fdbd9336f30ef95aa0f6d78f118c1f47b1b6d6b7?s=192&d=mm&r=g)Arvid Larson](https://adamtheautomator.com/author/arvid-larson/)22 December 20218 min. read

Categories: [IT Ops](/category/it-ops/)

Tags:[Apache Cassandra](/tag/apache-cassandra/)[Linux](/tag/linux/)

Table of Contents

*   [Prerequisites](#prerequisites)
*   [Installing Java OpenJDK and Python](#installing-java-openjdk-and-python)
*   [Installing Apache Cassandra NoSQL Database](#installing-apache-cassandra-nosql-database)
*   [Configuring the Apache Cassandra Cluster](#configuring-the-apache-cassandra-cluster)
*   [Securing the Apache Cassandra Cluster with Firewall](#securing-the-apache-cassandra-cluster-with-firewall)
*   [Checking the Apache Cassandra Cluster Status](#checking-the-apache-cassandra-cluster-status)
*   [Connecting to the Apache Cassandra Cluster](#connecting-to-the-apache-cassandra-cluster)
*   [Conclusion](#conclusion)

Apache [Cassandra](https://cassandra.apache.org/_/cassandra-basics.html) is a free and open-source [NoSQL](https://azure.microsoft.com/en-us/overview/nosql-database/) distributed database management system created by [Facebook (now Meta)](https://about.facebook.com/). Cassandra’s distributed nature allows for high availability and high performance with no single point of failure.

Because of its scalability, Cassandra is suitable for massive active and critical data set. Big and famous organizations such as [Apple](https://www.techrepublic.com/article/apples-secret-nosql-sauce-includes-a-hefty-dose-of-cassandra/), Bloomberg, BestBuy, eBay, Netflix, Spotify, and many more. And if you’re interested to know Apache Cassandra, you’re in the right place.

In this article, you’re going to learn how to set up and configure an Apache Cassandra Cluster on Linux systems. You’ll also learn how to interact with Cassandra using its command-line tools.

## Prerequisites

To follow along with the examples in this tutorial, be sure to have the following requirements in place.

*   You’ll need two Linux servers are in the same network. This tutorial will be using two [Rocky Linux](https://rockylinux.org/) (v8.5) servers with the following details.

<table><tbody><tr><td>Hostname</td><td>IP Address</td></tr><tr><td>cassandra01</td><td>172.16.1.10</td></tr><tr><td>cassandra02</td><td>172.16.1.15</td></tr></tbody></table>

> _The [Apache Cassandra documentation](https://cassandra.apache.org/doc/latest/cassandra/getting_started/installing.html) does not provide a prescriptive list of compatible Linux distros but mentions that Cassandra may run on CentOS, RHEL, Debian, and SUSE Enterprise Linux._

*   You must have sudo privileges or access to the root account.
*   Nano text editor or any Linux-based text editor.

Related:[How to Edit Files with a Real PowerShell Text Editor](https://adamtheautomator.com/powershell-text-editor/)

## Installing Java OpenJDK and Python

Before jumping in with the Apache Cassandra install, you first install the software dependencies. Cassandra is a Java-based application, and the latest version (v4.0 as of this writing) requires [Java OpenJDK 1.8](https://openjdk.java.net/) and [Python 3.6](https://www.python.org/).

> _This tutorial uses the [DNF](https://docs.fedoraproject.org/en-US/quick-docs/dnf/) package manager for RPM-based Linux distros. You may also use [Yum](https://access.redhat.com/solutions/9934) or [Apt](https://www.digitalocean.com/community/tutorials/what-is-apt) on DEB-based distros like Ubuntu and Debian. Refer to your distro’s documentation to determine which package manager to use._

Follow the steps below to install Java OpenJDK 1.8 and Python 3.6 on each server.

1\. Open your SSH client, connect to your server, and run the `sudo su` command to become root.

```bash
ssh user@server_name_or_IP
sudo su
```

2\. Next, run the `dnf` command below to install the Java OpenJDK 1.8 and Python 3.6 packages. Wait for the installation to complete.

```bash
dnf install java-1.8.0-openjdk python36 -y
```

3\. Now, verify the Java version by running the command below.

```bash
java -version
```

Below you can see the current version of Java OpenJDK is 1.8.0\_312.

![Checking the Java version](https://adamtheautomator.com/wp-content/uploads/2021/12/image-177.png)

Checking the Java version

4\. Next, set up the default Python interpreter on your servers to Python 3.6. To do so, run the `alternatives` command as below.

```bash
alternatives --config python
```

Type the number corresponding to your Python version at the command selection prompt. The example below shows that Python3 is option 2.

![Choosing the default Python interpreter](https://adamtheautomator.com/wp-content/uploads/2021/12/image-178.png)

Choosing the default Python interpreter

5\. Lastly, execute the following command to verify the Python version.

```bash
python --version
```

You should see that _Python 3.x.x_ is the default, similar to the screenshot below.

![Checking the Python version](https://adamtheautomator.com/wp-content/uploads/2021/12/image-179.png)

Checking the Python version

## Installing Apache Cassandra NoSQL Database

You’ve installed the dependencies and made sure they are suitable versions. Now it’s time to install Apache Cassandra!

While there are many ways to install Cassandra, the most convenient way is through the official repository. But there are a few quick steps you need to perform first. To install Cassandra NoSQL Database on Linux systems, proceed as follows.

1\. Run the following command to create a new repository file for Cassandra.

```bash
nano /etc/yum.repos.d/cassandra.repo
```

2\. Copy the following Cassandra repository configuration. This repository is available for most Red Hat distributions, including Rocky Linux.

```powershell
[cassandra]
name=Apache Cassandra
baseurl=https://downloads.apache.org/cassandra/redhat/40x/
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://downloads.apache.org/cassandra/KEYS
```

3\. After editing, save and close the file by pressing `Ctrl+X`, `Y`, and `Enter`.

4\. Next, execute the `dnf` command below to verify all available repositories on your system.

```bash
dnf repolist
```

You should see the Apache Cassandra repository in the repo list, as shown below.

![Checking repositories for Apache Cassandra](https://adamtheautomator.com/wp-content/uploads/2021/12/image-180.png)

Checking repositories for Apache Cassandra

5\. Now, install the Cassandra NoSQL Database by running the following command.

```bash
dnf install cassandra -y
```

You should see a confirmation message after installing Apache Cassandra, similar to the screenshot below.

![Installing Apache Cassandra](https://adamtheautomator.com/wp-content/uploads/2021/12/image-181.png)

Installing Apache Cassandra

## Configuring the Apache Cassandra Cluster

Once you have installed Cassandra, you’ll need to edit the configuration `/etc/cassandra/conf/cassandra.yaml` and set up the Cassandra cluster.

To make the Cassandra cluster work, you’ll need to change the default Cassandra configuration on all servers, such as:

*   Change the default `cluster_name`.
*   Add server IP addresses to the `seeds` option.
*   Change the default `listen_address` to the local IP address.
*   Enable the `rpc_address` for client connections.

Now, proceed with the following steps to set up the Cassandra cluster.

1\. On `cassandra01`, run the following command to open the Cassandra configuration _cassandra.yaml_ for editing.

```bash
nano /etc/cassandra/conf/cassandra.yaml
```

2\. Change the default value of the `cluster name` with the new name. This tutorial uses the new cluster name `ATA Cluster`.

```yaml
cluster_name: 'ATA Cluster'
```

![Specify the cluster\_name for the Apache Cassandra cluster](https://adamtheautomator.com/wp-content/uploads/2021/12/image-182.png)

Specify the cluster\_name for the Apache Cassandra cluster

3\. Now, add each server’s IP address with default Cassandra TCP port 7000 to the `seeds` option below. The format follows the pattern `IP:Port,IP:Port`, and the default port is `7000`.

```yaml
seeds: "172.16.1.10:7000,172.16.1.15:7000"
```

![Add node/server to the Apache Cassandra cluster](https://adamtheautomator.com/wp-content/uploads/2021/12/image-183.png)

Add node/server to the Apache Cassandra cluster

4\. Next, change the default `listen_address` to the server’s IP address, **not** localhost. The option `listen_address` defines which IP address Cassandra will be running.

```yaml
# for cassandra01
listen_address: 172.16.1.10

# for cassandra02
listen_address: 172.16.1.15
```

![Setup bind\_address Apache Cassandra](https://adamtheautomator.com/wp-content/uploads/2021/12/image-184.png)

Setup bind\_address Apache Cassandra

5\. Next, change the default option `rpc_address` with the server IP address, the same value as the `listen_address` option. On the Cassandra cluster environment, all client connections go through the local server IP address on default `TCP` port `9042`.

```yaml
# for cassandra01
rpc_address: 172.16.1.10

# for cassandra02
rpc_address: 172.16.1.15
```

![Setup rpc\_address for client connections](https://adamtheautomator.com/wp-content/uploads/2021/12/image-185.png)

Setup rpc\_address for client connections

6\. Save and close the configuration file by pressing `Ctrl+X`, `Y`, and `Enter`.

7\. After editing the Cassandra configuration, run the following command to start the Cassandra service. This command will automatically start the cluster and reach other servers whose IP addresses are on the `seeds` option.

```bash
service cassandra start
```

8\. Now, confirm the Cassandra service status by running the command below.

```bash
service cassandra status
```

You will get an output similar to the screenshot below. As you can see, the Cassandra service is **active (running)**.

![Verify Apache Cassandra service status](https://adamtheautomator.com/wp-content/uploads/2021/12/image-186.png)

Verify Apache Cassandra service status

## Securing the Apache Cassandra Cluster with Firewall

Setting up a firewall for securing services is an essential task in the production environment. Doing so allows you to limit access to the Cassandra cluster only from specific IP addresses or network ranges.

> _On generic Red Hat Linux distributions, [firewalld](https://firewalld.org/) is the default firewall software._

By default, Cassandra requires two TCP ports need to be open. Port 7000 is the default cluster port, and port 9042 is the native default transport port for client connections.

Follow these steps to secure Cassandra cluster deployment with a firewall.

1\. First, confirm whether you already have `firewalld` on your servers by running the command below.

```bash
dnf search firewalld
```

> _If `firewalld` does not exist, follow steps #2 and #3. But if `firewalld` already exists on the server, skip to step #4 instead._

![Checking for firewalld installation](https://adamtheautomator.com/wp-content/uploads/2021/12/image-187.png)

Checking for firewalld installation

2\. If you don’t have `firewalld` on your system, run the following command to install it.

```bash
dnf install firewalld -y
```

3\. Now, start the `firewalld` service by running the command below. This command will start the `firewalld` service with default rules, opening essential ports and services such as SSH and DHCP clients.

```bash
systemctl start firewalld
```

Related:[Controlling Systemd services with Ubuntu systemctl](https://adamtheautomator.com/ubuntu-systemctl/)

> _By default, firewalld provides a command-line interface `firewall-cmd` for managing and maintaining firewall rules._

4\. Run the following `firewall-cmd` command to create a new _zone_ for the Cassandra cluster and reload the `firewalld` rules.

```bash
# add firewalld zone cassandra-cluster
firewall-cmd --new-zone=cassandra-cluster --permanent

# reload firewalld
firewall-cmd --reload
```

You will see the output message **success**, which means the operation is successful. The option `--permanent` makes new firewall rules permanent.

![Add new zone and reload firewalld](https://adamtheautomator.com/wp-content/uploads/2021/12/image-188.png)

Add new zone and reload firewalld

5\. Next, add your server network CIDR to the `cassandra-cluster` zone. This rule allows any servers or clients on the CIDR `172.16.1.0/24` to talk and connect. To add a single IP address, input the IP address `172.16.1.20`.

```bash
firewall-cmd --zone=cassandra-cluster --add-source=172.16.1.0/24 --permanent
```

6\. Now, run the command below to add Cassandra service ports `7000` and `9042` to the `cassandra-cluster` zone.

```bash
# add storage_port Apache Cassandra to the zone cassandra_cluster
firewall-cmd --zone=cassandra-cluster --add-port=7000/tcp --permanent

# add Apache Cassandra port for client connections
firewall-cmd --zone=cassandra-cluster --add-port=9042/tcp --permanent
```

![Add source IP address and Apache Cassandra ports to firewalld](https://adamtheautomator.com/wp-content/uploads/2021/12/image-189.png)

Add source IP address and Apache Cassandra ports to firewalld

7\. Lastly, reload `firewalld` rules to apply a new configuration by running the command below.

```bash
firewall-cmd --reload
```

The Cassandra cluster is now accessible only through the `172.16.1.0/24` network and will drop all connections from other networks.

## Checking the Apache Cassandra Cluster Status

[Nodetool](https://cassandra.apache.org/doc/latest/cassandra/tools/nodetool/nodetool.html) is a native command utility for managing and monitoring the Cassandra cluster. This tool allows you to show the Cassandra cluster’s metrics status, such as tables and keyspaces, server metrics, applications, client connection metrics, etc.

In general, administrators run the `nodetool` command directly on the operational Cassandra server performing routine database maintenance and monitoring.

Follow the steps below to learn the basics of monitoring the Cassandra cluster using the `nodetool` utility.

1\. Check the Cassandra cluster status by running the following command.

```bash
nodetool status
```

You will get an output similar to the screenshot below.

*   **U** means the node is **UP** or running.
*   **N** means the node is **NORMAL**.
*   The **Address** can be the node IP address or URL.
*   **Load** is the size of files in the Cassandra data directory. This value refreshes every 90 seconds.
*   The **Token** is the number of tokens available on the node.
*   The **Host ID** is the network id of the node. Each node has a different id.

![Checking Apache Cassandra cluster status with Nodetool](https://adamtheautomator.com/wp-content/uploads/2021/12/image-190.png)

Checking Apache Cassandra cluster status with Nodetool

2\. Now, run the command below to get detailed information about the single node.

```bash
nodetool info
```

Below, you can see detailed information about the node such as:

*   Uptime
*   Heap memory info
*   Load
*   Key cache and Counter cache
*   Datacenter location

![Checking detail of node with Nodetool](https://adamtheautomator.com/wp-content/uploads/2021/12/image-191.png)

Checking detail of node with Nodetool

3\. Next, display the Cassandra cluster details by running the command below.

```bash
nodetool describecluster
```

You can see below the detailed Cassandra cluster.

*   **Cluster Information** contains basic information about the Cassandra cluster, including name, default Cassandra partitioner, and schema version.
*   **Stats for all nodes** indicate the current status of all nodes on the Cassandra cluster.
*   If you’ve built the Cassandra cluster on multiple data centers, you will see all of your datacenters on the **Data centers** section.
*   The **Database versions** section shows the Cassandra version on each cluster node.
*   The list of all available keyspaces or databases on the Cassandra cluster is available under the **Keyspaces** section.

![Checking details Apache Cassandra cluster with Nodetool](https://adamtheautomator.com/wp-content/uploads/2021/12/image-192.png)

Checking details Apache Cassandra cluster with Nodetool

## Connecting to the Apache Cassandra Cluster

Installing the Apache Cassandra package on the server also installs the [Cassandra Query Language Shell (CQLSH)](https://cassandra.apache.org/doc/latest/cassandra/tools/cqlsh.html). This tool allows admins to connect to Apache Cassandra and manage databases or keyspaces and users.

Follow the below steps to connect to the Cassandra cluster using the command-line `cqlsh`.

1\. Run the `cqlsh` command below for connecting to the Cassandra cluster. Specify the Cassandra IP address, and the default port for client connections is `9042`.

```bash
cqlsh 172.16.1.10 9042
```

Once you connect to the Cassandra cluster, you will see a similar output like the screenshot below. This example uses the cluster name ATA Cluster on the server IP address `172.16.1.10`.

![Connect to Cassandra with cqlsh](https://adamtheautomator.com/wp-content/uploads/2021/12/image-193.png)

Connect to Cassandra with cqlsh

2\. Now, run the following CQL queries to check which server you connected to, check cluster name, and check all available keyspaces on the Cassandra.

```bash
# show detailed host
SHOW HOST

# show cluster name
DESCRIBE CLUSTER

# list all available keyspaces (databases)
DESCRIBE KEYSPACES
```

You will see a similar output to the screenshot below. The `SHOW HOST` query shows you where you’re connected, the query `DESCRIBE CLUSTER` shows you the Cassandra cluster name, and the query `DESCRIBE KEYSPACES` shows you the list of keyspaces on your Cassandra node.

![Connecting to Apache Cassandra using cqlsh commands](https://adamtheautomator.com/wp-content/uploads/2021/12/image-194.png)

Connecting to Apache Cassandra using cqlsh commands

3\. Finally, type the `exit` to log out from the `cqlsh` environment.

## Conclusion

Throughout this tutorial, you’ve learned how to install and configure Apache Cassandra on Linux. You’ve also configured the Apache Cassandra cluster using two Linux servers and secured the deployment using the Firewalld.

At this point, you’re ready to add more servers and scale your deployments, providing high availability, consistency, and redundancy for your data.

What’s next for you? Perhaps begin with setting up the authentication and authorization on your Cassandra cluster, then set up keyspace/database replication for your applications. And while you’re at it, why not learn how to maintain the Apache Cassandra cluster with nodetool?

Share this article

[Share on X](https://twitter.com/intent/tweet?url=https%3A%2F%2Fadamtheautomator.com%2Fapache-cassandra%2F&text=How%20to%20Install%20Apache%20Cassandra%20Cluster%20on%20Linux)[Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fadamtheautomator.com%2Fapache-cassandra%2F)[Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fadamtheautomator.com%2Fapache-cassandra%2F)

## Related Posts

![](https://adamtheautomator.com/wp-content/uploads/2022/09/Practical-Linux-Unix-Tee-Commands-for-the-Linux-Admin.jpg)

### [Master Unix tee Commands for Real-World Linux Admin Tasks](/unix-tee/)

Simplify Linux output management and streamline your workflow with the “Unix tee” command. This tutorial guides you through its practical applications.

![](https://adamtheautomator.com/wp-content/uploads/2024/03/openldap-4.jpg)

### [How to Install and Configure an OpenLDAP Ubuntu Server](/openldap/)

Unlock the power of OpenLDAP on Ubuntu for centralized user authentication, seamless access control management, and enhanced directory services!

![](https://adamtheautomator.com/wp-content/uploads/2024/03/pipe-command-in-linux-1.jpg)

### [Unleashing the Power of the Pipe Command in Linux](/pipe-command-in-linux/)

Unlock the prowess of the pipe command in Linux to streamline tasks, boost productivity, and simplify complex operations effortlessly!

## Categories

*   [IT Ops](/category/it-ops/)
*   [Cloud](/category/cloud/)
*   [DevOps](/category/devops/)
*   [Home Ops](/category/home-ops/)
*   [Information Security](/category/infosec/)
*   [Software Development](/category/software-development/)

## Site

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Copyright 2026© ATA Learning | [Privacy Policy](/privacy/)
