How to Install Apache Cassandra on Oracle Linux

Apache Cassandra is a free NoSQL database management system. It supports scalability and availability and can handle large amounts of data across many servers. Let’s find out how to install Apache Cassandra on Oracle Linux.

Apache Cassandra is the most popular to handle large amounts of unstructured data. It works on the peer-to-peer model similar to DynamoDB and Google’s Big Table. Hence, there exists no master node in the server. All nodes are equal when it comes to reading/writing permissions.

This tutorial will cover how you can install Apache Cassandra on Oracle Linux and configure Cassandra nodes on your local machine. 

Apache Cassandra Properties

Apache Cassandra is widely used by eBay, GitHub, Netflix, and over 1500 more companies.

  • High fault tolerance
  • No single point of failure
  • Outperforms other NoSQL applications 
  • No network bottlenecks
  • No downtime and increased throughput
  • Provides durability even when the data center is down
  • Offers a choice between synchronous and asynchronous replication

Prerequisites

For Apache Cassandra, you will need a Linux system with sudo privileges and Oracle Java JDK already installed in your system.

Install Apache Cassandra on Oracle Linux

1. Check Java Version

Before starting the installation, check if Java already exists on the system. Open the terminal by pressing the shortcut key “Ctrl+Alt+T”, and execute the command given below:

java –version

This is what your output would look like:

Check Java Version

However, if it does not exist, you will have to install it. To learn how to install Java, check this article.

Alternatively, execute the command given below to install Java JDK.

sudo dnf install java-11-openjdk

For the entire tutorial, we will use the dnf package manager 

2. Update the System

Now that Java is installed, begin the installation by cleaning the repository and updating the existing packages. Specifically, use the command given below:

sudo dnf update

If the dnf package manager does not exist, you will have to install yum package manager and then install dnf.

Alternatively, you can use the following command:

sudo apt update

The system will start updating like this:

Update the System

Next, install the Yum package manager and Extra Packages for Enterprise Linux (EPEL) repository using the install command. For example:

sudo dnf install yum-utils
sudo dnf install epel-release

Since most EPEL repositories rely on PowerTools for creating or installing applications, we will enable that. Use the code given below:

sudo dnf config-manager --set-enabled powertools

3. Add Apache Cassandra Repository

The third step is to add the Cassandra repository to the default Linux repositories. It is because the default packages for Apache Cassandra are not available by default in the Linux repository. This step also ensures that the latest version of Cassandra is installed. Follow these steps to add the packages:

First, create the repository either using the nano or vi editors.

sudo vi /etc/yum.repos.d/cassandra.repo

In the cassandra.repo folder, add the following line of code:

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

After that, save the changes and exit the editor.

This is what the output would look like:

Add Repository

Finally, update the repository packages again using the update command. For instance:

sudo dnf update -y

4. Install Apache Cassandra

Now that we have added the repository, we can easily install Apache Cassandra on Linux. Type the command given below, and hit the “Enter key”.

sudo dnf install cassandra 

You will get a similar output:

Install Apache Cassandra

5. Start Apache Cassandra

After the installation, we will enable the service to start at boot. We will also manually start the service and check if it is running correctly. For instance,

sudo service cassandra start
sudo systemctl enable cassandra

The service would start, and it will look like this:

Start Apache Cassandra
systemctl status cassandra

To check if Cassandra is running on the localhost:9042, use the status command. For example:

nodetool status

This is what your output would look like:

Start Apache Cassandra

6. Install Cassandra Query Language (CQL) on Oracle Linux

Cassandra Query Language (CQL) is a query language similar to SQL. We will install this language to use it in the Apache Cassandra application. But first, we will install Python:

sudo dnf install python38
Install Cassandra Query Language (CQL) on Oracle Linux

Configure your latest version as a default version. However, you will do this if you have multiple Python versions installed. For example:

sudo update-alternatives --config python3

To know more about installing Python, check out this guide.

Now, using the pip package manager, install the CQL. For instance:

pip3 install --user cqlsh

After it is successfully installed, check its version:

cqlsh --version

Finally, it is successfully installed. To open it, execute the following command:

cqlsh 

You will get a similar output:

Install Apache Cassandra on Oracle Linux

7. Configure Apache Cassandra Cluster on Oracle Linux

To update the Cassandra cluster to localhost, execute the command given below:

UPDATE system.local SET cluster_name = 'H2s Cluster' WHERE KEY = 'local';

After that, using either nano or vi editors, edit the cassandra.yaml file. This file consists of all Cassandra configurations.

sudo nano /etc/cassandra/default.conf/cassandra.yaml

Replace the cluster_name variable name with the name of your choice. After that, save the changes and exit the editor. This is how you will update it:

Configure Apache Cassandra Cluster

After that, flush the cache and restart the Cassandra service to reflect the changes.

nodetool flush system
sudo systemctl restart cassandra

Now, to confirm that the cluster name has changed, execute the following commands:

cqlsh
DESC CLUSTER

You will get a similar output:

8. Update Apache Cassandra on Oracle Linux

In case, you want to update the existing version of Apache Cassandra on your Linux machine, update the packages and fetch the changes. For example:

sudo dnf update && sudo dnf upgrade

Hence, this is what your output would look like:

Update Apache Cassandra on Oracle Linux

9. Uninstall or Remove Apache Cassandra

On the other hand, you can easily uninstall or remove Cassandra from Linux machines using the remove command. Specifically:

sudo dnf remove cassandra

Furthermore, you will also uninstall its configuration files. For example:

sudo rm /etc/yum.repos.d/cassandra.repo

Finally, you learned how to install Apache Cassandra in this article. Apache Cassandra also enables you to add user authentication and admin users in your Cassandra databases. To find out more about Cassandra, visit this website. We hope this article was helpful to you. 

If this guide helped you, please share it.

Leave a Reply
Related Posts