Skip to content Skip to footer

Getting Started with Cassandra: Installation and Setup Guide


Getting Started with Cassandra: Installation and Setup Guide Image by Author

 

Introduction

 
Apache Cassandra is a distributed, open-source NoSQL database system designed to manage massive amounts of data across multiple servers to ensure high availability and performance. It is known for its horizontal scalability in Applications where reliability, speed, and uptime are important. This guide will walk you through the process of installing and setting up Cassandra on Linux, Windows, and macOS. It will show you how to configure your system, connect to Cassandra Shell, and get ready to manage data at scale.

Originally developed by Facebook and later adopted by the Apache Software Foundation, Cassandra is known for handling huge amounts of data across multiple servers without a single point of failure. It uses a unique data storage mechanism called a data storage model. It is “peer-to-peer” meaning there is no central server in the system. Each node is equally important. This approach allows Cassandra to deliver excellent fault tolerance and is ideal for applications that need constant uptime and quick data accessibility, such as e-commerce, real-time analytics, and IoT.

 

Architecture and Key Features

Cassandra’s peer-to-peer, distributed architecture eliminates single points of failure and enables seamless horizontal scaling, making it ideal for mission-critical applications requiring constant uptime. By utilizing a tunable consistency model, Cassandra provides flexibility to balance latency and data accuracy per query, accommodating a wide range of application needs from quick searches to secure order processing. Its columnar data model supports high-speed writes, especially beneficial for handling high-velocity data in IoT, log aggregation, and time-series databases. Adding nodes to a Cassandra cluster is straightforward, as the system automatically manages data distribution, ensuring efficient scaling and data balance across the network.

 

Use Cases and Integration in Big Data Ecosystems

Known for powering real-time recommendations, analytics platforms, and decentralized storage systems, Cassandra is widely adopted in industries like social media, finance, and telecommunications, where rapid data access and reliability are essential. Additionally, Cassandra integrates smoothly with big data tools such as Apache Spark and Apache Kafka, making it an excellent choice for real-time data pipelines that demand high-performance processing and storage capabilities.

Whether you’re working with time-series data, managing a large dataset, or building applications that demand real-time data processing, Cassandra offers a robust solution with its high-performance, scalable, and decentralized design.

 

Prerequisites

To install and set up Cassandra, please ensure that you meet the following requirements:

  • Basic Knowledge of Command Line: Some familiarity with using the command line will simplify the setup process
  • Operating System Compatibility: You should have a system running:
    • Linux (Ubuntu/Debian or Red Hat/Rocky Linux)
    • Windows (using the Windows Subsystem for Linux)
    • macOS
  • Internet Connection: Required to download Cassandra and other dependencies
  • Administrator Privileges: You’ll need permission to install software on your system, especially on Windows and Linux systems

 

Step-by-Step Guide for Installation

 

Installing Cassandra on Linux

Let’s start by installing Cassandra on Linux distributions such as Ubuntu/Debian and Red Hat/Rocky.

 

Install on Ubuntu/Debian

  • Install Java: Cassandra requires Java, so start by installing OpenJDK. Open your terminal and run:
sudo apt update
sudo apt install openjdk-11-jdk

 

  • Verify the installation by checking the Java version:

 

  • Add the Cassandra Repository: To use the latest stable version, add the Cassandra repository:
echo "deb https://www.apache.org/dist/cassandra/debian 40x main" | sudo tee -a /etc/apt/sources.list.d/cassandra.sources.list

 

  • Add the GPG Key: Cassandra’s repository key is required for a secure installation:
curl https://www.apache.org/dist/cassandra/KEYS | sudo apt-key add -

 

  • Update Package List and Install Cassandra: Now, update your package list and install Cassandra:
sudo apt update
sudo apt install cassandra

 

  • Start and Enable Cassandra: Cassandra should start automatically. To start it manually, use:
sudo systemctl start cassandra

 

  • Enable Cassandra to start on boot with:
sudo systemctl enable cassandra

 

Install on Red Hat/Rocky Linux

  • Install Java: As with Ubuntu, you’ll need to install Java first:
sudo systemctl enable cassandra

 

  • Add the Cassandra Repository:
sudo nano /etc/yum.repos.d/cassandra.repo

 

  • Add the following lines to the file and save:
[cassandra]
name=Apache Cassandra
baseurl=https://www.apache.org/dist/cassandra/redhat/40x/
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://www.apache.org/dist/cassandra/KEYS

 

  • Install Cassandra: Update the repository index and install Cassandra:
sudo yum install cassandra

 

  • Start and Enable Cassandra: Start the Cassandra service and enable it to launch on boot:
sudo systemctl start cassandra
sudo systemctl enable cassandra

 

 

Installing Cassandra on Windows

To install Cassandra on Windows, we will use the Windows Subsystem for Linux (WSL).

  • Set up WSL and install Ubuntu and restart your computer if prompted:

Enable WSL2: Ensure you’re running Windows 10 version 2004 or higher or Windows 11. Open PowerShell as an administrator and enable WSL

 

  • Install Ubuntu via the Microsoft Store: Download and install Ubuntu from the Microsoft Store. After installing, open Ubuntu to complete the setup
  • Install Cassandra in Ubuntu (via WSL): Once you have Ubuntu running in WSL, install Java
sudo apt update
sudo apt install openjdk-11-jdk

 

  • Add the Cassandra Repository and Key:
echo "deb https://www.apache.org/dist/cassandra/debian 40x main" | sudo tee -a /etc/apt/sources.list.d/cassandra.sources.list
curl https://www.apache.org/dist/cassandra/KEYS | sudo apt-key add -

 

sudo apt update
sudo apt install cassandra

 

sudo service cassandra start

 

  • Test the Installation: To test that Cassandra is running, connect to the Cassandra shell (cqlsh) and run a command

 

You should see the Cassandra shell prompt (cqlsh>) appear, indicating a successful connection.

 

Installing Cassandra on macOS

The easiest way to install Cassandra on macOS is by using Homebrew. Make sure Homebrew is installed on your system. If it isn’t, install it by running:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  • Install Java: Cassandra requires Java, so first, ensure it’s installed via Homebrew:

 

  • Start Cassandra: Cassandra will not start automatically. You can start it with:
brew services start cassandra

 

  • Test the installation: To verify that Cassandra is running, open the Cassandra shell:

 

Type ping to check the connection. If the shell responds with a prompt, your installation is successful.

 

Managing Cassandra

 
With Cassandra running, you can start, stop, or restart it as follows:

sudo systemctl start cassandra

 

sudo systemctl stop cassandra

 

sudo systemctl restart cassandra

 

 

Conclusion

 
In this guide, you learned how to install and configure Apache Cassandra on Linux, Windows, and macOS. You also learned how to start and stop the Cassandra service, connect to it via cqlsh, and test its functionality. Cassandra’s distributed peer-to-peer architecture makes it a robust and scalable solution for managing massive amounts of data.

Its compatibility with different operating system platforms makes it accessible to a wide range of users. Once Cassandra is up and running, you’re ready to explore its rich set of features for managing broadly distributed data.
 
 

Shittu Olumide is a software engineer and technical writer passionate about leveraging cutting-edge technologies to craft compelling narratives, with a keen eye for detail and a knack for simplifying complex concepts. You can also find Shittu on Twitter.





Source link

Leave a comment

0.0/5