Install Cassandra 4 on Ubuntu 20.04

Upasana | July 27, 2020 | 3 min read | 118 views


Apache Cassandra 4 beta came out just few days ago. In this article we wil explore how to install Cassandra on Ubuntu 20 server.

Prerequisites

  • Ubuntu 18+ with sudo permissions

  • Java 11 or latest version of Java 8

  • Python 3.6+ for cqlsh

Installing the Debian packages

  1. Check you have the correct version of Java installed on your system using below command:

    $ java -version
    
    openjdk version "11.0.8" 2020-07-14
    OpenJDK Runtime Environment (build 11.0.8+10-post-Ubuntu-0ubuntu120.04)
    OpenJDK 64-Bit Server VM (build 11.0.8+10-post-Ubuntu-0ubuntu120.04, mixed mode, sharing)
  2. Add the Apache repository of Cassandra to the file cassandra.sources.list. The latest major version is 4.0 and the corresponding distribution name is 40x (with an “x” as the suffix)

    echo "deb http://downloads.apache.org/cassandra/debian 40x main" | sudo tee -a /etc/apt/sources.list.d/cassandra.sources.list
  3. Add the Apache Cassandra repository keys to the list of trusted keys on the server:

    curl https://downloads.apache.org/cassandra/KEYS | sudo apt-key add -
  4. Update the packages index using below command

    sudo apt-get update
  5. Install Apache Cassandra with APT

    sudo apt-get install cassandra

    This will install cassandra and run it using a new linux user cassandra.

  6. Check Status using nodetool

    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  72.57 KiB  256     ?                 016c0c52-be2f-4f45-9956-be699db50701  rack1
  7. Install location:

    Installation directory
    cd /etc/cassandra
    Check logs
    tail -f /var/log/cassandra/system.log
  8. cqlsh client

    $ cqlsh
    Connected to Test Cluster at 127.0.0.1:9042.
    [cqlsh 5.0.1 | Cassandra 4.0 | CQL spec 3.4.5 | Native protocol v4]
    Use HELP for help.
    cqlsh>

Installing from binary tarball

  1. Check you have the correct version of Java installed on your system using below command:

    $ java -version
    
    openjdk version "11.0.8" 2020-07-14
    OpenJDK Runtime Environment (build 11.0.8+10-post-Ubuntu-0ubuntu120.04)
    OpenJDK 64-Bit Server VM (build 11.0.8+10-post-Ubuntu-0ubuntu120.04, mixed mode, sharing)
  2. Download the latest version of Apache Cassandra

    $ curl -OL http://apachemirror.wuchna.com/cassandra/4.0-beta1/apache-cassandra-4.0-beta1-bin.tar.gz
  3. Extract the tarball

    $ tar xzvf apache-cassandra-4.0-beta1-bin.tar.gz

    The files will be extracted to the apache-cassandra-4.0-beta1 directory. This is the tarball installation location.

  4. Start the server

    $ cd apache-cassandra-4.0-beta1
    $ bin/cassandra

    This will start Cassandra with the default configuration using the authenticated linux user.

  5. Check logs

    $ tail -200f logs/system.log
  6. Check status of Cassandra

    $ bin/nodetool status
  7. Configuration

    Tune memory configuration:

    $ vi conf/jvm-server.options
    conf/jvm-server.options
    # It is recommended to set min (-Xms) and max (-Xmx) heap sizes to
    # the same value to avoid stop-the-world GC pauses during resize, and
    # so that we can lock the heap in memory on startup to prevent any
    # of it from being swapped out.
    -Xms1G
    -Xmx1G

    Uncomment and modify Xms and Xmx to appropriate value.


Top articles in this category:
  1. Install ElasticSearch 7 on Ubuntu 20.04
  2. Install & configure Redis on Ubuntu
  3. Upgrade Jenkins on Ubuntu 18.04 LTS
  4. Install OpenJDK 11 on Ubuntu 18.04 LTS
  5. Install RabbitMQ and Erlang 23 on Ubuntu 20
  6. MySql 8 installation on Ubuntu 20
  7. Upgrade MySQL from 5.7 to 8 on Ubuntu 18.04

Recommended books for interview preparation:

Find more on this topic:
Buy interview books

Java & Microservices interview refresher for experienced developers.