Tuesday, August 29, 2023

Cassandra: Installing Cassandra on Linux (Centos and Ubuntu)

Quick guide to install Cassandra on linux. This guide will demonstrate the installation of Cassandra on both Centos and Ubuntu. Ubuntu version is at the lower part of the guide.

 

3 types of installation

  • Through linux installation packages (rpm/yum)
  • Through tarball
  • Through container (kubernetes/docker)

Note: This guide will focus on cassandra installation from package management.

Installation

Installing cassandra8 on Centos8 

Verify Centos version

cat /etc/redhat-release
CentOS Stream release 8

Update the OS

sudo yum update
<restart the system>


Install Java as requirement for Cassandra

sudo dnf install java-1.8.0-openjdk-devel -y


Verify Java version

openjdk version "1.8.0_362"
OpenJDK Runtime Environment (build 1.8.0_362-b08)
OpenJDK 64-Bit Server VM (build 25.362-b08, mixed mode)


Install cassandra

Download Datastax community edition

Instructions

OR

and easier way to do it with package manager.
sudo vi  /etc/yum.repos.d/cassandra.repo

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

sudo dnf install cassandra -y

sudo vi /etc/systemd/system/cassandra.service
[Unit]
Description=Apache Cassandra
After=network.target

[Service]
PIDFile=/var/run/cassandra/cassandra.pid
User=cassandra
Group=cassandra
ExecStart=/usr/sbin/cassandra -f -p /var/run/cassandra/cassandra.pid
Restart=always

[Install]
WantedBy=multi-user.target

start and enable cassandara
sudo systemctl daemon-reload
sudo systemctl start cassandra
sudo systemctl enable cassandra


Check status

[cassandra@localhost ~]$ nodetool status
Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
--  Address    Load       Tokens       Owns (effective)  Host ID                               Rack
UN  127.0.0.1  70.87 KiB  256          100.0%            aba0f684-9f2f-42ce-8032-0cea75541e5d  rack1



Requirement for cqlsh: Install python 2
sudo dnf install python2
sudo alternatives --set python /usr/bin/python2

Now, “clash” is accessible. 

Check version
cqlsh> show version
[cqlsh 5.0.1 | Cassandra 3.11.13 | CQL spec 3.4.4 | Native protocol v4]

cqlsh> select cql_version from system.local;
 cql_version
-------------
       3.4.4

(1 rows)

Nodestool
[cassandra@localhost ~]$ nodetool version;
ReleaseVersion: 3.11.13


Path and directories

cassandra.yaml is at /etc/cassandra/default.conf/cassandra.yaml
data directory - /var/lib/cassandra
log directory - /var/log/cassandra



Installing Cassandra8 on Ubuntu

This installation will be slightly simpler than rpm's. Installation on Macbook M1.

lsb_release -a
No LSB modules are available.
Distributor ID:  Ubuntu
Description:     Ubuntu 22.04.3 LTS
Release:    22.04
Codename:   jammy


echo "deb https://debian.cassandra.apache.org 41x main" | sudo tee -a /etc/apt/sources.list.d/cassandra.sources.list

curl https://downloads.apache.org/cassandra/KEYS | sudo apt-key add 

sudo apt-get update

sudo apt-get install cassandra

Some additional Nodetool (e.g sstabledump) will need to be installed separately for Ubuntu version
 
sudo apt-get install cassandra-tools
[sudo] password for cassandra: 
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
  cassandra-tools
0 upgraded, 1 newly installed, 0 to remove and 13 not upgraded.
Need to get 4,920 B of archives.
After this operation, 27.6 kB of additional disk space will be used.
Get:1 https://apache.jfrog.io/artifactory/cassandra-deb 41x/main arm64 cassandra-tools all 4.1.3 [4,920 B]
Fetched 4,920 B in 2s (2,652 B/s)                 
Selecting previously unselected package cassandra-tools.
(Reading database ... 115981 files and directories currently installed.)
Preparing to unpack .../cassandra-tools_4.1.3_all.deb ...
Unpacking cassandra-tools (4.1.3) ...
Setting up cassandra-tools (4.1.3) ...
Scanning processes...                                                                                                                              
Scanning linux images...                                                                                                                     
 
No services need to be restarted.
 
No containers need to be restarted.
 
No user sessions are running outdated binaries.
 
No VM guests are running outdated hypervisor (qemu) binaries on this host.
 

Ubuntu Cassandra.yaml path is located in /etc/cassandra

No comments:

Post a Comment