Cassandra NoSQL Database Installation on Unix / Linux

This article describes the process for installing a Cassandra NoSQL database for TestRail Server installations on Unix or Linux servers that use TestRail 7.4 or later.

Prerequisites

In order to install Cassandra database, you have to install some required components:

  1. Open JDK 8
  2. C++ driver
  3. Cassandra driver for TestRail installation operating system

The following steps are an example of an Ubuntu 20.04 installation:

1. Install JDK 8

Install Java version 8 using the following command:

$ apt-get install openjdk-8-jdk -y

 

If you are installing on a RedHat-based distribution, the package is called java-1.8.0-openjdk

Once the installation is completed, verify the installed version of Java with the following command:

$ java -version

The JDK is successfully installed if java -version outputs something like this:

Openjdk version “1.8.0_312”
OpenJDK Runtime Environment (build 1.8.0_312-8u312-b07-0ubuntu1~20.04-b07)
OpenJDK 64-bit Server VM (build 25.312-b07, mixed mode)

2. Install C++ driver

C++ driver is needed for Linux TestRail platforms since the Cassandra driver won’t run without it.

Ubuntu Distribution

Download the multiarch-support package:

$ wget http://archive.ubuntu.com/ubuntu/pool/main/g/glibc/multiarch-support_2.27-3ubuntu1.6_amd64.deb

Install the package.

$ dpkg -i multiarch-support_2.27-3ubuntu1.2_amd64.deb

Now download the C++ driver.

$ wget https://downloads.datastax.com/cpp-driver/ubuntu/18.04/cassandra/v2.16.0/cassandra-cpp-driver_2.16.0-1_amd64.deb

Run this command to install it.

$ dpkg -i cassandra-cpp-driver_2.16.0-1_amd64.deb

RedHat-based Distribution

Download the multiarch-support package.

$ wget https://downloads.datastax.com/cpp-driver/centos/7/dependencies/libuv/v1.35.0/libuv-1.35.0-1.el7.x86_64.rpm

Install the package.

$ rpm -i libuv-1.35.0-1.el7.x86_64.rpm

Now download the C++ driver.

$ wget https://downloads.datastax.com/cpp-driver/centos/7/cassandra/v2.16.0/cassandra-cpp-driver-2.16.0-1.el7.x86_64.rpm

Run this command to install it.

$ rpm -i cassandra-cpp-driver-2.16.0-1.el7.x86_64.rpm

3. Cassandra driver for TestRail

Download the driver for Linux from here.

You can manually download it or Git clone the file to your machine.

$ git clone https://github.com/gurock/CassandraDrivers.git

Move to the drivers directory where the file is.

$ cd Drivers.Cassandra/Linux/7.3

Find the location of the extension_dir folder entering the following command.

$ php -i | grep ^extension_dir

Copy the file cassandra.so to the extension_dir folder.

$ cp cassandra.so /usr/lib64/php/modules/

Enable the extension inside the php.ini by adding the following line to the file.

extension=cassandra.so

You can confirm the extension is available by writing the following command.

$ php -m

Here is a typical phpinfo page that lists all the required php extensions including cassandra.

Install Apache Cassandra

The following steps are an example of an Ubuntu 20.04 installation, if you are installing on a RedHat-based distribution, follow the instructions here.

 

Currently, Cassandra 3.11 is the ONLY supported Cassandra version for Server installations.

Install the required dependencies with the following command:

$ apt-get install apt-transport-https gnupg2 -y

Download and add the GPG key with the following command:

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

Wait for the OK response, it may take a few seconds. Next, add the Cassandra repository to the APT with the following command:

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

Update the repository cache:

$ apt-get update -y

Install Apache Cassandra.

$ apt-get install cassandra -y

Make sure you have a cassandra-lucene-index-plugin-*.jar installed in your Cassandra Home lib directory. (Usually the path is /usr/share/cassandra/lib). This .jar file should have the version number of your Cassandra installation.

If you don’t, you can download the .jar file from the official maven repository.

$ wget https://repo1.maven.org/maven2/com/stratio/cassandra/cassandra-lucene-index-plugin/3.11.3.0/cassandra-lucene-index-plugin-3.11.3.0.jar

Copy the file to the Home lib directory.

$ cp cassandra-lucene-index-plugin-3.11.3.0.jar /usr/share/cassandra/lib

Restart Cassandra.

$ service cassandra restart

Now you are ready to connect to Cassandra for the first time. Type:

cqlsh

You should get the following output:

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

To install TestRail, it is necessary to create a Cassandra keyspace. Create one running the following CQL query:

CREATE KEYSPACE IF NOT EXISTS testrail WITH REPLICATION={'class': 'SimpleStrategy', 'replication_factor': 1};

This installation of Cassandra uses ‘cassandra’ as user and ‘cassandra’ as password. If you want to create a new user, you must edit the cassandra.yaml file on your terminal:

Edit the file by making changes to the authenticator and authorizer directives. Comment the line “authenticator: AllowAllAuthenticator” and add the following line, so it looks like this:

#authenticator: AllowAllAuthenticator
authenticator: org.apache.cassandra.auth.PasswordAuthenticator

Next comment the line authorizer: “AllowAllAuthorizer” and add the following line so it looks like this:

#authorizer: AllowAllAuthorizer
authorizer: org.apache.cassandra.auth.CassandraAuthorizer

Then, restart cassandra.

$ service cassandra restart

Connect to Cassandra using the default user and password.

$ cqlsh -u cassandra -p cassandra

Then, create a Cassandra TestRail user and password.

cassandra@cqlsh> create user 'username' with password 'password';

Grant all privileges to the TestRail user.

cassandra@cqlsh> GRANT ALL ON KEYSPACE testrail to 'testrail';

You can then exit Cassandra.

Was this article helpful?
3 out of 10 found this helpful