How to Install Cassandra on Ubuntu

Apache Cassandra is a highly scalable distributed NoSQL database designed for handling massive amounts of data across multiple commodity servers. Its fault-tolerant architecture and flexible data model make it ideal for big data applications and real-time data processing.

In this post, we will discuss how to install Cassandra Ubuntu system by providing you with knowledge and further we will understand how to configure Cassandra on your Ubuntu system.

Prerequisites

Before diving into the installation, ensure your Ubuntu system meets the following requirements:

  • Ubuntu Version: This guide focuses on Ubuntu 22.04 LTS stands for Long-Term Support but the instructions are generally applicable to recent LTS versions. You can check the Ubuntu version for the Cassandra requirements.
  • Root or Sudo Privileges: Some commands require root or sudo privileges to execute.
  • Java OpenJDK: Cassandra relies on Java for its operation.

Installing Apache Cassandra on Ubuntu

Following are the methods described below on how to install Cassandra on the Ubuntu Linux system:

1. Install Java OpenJDK

Ubuntu install Cassandra requires Java OpenJDK for execution. First update the package list with the following command:

sudo apt update

Then install OpenJDK using the following command, you can download according to your version preference:

sudo apt-get install openjdk-11-jdk
install openjdk

Verify Java Installation

Once installed verify the Java version by running the following command:

java -version

The output should display the installed Java version. Another good option is to install Java on Ubuntu separately to avoid any isssues.

java version

2. Add the Cassandra Repository and GPG Key

The official Cassandra packages are not included in the default Ubuntu repositories. We need to add the Apache Cassandra repository and its GPG key for secure package verification.

Import GPG Key

You can import the GPG key using the Curl command. Here type the following:

curl -L https://www.apache.org/dist/cassandra/KEYS | sudo apt-key add -
add GPG keys

Add Cassandra Repository

Create a new file named /etc/apt/sources.list.d/cassandra.sources.list with your preferred text editor and add the following line replacing with your desired Cassandra version for example 4.0:

deb http://www.apache.org/dist/cassandra/debian <version> main
Cassandra repository

Save and close the file. You can download Cassandra from the deb method or from the official website.

3. Install Apache Cassandra

Update the package list again to reflect the newly added repository:

sudo apt update

Finally, install Cassandra using the following command:

sudo apt install cassandra

The installation process might take a while depending on your internet speed.

install cassandra

4. Enable and Start Cassandra Service

By default, the Cassandra service might not be automatically enabled to start on boot. To enable the Cassandra type the following command:

sudo systemctl enable cassandra

It will enable the service on your Ubuntu system then start the service by typing this command:

sudo systemctl start cassandra
enable cassandra

5. Verify Cassandra Installation

To confirm a successful installation, check the service status:

sudo systemctl status cassandra

The output should display the service as “active (running)”.

cassandra status

Additional Verification

You can also use the nodetool command-line utility to check the cluster information:

nodetool status

This command should display information about the Cassandra cluster, including the running nodes and their status.

status nodetool

Configuring Cassandra on Ubuntu

By default, Cassandra runs in a single-node cluster on your local machine. For production deployments, you’ll need to configure a multi-node cluster with other Cassandra instances. Here’s a brief overview of some configuration options:

  • Cluster Name: The name of your Cassandra cluster is defined in the cassandra.yaml configuration file located at /etc/cassandra/cassandra.yaml. You can edit this file to change the cluster name.
  • Seed Nodes: In a multi-node cluster, each node needs to know the location of other nodes. You’ll need to specify the IP addresses of seed nodes in the cassandra.yaml file.
  • Data Replication: Cassandra replicates data across multiple nodes for fault tolerance. You can configure the replication factor the number of replicas for your data in the cassandra.yaml file.

Modifying configuration files requires a restart of the Cassandra service afterward. Use the following command to apply changes.

sudo systemctl restart cassandra

Connecting to Cassandra

Once Cassandra is running you can connect to it using the Cassandra Query Language (CQL) shell. Open a terminal and type:

cqlsh

This will launch the CQL shell, allowing you to interact with your Cassandra cluster by issuing CQL statements to create keyspaces, and tables, insert data, and perform queries.

cqlsh cassandra

Securing Cassandra

For production environments securing your Cassandra cluster is important. Here are some essential security considerations:

  • Enable authentication to restrict access to the Cassandra cluster. You can configure username and password-based authentication or integrate with LDAP or Kerberos for centralized authentication.
  • Implement authorization controls to define user permissions for accessing specific keyspaces and tables within the cluster. This ensures full control over data access.
  • Consider encrypting data at rest and in transit for further protection. Cassandra provides options for data encryption at rest and in-flight encryption for communication between nodes.

Conclusion

By following these steps and leveraging available resources, you can successfully install, configure, and use Apache Cassandra on your Ubuntu system. Remember, Cassandra offers a rich set of features and capabilities for managing large-scale data. Explore its functionalities and explore its potential for your big data applications.

Installing Cassandra on Ubuntu can be a complex process especially when it comes to configuration and ensuring high availability and often lack the resources and control needed for such demanding tasks. Upgrading to an Ultahost Linux VPS hosting plan empowers you to manage Cassandra databases effectively and allows you to configure for optimal performance and data replication across multiple nodes.

FAQ

What are the system requirements for installing Cassandra on Ubuntu?
How do I install Java for Cassandra on Ubuntu?
Where can I download Cassandra for Ubuntu?
How do I start the Cassandra service after installation?
How do I check if Cassandra is running on Ubuntu?

Related Post

Setup and Configuration of FreeRADIUS + MySQL

Network authentication is an essential aspect of mainta...

How To Use MySQL Triggers with Examples

MySQL triggers are a powerful feature that allows autom...

What Is the Default MySQL Port Number?

MySQL is a well-known Open Source SQL Data Management S...

How to Install phpPgAdmin on Ubuntu 24.04

phpPgAdmin is a free, open-source web-based tool that s...

How to Install MongoDB on Windows

MongoDB, a leading NoSQL database, is a powerful and ve...

How to Run SQL Queries in phpMyAdmin

phpMyAdmin a free and open-source web application serve...

Leave a Comment