Table of Contents
Today, In this article we will show you how to Install Cassandra on Ubuntu 22.04 LTS Jammy. The most recent LTS (long term support) version of Ubuntu is 22.04 Jammy Jellyfish. Many customers are curious about how the new version compares to earlier Ubuntu releases and to Linux distributions created by other developers before deciding to embrace it. We’ve already done the grunt work for you, though. We have been using Ubuntu 22.04 for several months and can share all the advantages and disadvantages we have discovered.
Better colour and theme settings, including a dark theme, are available in the new version of GNOME. The new dark theme adheres to a standard of colours that makes more sense and is more well-respected by desktop programmes. Currently, Cassandra and MongoDB are two of the most widely used NoSQL databases. Cassandra is intended to handle massive amounts of data on distributed systems in a scalable, fail-safe manner (clusters).
This database, like Apache HBase, is written in Java as opposed to CouchDB and MongoDB (both C++). The Cassandra Query Language, a SQL-like query language that can act as a straightforward interface, has been available since version 0.8. We mentioned below are the steps to install Cassandra on Ubuntu 22.04 LTS Jammy.
Steps to install Cassandra on Ubuntu 22.04 LTS Jammy
Install Cassandra using SNAP
Step 1: Using SNAP is the first and simplest method for installing Apache Cassandra on Ubuntu 22.04. On Ubuntu computers, it is a universal and APT substitute package manager that is turned on by default. It enables users to install apps in a closed environment that is still accessible in the same way as other applications.
sudo snap install cassandra
Update Ubuntu 22.04
Step 1: Let’s first perform the system update and upgrade command to make sure our system is up to date before executing any other commands. It is also significant since, in this technique, the Cassandra database will be installed via the APT package manager.
sudo apt update && sudo apt upgrade
Step 2: Also add:
sudo apt install apt-transport-https
Install OpenJDK
Step 1: We don’t need to add any repository for getting Java on our Linux system. We can use the APT package manager to set it up.
sudo apt install default-jdk
Step 2: To check the version after the installation use:
java –version
Add GPG Key
Step 1: First import the key from the Ubuntu Keyserver for Cassandra.
gpg –keyserver keyserver.ubuntu.com –recv-keys 7E3E87CB
Step 2: Now, export it to GPG format and readable by our system to use for the repository we are going to add for Cassandra.
gpg –export –armor 7E3E87CB | sudo gpg –dearmour -o /etc/apt/trusted.gpg.d/cassandra-key.gpg
Add Cassandra Repository on Ubuntu 22.04
Using the official repository of Ubuntu 22.04, we are unable to directly install the Cassandra Database. Consequently, we must include the one provided by its creators:
Step 1: For Cassandra version 4.0.x add the following repo
sudo sh -c ‘echo “deb 40x main” > /etc/apt/sources.list.d/cassandra.list’
Step 2: Whereas, the users who want to try out version 4.1.x add this one
sudo sh -c ‘echo “deb 41x main” > /etc/apt/sources.list.d/cassandra.list’
Step 3: After adding repository it is necessary to run the system update command to refresh the APT package index cache.
sudo apt update
Install Apache Cassandra
Step 1: We can now install the Cassandra database on Ubuntu using the command line and the APT package management. The advantage of this approach is that we can quickly update this Database system in the future by using the system update command.
sudo apt install cassandra
Check Apache Cassandra Status
Step 1: Once the installation is completed, to check the status of Cassandra server and node to know weather it is running without any error use:
systemctl status cassandra –no-pager -l
Step 2: For Node:
nodetool status
Step 3: The UN in the output means it is running fine.
Command to enable, stop, start and restart
So, when this database system is installed, a system service will also be created to help manage it and run in the background.
Step 1: To Enable the service, so that Cassandra service can start with system boot use:
sudo systemctl enable cassandra
Step 2: To start the service:
sudo systemctl start cassandra
Step 3: To restart it:
sudo systemctl restart cassandra
Step 4: To stop the service use:
sudo systemctl stop cassandra
Check Cassandra version on Ubuntu 22.04
To check the version of Cassandra on Ubuntu, we can use its command tool known as cqlsh.
Step 1: First type the given command on your terminal to access the tool:
cqlsh
Step 2: Now to check the version, simply use:
show VERSION
Step 3: To exit the command line of the tool, we can use:
exit
Update
As there are two ways to install Cassandra on Ubuntu 22.04, run the following command to update your database instance according to your chosen method:
Step 1: For SNAP users:
sudo snap refresh cassandra
Step 2: For APT repository method:
sudo apt update && sudo apt upgrade
Uninstall or Remove
Depending on the method you used to set it up, use the appropriate command to remove the Cassandra Database instance if you no longer need it on your Ubuntu 22.04 server.
Step 1: For SNAP
sudo snap remove cassandra
Step 2: For APT users:
sudo apt autoremove –purge cassandra
Step 3: To remove GPG and repo as well:
sudo rm /etc/apt/sources.list.d/cassandra.list
sudo rm /etc/apt/trusted.gpg.d/cassandra-key.gpg
Final Words
We hope you like our article on how to Install Cassandra on Ubuntu 22.04 LTS Jammy. Only UNIX-like operating systems, including Mac OS X and Linux, can run Cassandra, which is written in Java and RubyGems. Particularly with relational databases, experienced developers should take a closer look at the structure and data model of Cassandra because there are some similarities in the data model in addition to the emergence of fundamentally new terms as well as some familiar terms that, while present in Cassandra, have a completely different meaning.