Install Cassandra Web on CentOS / RHEL 8 - CentLinux

Latest

Wednesday, 5 August 2020

Install Cassandra Web on CentOS / RHEL 8

Install Cassandra Web Interface on CentOS / RHEL 8

In this article, you will learn how to install Cassandra Web on CentOS / RHEL 8.

 

Table of Contents:

 

What is Cassandra Web? :

Cassandra Web is a web interface to Apache Cassandra with AngularJS and server-sent events. Cassandra Web is free and open source and its source is available at GitHub.

Cassandra Web is very simple application with limited features, but it fulfills the purpose of monitoring of complete Apache Cassandra cluster via a single web interface.

 

Environment Specification:

Although it is not necessary to install Cassandra Web on a Apache Cassandra node. But for the sake of simplicity, we are installing the Cassandra Web on the same machine, on which you have installed Apache Cassandra.

 

Installing Ruby on CentOS / RHEL 8:

You are required Rubygems package manager to install Cassandra Web on Linux. Therefore, install the Ruby on CentOS / RHEL 8 with related packages by using dnf command.

# dnf install -y rubygems ruby-devel

 

Install Prerequisite Packages:

To install Cassandra Web by using rubygems, you need the make and compilation packages. You can install all the required packages by using a single dnf command.

# dnf install -y make gcc gcc-c++ redhat-rpm-config

 

Install Cassandra Web on CentOS / RHEL 8:

Now, you are ready to install Cassandra Web interface. You can execute the following gem command to install it on our Linux server.

# gem install cassandra-web
Building native extensions. This could take a while...
Successfully installed eventmachine-1.2.7
Fetching: thin-1.7.2.gem (100%)
Building native extensions. This could take a while...
Successfully installed thin-1.7.2
Fetching: ione-1.2.4.gem (100%)
Successfully installed ione-1.2.4
Fetching: cassandra-driver-3.2.4.gem (100%)
Building native extensions. This could take a while...
Successfully installed cassandra-driver-3.2.4
Fetching: cassandra-web-0.5.0.gem (100%)
Successfully installed cassandra-web-0.5.0
5 gems installed

Ruby Bundler gem is also required by the web user interface. Install it by executing gem command.

# gem install bundler
Fetching: bundler-2.1.4.gem (100%)
Successfully installed bundler-2.1.4
1 gem installed

 

Configure Linux Firewall:

Cassandra Web interface runs at default port 3000/tcp. Therefore, you have to allow incoming traffic through this port in Linux firewall.

# firewall-cmd --permanent --add-port=3000/tcp
success
# firewall-cmd --reload
success

 

Create a Database User:

To access the Apache Cassandra nodes, Web interface requires an Admin user.

Create a database user for this purpose as follows.

# cqlsh -u ahmer -p Ahmer@1234
Connected to Test Cluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 3.11.7 | CQL spec 3.4.4 | Native protocol v4]
Use HELP for help.
ahmer@cqlsh> CREATE ROLE cassweb WITH PASSWORD = 'Cassweb@1234' AND SUPERUSER = true AND LOGIN = true;
ahmer@cqlsh> exit

 

Starting the Cassandra Web Interface:

Start the Cassandra Web interface by using the following command syntax.

If you have running the Apache Cassandra database on another node then you have to change the hosts address from the following command according to your environment.

# cassandra-web --hosts '127.0.0.1' --port '9042' --username 'cassweb' --password 'Cassweb@1234'
I, [2020-08-01T13:14:42.011519 #52137]  INFO -- : Establishing control connection
I, [2020-08-01T13:14:42.131120 #52137]  INFO -- : Refreshing connected host's metadata
I, [2020-08-01T13:14:42.171751 #52137]  INFO -- : Completed refreshing connected host's metadata
I, [2020-08-01T13:14:42.173263 #52137]  INFO -- : Refreshing peers metadata
I, [2020-08-01T13:14:42.176922 #52137]  INFO -- : Completed refreshing peers metadata
I, [2020-08-01T13:14:42.177016 #52137]  INFO -- : Refreshing schema
I, [2020-08-01T13:14:42.284935 #52137]  INFO -- : Schema refreshed
I, [2020-08-01T13:14:42.285016 #52137]  INFO -- : Control connection established
I, [2020-08-01T13:14:42.285665 #52137]  INFO -- : Creating session
I, [2020-08-01T13:14:42.556420 #52137]  INFO -- : Session created
Thin web server (v1.7.2 codename Bachmanity)
Maximum connections set to 1024
Listening on 0.0.0.0:3000, CTRL+C to stop

Open URL http://cassandra-01.centlinux.com:3000 in a web browser e.g Google Chrome.

01-install-cassandra-web-interface-on-centos-8-cluster-status

Cassandra Web does not provide any user authentication. However, you can configure HTTP basic authentication to control access to Cassandra Web interface.

Click on system_schema.

02-install-cassandra-web-interface-on-centos-8-keyspace

Cassandra Web interface is working fine.

 

Create a Systemd Service:

To automate startup of Cassandra Web application, you can create a simple Systemd service.

Create a Systemd service file for Cassandra Web by using vim text editor.

# vi /usr/lib/systemd/system/cassweb.service

Add following lines of code therein.

[Unit]
Description=Cassandra Web

[Service]
Type=simple
ExecStart=cassandra-web --hosts '127.0.0.1' --port '9042' --username 'cassweb' --password 'Cassweb@1234'

[Install]
WantedBy=multi-user.target

Enable and start Cassandra Web Service.

# systemctl enable --now cassweb.service
Created symlink /etc/systemd/system/multi-user.target.wants/cassweb.service รข /usr/lib/systemd/system/cassweb.service.

Cassandra Web service has been started.

 

Conclusion:

Our Cassandra Web has been installed on CentOS / RHEL 8. Cassandra: The Definitive Guide: Distributed Data at Web Scale 2nd Edition by Jeff Carpenter is a very good book and we strongly recommend that you should read it.

No comments:

Post a Comment