Install Cassandra and Run as single-node cluster in Fedora

Apache CassandraApache Cassandra is a NoSQL database intended for storing large amounts of data in a decentralized, highly available cluster. Cassandra database is the right choice when you need scalability and high availability without compromising performance.

Pre-Install Check

  • These instructions are intended for installing Cassandra 3 on a Fedora node (versioned 22+).
  • You may skip to step #2 if you already have a stable version of Java 8. Check to see if your server already has Java installed by running the following command: java -version

Step 1: Install Java
First, you’ll follow a simple best practice: ensuring the list of available packages is up to date before installing anything new.

# dnf -y update

At this point, installing java is as simple as running just one command:

dnf -y install java

Step #2: Add the DataStax Community Repository
To add a repository, we need to setup a config file used by Fedora to retrieve the precompiled package for Cassandra.

vim /etc/yum.repos.d/datastax.repo

Add the following information to the file you’ve created, using i to insert:

[datastax]
name = DataStax Repo for Apache Cassandra
baseurl = http://rpm.datastax.com/community
enabled = 1
gpgcheck = 0

Then exit and save the file with the command :wq.

Step #3: Install Apache Cassandra 3
At this point, installing Cassandra is as simple as running just one command:

# dnf install cassandra30.noarch cassandra30-tools.noarch python3-cassandra-driver.x86_64

Step #4: Get Cassandra Running
Start-Up Cassandra

systemctl start cassandra

Check Cassandra Service Status

systemctl status cassandra

Enable Cassandra to Start at Boot

systemctl enable cassandra

Enter the Cassandra Command Line

cqlsh

The cqlsh interface should look similar to:
Connected to Test Cluster at localhost:9160.
[cqlsh 4.1.1 | Cassandra 2.0.10 | CQL spec 3.1.1 | Thrift protocol 19.39.0]
Use HELP for help.
cqlsh>

Check Cassandra Node Status

nodetool status

If you get an error such as: ‘Failed to connect to ’127.0.0.1:7199′: Connection refused’, you may need to update one default setting for Cassandra,
Open the file /etc/cassandra/default.conf/cassandra-env.sh, and find thess lines,

# add this if you’re having trouble connecting:
# JVM_OPTS=”$JVM_OPTS -Djava.rmi.server.hostname=<public name>”

Uncomment the second line, and add the hostname of your server, or the IP address which you’re connecting to/from. In this case, replacing with 127.0.0.1 resolved the issue.

Restart Cassandra

systemctl restart cassandra

Shutdown Cassandra

service cassandra stop
Share Button

Leave a comment

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