INSTALLATION OF CASSANDRA IN UBUNTU

INSTALLATION OF CASSANDRA IN UBUNTU

Cassandra is a NoSQL database management system that is free and open-source. It is made to handle massive volumes of data over multiple commodity servers while also offering high availability and eliminating single points of failure.

Considering its capability to handle volumes and cheap cost, market is slowly moving towards Cassandra

Install apt-transport-https package to access Cassandra repository over secure protocol

root@exhydra:/home/exhydra# apt install apt-transport-https
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  apt-transport-https
0 upgraded, 1 newly installed, 0 to remove and 254 not upgraded.
Need to get 4,348 B of archives.
After this operation, 154 kB of additional disk space will be used.
Get:1 http://in.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 apt-transport-https all 1.6.14 [4,348 B]
Fetched 4,348 B in 1s (3,316 B/s)
Selecting previously unselected package apt-transport-https.
(Reading database ... 148579 files and directories currently installed.)
Preparing to unpack .../apt-transport-https_1.6.14_all.deb ...
Unpacking apt-transport-https (1.6.14) ...
Setting up apt-transport-https (1.6.14) ...

Install curl to fetch the Cassandra package from repository

root@exhydra:/home/exhydra# snap install curl
curl 7.86.0 from Wouter van Bommel (woutervb) installed
root@exhydra-VirtualBox:/home/exhydra# curl https://downloads.apache.org/cassandra/KEYS | sudo apt-key add -
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  267k  100  267k    0     0   205k      0  0:00:01  0:00:01 --:--:--  205k

Update apt utility in Ubuntu

root@exhydra-VirtualBox:/home/exhydra# apt update

Install cassandra using the below package

root@exhydra:/home/exhydra# apt install cassandra
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  ca-certificates-java java-common libopts25 ntp openjdk-8-jre-headless sntp
Suggested packages:
  cassandra-tools default-jre ntp-doc fonts-dejavu-extra fonts-ipafont-gothic fonts-ipafont-mincho fonts-wqy-microhei fonts-wqy-zenhei
The following NEW packages will be installed:
  ca-certificates-java cassandra java-common libopts25 ntp openjdk-8-jre-headless sntp
0 upgraded, 7 newly installed, 0 to remove and 254 not upgraded.
Need to get 76.6 MB of archives.
After this operation, 165 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://in.archive.ubuntu.com/ubuntu bionic/universe amd64 libopts25 amd64 1:5.18.12-4 [58.2 kB]
Get:2 http://in.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 ntp amd64 1:4.2.8p10+dfsg-5ubuntu7.3 [640 kB]
Get:3 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 java-common all 0.68ubuntu1~18.04.1 [14.5 kB]
Get:4 http://in.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 openjdk-8-jre-headless amd64 8u352-ga-1~18.04 [28.3 MB]
Get:6 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 ca-certificates-java all 20180516ubuntu1~18.04.1 [12.2 kB]
Get:7 http://in.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 sntp amd64 1:4.2.8p10+dfsg-5ubuntu7.3 [86.5 kB]
Get:5 https://downloads.apache.org/cassandra/debian 40x/main amd64 cassandra all 4.0.5 [47.5 MB]
Fetched 76.6 MB in 12s (6,527 kB/s)

Start Cassandra service post installation and enable it to start the service automatically after reboot using systemctl utility

root@exhydra:/home/exhydra# systemctl start cassandra
root@exhydra:/home/exhydra# systemctl enable cassandra
cassandra.service is not a native service, redirecting to systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable cassandra
root@exhydra:/home/exhydra# systemctl status cassandra
● cassandra.service - LSB: distributed storage system for structured data
   Loaded: loaded (/etc/init.d/cassandra; generated)
   Active: active (running) since Wed 2022-11-16 22:36:01 IST; 2min 12s ago
     Docs: man:systemd-sysv-generator(8)
    Tasks: 41 (limit: 4915)
   CGroup: /system.slice/cassandra.service
           └─2537 /usr/bin/java -ea -da:net.openhft... -XX:+UseThreadPriorities -XX:+HeapDumpOnOutOfMemoryError -Xss256k -XX:+AlwaysPreTouch -XX:-

Nov 16 22:36:01 exhydra-VirtualBox systemd[1]: Starting LSB: distributed storage system for structured data...
Nov 16 22:36:01 exhydra-VirtualBox systemd[1]: Started LSB: distributed storage system for structured data.

Check the current node status to check the service status

root@exhydra:/home/exhydra# 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  69.08 KiB  16      100.0%            147efa87-4637-470a-a33a-1a237bb7fc35  rack1

Use the command line shell using cqlsh utility

root@exhydra:/home/exhydra# cqlsh
Connected to Test Cluster at 127.0.0.1:9042
[cqlsh 6.0.0 | Cassandra 4.0.5 | CQL spec 3.4.5 | Native protocol v5]
Use HELP for help.
cqlsh> help

Documented shell commands:
===========================
CAPTURE  CLS          COPY  DESCRIBE  EXPAND  LOGIN   SERIAL  SOURCE   UNICODE
CLEAR    CONSISTENCY  DESC  EXIT      HELP    PAGING  SHOW    TRACING

CQL help topics:
================
AGGREGATES               CREATE_KEYSPACE           DROP_TRIGGER      TEXT
ALTER_KEYSPACE           CREATE_MATERIALIZED_VIEW  DROP_TYPE         TIME
ALTER_MATERIALIZED_VIEW  CREATE_ROLE               DROP_USER         TIMESTAMP
ALTER_TABLE              CREATE_TABLE              FUNCTIONS         TRUNCATE
ALTER_TYPE               CREATE_TRIGGER            GRANT             TYPES
ALTER_USER               CREATE_TYPE               INSERT            UPDATE
APPLY                    CREATE_USER               INSERT_JSON       USE
ASCII                    DATE                      INT               UUID
BATCH                    DELETE                    JSON
BEGIN                    DROP_AGGREGATE            KEYWORDS
BLOB                     DROP_COLUMNFAMILY         LIST_PERMISSIONS
BOOLEAN                  DROP_FUNCTION             LIST_ROLES
COUNTER                  DROP_INDEX                LIST_USERS
CREATE_AGGREGATE         DROP_KEYSPACE             PERMISSIONS
CREATE_COLUMNFAMILY      DROP_MATERIALIZED_VIEW    REVOKE
CREATE_FUNCTION          DROP_ROLE                 SELECT
CREATE_INDEX             DROP_TABLE                SELECT_JSON

Check the version and host inside command line

cqlsh> show version;
[cqlsh 6.0.0 | Cassandra 4.0.5 | CQL spec 3.4.5 | Native protocol v5]
cqlsh> show host;
Connected to Test Cluster at 127.0.0.1:9042

Leave a Reply

%d bloggers like this: