How to Install Apache Cassandra on Debian 10 Linux

[ad_1]

Apache Cassandra is a free and open-source NoSQL database with no single point of failure. It provides linear scalability and high availability without compromising performance. Apache Cassandra is used by a number of companies that have large, active data sets, including Reddit, NetFlix, Instagram, and Github.

In this article, we will explain how to install Apache Cassandra on Debian 10, Buster.

Prerequisites #

The instructions assume that you are logged in as root or user with sudo privileges
.

Installing Java #

At the time of writing this article, the latest stable version of Apache Cassandra is 3.11 and requires OpenJDK 8, which is not available in the official Debian Buster repositories.

We’ll enable the AdoptOpenJDK
repository and install the prebuilt OpenJDK 8
package.

Update the packages list and install the dependencies necessary to add a new repository
over HTTPS:

sudo apt updatesudo apt install apt-transport-https ca-certificates wget dirmngr gnupg software-properties-common

Import the repository’s GPG key and add the AdoptOpenJDK APT repository to your system:

wget -qO - https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public | sudo apt-key add -sudo add-apt-repository --yes https://adoptopenjdk.jfrog.io/adoptopenjdk/deb/

Install Java 8 by running the following commands:

sudo apt updatesudo apt install adoptopenjdk-8-hotspot

Once completed, verify it by printing the Java version
:

java -version

The output should look something like this:

openjdk version "1.8.0_232"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_232-b09)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.232-b09, mixed mode)

Installing Apache Cassandra #

We’ll install Apache Cassandra using the deb package from the vendor repository. To do so we, need to enable the Apache Cassandra repository.

Import the repository’s public key using the following wget
command:

wget -q -O - https://www.apache.org/dist/cassandra/KEYS | sudo apt-key add -

The command above should output OK. That means that the key has been successfully imported, and packages from this repository will be considered trusted.

Add the Cassandra repository to your system sources’ list by running the command below:

sudo sh -c 'echo "deb https://www.apache.org/dist/cassandra/debian 311x main" > /etc/apt/sources.list.d/cassandra.list'

Update the packages’ index and install the Apache Cassandra package:

sudo apt updatesudo apt install cassandra

When the installation process is complete the Cassandra service will automatically start. To verify that Cassandra is running, type:

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  103.71 KiB  256          100.0%            dd8f6709-08ef-45b8-881e-5c1b5bbfc7f7  rack1

That’s it. Apache Cassandra has been successfully installed.

Configuring Apache Cassandra #

Apache Cassandra data is stored in the /var/lib/cassandra directory. Configuration files are located in /etc/cassandra, and Java start-up options can be configured in the /etc/default/cassandra file.

By default, Cassandra listens on the localhost only. If the client connecting to the database is also running on the same machine, you don’t need to change the binding interface.

To interact with Cassandra through the command line, use the cqlsh tool, which is shipped with the Cassandra package.

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

Renaming Apache Cassandra Cluster #

By default, the Cassandra cluster is named “Test Cluster”. If you want to change it follow the steps below:

  1. Login to the Cassandra CQL terminal with cqlsh:

    cqlsh
  2. Issue the following command to change the cluster name to “Linuxize Cluster”:

    UPDATE system.local SET cluster_name = 'Linuxize Cluster' WHERE KEY = 'local';
    

    Change “Linuxize Cluster” with your desired name. Once done, type exit to exit the terminal.

  3. Edit the cassandra.yaml configuration file and put your new cluster name:

    /etc/cassandra/cassandra.yaml

    cluster_name: 'Linuxize Cluster'
    
  4. Clear the system cache:

    nodetool flush system
  5. Restart the Cassandra service by running:

    sudo systemctl restart cassandra

Conclusion #

We’ve shown you how to install Apache Cassandra Debian 10 and optionally rename the default cluster. For more information about how to get started with Cassandra, visit the official Documentation
page.

If you hit a problem or have feedback, leave a comment below.

[ad_2]

Source link

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.