Installing Apache Cassandra on CentOS 7

Prerequisites

The user you are logged in as must have sudo privileges to be able to install packages.

Installing Apache Cassandra

The recommended way to install Apache Cassandra on CentOS 7 is by installing the rpm package from the official Apache Cassandra repository.

To install OpenJDK , on your system type:

$ sudo yum install java-1.8.0-openjdk-devel

Verify the Java installation by running the following command which will print the Java version :

$ java -version

Now that Java is installed, the next step is to add the Apache Cassandra repository.

Open your editor of choice and create the following repository file:

$ sudo nano /etc/yum.repos.d/cassandra.repo

Paste the following content into the file:

/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

Once the repository is enabled, install the latest version of Apache Cassandra by typing:

$ sudo yum install cassandra

Start and enable the Cassandra service:

$ sudo systemctl enable cassandra
$ sudo systemctl start cassandra

Verify that Cassandra is running by typing:

$ nodetool status

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.

To interact with Cassandra through CQL (the Cassandra Query Language) you can use a command line utility named cqlsh that is shipped with the Cassandra package.

$ cqlsh