In this tutorial, we will show you how to install Apache Cassandra on a Debian 9 VPS.
Apache Cassandra is a free and open-source distributed NoSQL database management system that provides High-Availability with no single point of failure. Cassandra does not use the table model seen in MySQL, MSSQL or PostgreSQL – rather, it uses a cluster model. It is designed to handle large amounts of data across commodity hardware. It provides linear scalability by adding a new machine to it without any interruption to applications. Apache Cassandra is used by many popular organizations including Apple, NetFlix, eBay, and Easou.
Let’s begin with the installation.
Table of Contents
Prerequisites
- For the purposes of this tutorial, we will use a Debian 9 VPS.
- The latest version of Java 8, either the Oracle Java Standard Edition 8 or OpenJDK 8 is installed.
- Full SSH root access or a user with sudo privileges is also required.
Step 1: Connect via SSH and Update the OS
Connect to your server via SSH as the root user using the following command:
Remember to replace “IP_ADDRESS” and “PORT_NUMBER” with your server’s respective IP address and SSH port number.
Before starting with the installation, you will need to update your OS packages to their latest versions. It’s easy to do, and it won’t take more than a few minutes.
You can do this by running the following command:
Once the updates are completed, we can move on to the next step.
Step 2: Install Java 8
Apache Cassandra requires the latest version of Java 8 to be installed. To install Java 8 on your Debian 9 VPS, run the following command:
Next, verify the Java installation by running the following command, which will print the Java version:
The output should look something like this:
Step 3: Install Apache Cassandra
To install Apache Cassandra on your server, we need to add the Apache Cassandra repository.
Add the Cassandra repository by running the following command:
Add the Apache Cassandra repository keys using the following command:
Next, update the package index and install Apache Cassandra using the following command:
Once installed, start the Apache Cassandra service and enable it to start after system reboot with the following command:
To check the service status, use the following command.
We should see the following output:
Step 4: Test the Apache Cassandra Installation
Apache Cassandra provides a nodetool
command-line utility for managing Apache Cassandra cluster. Here, we can do some tests using the nodetool to verify the Cassandra cluster.
To begin with, run the nodetool command to get the Cassandra server status.
And you should get an output similar to the following:
As you can see, the Apache Cassandra is ‘Up’ with the ‘Normal’ state. And it’s running under the localhost IP.
Step 5: Configure Apache Cassandra
Apache Cassandra stores all of its configuration files in the /etc/cassandra
directory and data is stored in the /var/lib/cassandra
directory.
By default, Apache Cassandra is configured to listen on localhost only and you don’t need to change the default configuration file if the client is also running on the same host.
You can also connect Apache Cassandra with Cassandra Query Language (CQL) command-line utility.
Simply run the following command to interact with Apache Cassandra:
The output will be similar to the following:
By default, the Apache Cassandra cluster is named “Test Cluster” as shown in the above output. You can change the cluster name with the following command:
Change ‘RoseHosting Cluster’ with your desired name. Once done type exit to exit from the console. Next, open the cassandra.yaml configuration file and provide your new cluster name.
Change the following line with your desired name:
Save and close the file. Then, clear the system cache with the following command:
Finally, restart the Apache Cassandra service to apply the configuration changes:
Next, log in again with cqlsh and verify the new cluster name is visible.
The output will be similar to the following:
Congratulations. We have successfully installed Apache Cassandra on our Debian 9 VPS. If you are new to Apache Cassandra, it is recommended to use the official documentation as a starting point. The documentation is available at the Apache Cassandra documentation page, and it will help you learn how to configure and use the service for your projects.
Follow this guide for installing Apache Cassandra on Ubuntu 20.04
Of course, you don’t have to install Apache Cassandra on a Debian 9 by yourself if you use one of our Linux VPS Hosting services, in which case you can simply ask our expert Linux admins to install Apache Cassandra on a Debian 9 on your server for you. They are available 24×7 and will take care of your request immediately.
PS. If you liked this post on how to Install Apache Cassandra on Debian 9, please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.