Introduction
let’s briefly understand – What is Apache Cassandra?
It is a NoSQL database that is free and open source, with no single point of failure. It offers high availability and linear scalability without sacrificing performance. Many businesses with sizable, active data sets, such as Reddit, Netflix, Instagram, and GitHub, use it.
In this tutorial, you will install this on Debian 10 Linux.
Prerequisites
1) Root or a user with sudo privileges.
Installing Java
The latest stable version of Apache Cassandra is 3.11
, and it requires OpenJDK 8, which is not present in the official Debian Buster repositories at the time this tutorial was written.
We will enable the AdoptOpenJDK repository and install the prebuilt OpenJDK 8 package.
To add a new repository over HTTPS, update the packages list and install the required dependencies:
Add the AdoptOpenJDK APT repository to your system and import the repository’s GPG key:
Execute the following commands to install Java 8:
Verify it was once done by printing the Java version:
The output should look like this:
Output
openjdk version "1.8.0_232"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_232-b09)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.232-b09, mixed mode)
Install on Debian 10
We will use the deb package from the vendor repository to install Apache Cassandra. We must first enable the Apache Cassandra repository to do this.
Use the wget
the command below to import the repository’s public key:
The output from the aforementioned command should be OK
. As a result, the packages from this repository will be regarded as trustworthy because the key was successfully imported.
Use the command below to add the Cassandra repository to your list of system sources:
Install the Apache Cassandra package after updating the package index:
The Cassandra service will launch automatically after the installation has been completed. To ensure Cassandra is up and running, enter:
You should see something like this:
Output
Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
-- Address Load Tokens Owns (effective) Host ID Rack
UN 127.0.0.1 103.71 KiB 256 100.0% dd8f6709-08ef-45b8-881e-5c1b5bbfc7f7 rack1
All done. Apache Cassandra has been installed successfully.
Configuration
The /var/lib/cassandra
directory stores Apache Cassandra data. Java start-up options can be configured in the /etc/default/cassandra
file, which is where configuration files for Cassandra are placed.
Cassandra only listens on localhost by default. You do not need to change the binding interface if the client connecting to the database is also operating on the same system.
Use the cqlsh
tool, which comes with the Cassandra package, to communicate with Cassandra using the command line.
Output
Connected to Test Cluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 3.11.5 | CQL spec 3.4.4 | Native protocol v4]
Use HELP for help.
cqlsh>
Rename Cluster
The cluster’s default name is “Test Cluster.” The following steps should be followed if you want to change it:
1) Using cqlsh
, access the Cassandra CQL terminal:
2) To rename the cluster to “Stack Cluster,” enter the following command:
Replace “Stack Cluster” with the name of your choice. Type exit
to close the terminal after you are done.
3) Edit the cassandra.yaml
configuration file and enter your new cluster name:
4) Get rid of the system cache:
5) Run the following command to restart Cassandra:
Also, read WordPress Deployment Made Easy: Docker Compose 2023
Conclusion
We have demonstrated how to set up it on Debian 10 and how to rename the default cluster if desired. Visit the official Documentation page for more details on how to start using it.
If you have any queries, feel free to post a comment below, and we’ll be happy to answer them.