Sunday, January 21, 2018

How to Install Cassandra Distributed Database on CentOS 7

Cassandra is a free and open source distributed database management system that can be used to handle large amounts of data across many servers. It is reliable, clusterable and specialy designed to handle very large amounts of structured data. Cassandra also supports replication and multi-data center replication for redundancy, failover, and disaster recovery.
In this tutorial, we will learn how to install and configure Cassandra on CentOS 7.


  • A server running CentOS 7.
  • A non-root user with sudo privileges setup on your server.

Getting Started

Before starting, update your system with the latest version with the following command:
sudo yum update -y
Cassandra is written in Java, so you will need to install Java to your system. You can install Java by just running the following command:
sudo yum install java -y
After installing Java, you can verify the version of the Java with the following command:
sudo java -version
You should see the Java version in the following output:
openjdk version "1.8.0_151"
OpenJDK Runtime Environment (build 1.8.0_151-b12)
OpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode)

Install Cassandra

By default, Cassandra is not available in CentOS 7 default repository. So you will need to add the official Apache Software Foundation repositories to your system. You can do this by creating cassandra.repo file inside /etc/yum.repos.d directory:
sudo nano /etc/yum.repos.d/cassandra.repo
Add the following line:
name = DataStax Repo for Apache Cassandra
baseurl =
enabled = 1
gpgcheck = 0
Save and close the file when you are finished, then update the repository with the following command:
sudo yum update -y
Next, install Cassandra using the following command:
sudo yum install dsc20 -y
After installing Cassandra, start the Cassandra service and enable it to start on boot time with the following command:
sudo systemctl start cassandra
sudo systemctl enable cassandra
You can also check the status of the Cassandra service using the following command:
sudo systemctl status cassandra
If everything is fine, you should see the following output:
? cassandra.service - SYSV: Starts and stops Cassandra
   Loaded: loaded (/etc/rc.d/init.d/cassandra; bad; vendor preset: disabled)
   Active: active (exited) since Sun 2017-12-17 17:53:58 IST; 12s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 15323 ExecStart=/etc/rc.d/init.d/cassandra start (code=exited, status=0/SUCCESS)

Dec 17 17:53:55 centOS-7 systemd[1]: Starting SYSV: Starts and stops Cassandra...
Dec 17 17:53:56 centOS-7 su[15332]: (to cassandra) root on none
Dec 17 17:53:58 centOS-7 cassandra[15323]: Starting Cassandra: OK
Dec 17 17:53:58 centOS-7 systemd[1]: Started SYSV: Starts and stops Cassandra.

Connect and Check Cassandra Cluster

Cassandra is now up and running. It's time to verify and connect Cassandra Cluster.
You can verify the Cassandra Cluster status with the following command:
sudo nodetool status
If everything is fine, you should see the following output:
Datacenter: datacenter1
|/ State=Normal/Leaving/Joining/Moving
--  Address    Load       Tokens  Owns (effective)  Host ID                               Rack
UN  65.15 KB   256     100.0%            516af85e-2e6a-454a-b27f-6eacafa6b978  rack1
Next, connect the Cassandra Cluster using the cqlsh command as shown below:
You should see the following output:
Connected to Test Cluster at localhost:9160.
[cqlsh 4.1.1 | Cassandra 2.0.17 | CQL spec 3.1.1 | Thrift protocol 19.39.0]
Use HELP for help.
Next, exit from the Cassandra command line interface with the following command:
cqlsh> exit

Monitoring Your PiCluster with Elasticsearch and Kibana

PiCluster is a simple way to manage Docker containers on multiple hosts. It will work on x86 or ARM CPU architectures that can run Docker and Node.js. PiCluster 2.3 will be out soon and I wanted to share the exciting new Elasticsearch integration currently in the dev branch.  Traditionally, PiCluster had the ability to store its log output in Elasticsearch. Starting in PiCluster 2.3, node metrics such as disk, cpu, and memory utilization is stored also. With this ability, users can easily view their host metrics over time.


  • PiCluster
  • Elasticsearch 6+
  • Kibana 6+


If you want to quickly spin up an Elasticsearch cluster with Kibana in Docker,  check this out.

PiCluster Configuration

PiCluster needs to be configured for Elasticsearch so it knows where to send data. All you need to do is add the following config option in config.json that points to your Elasticsearch endpoint and restart the PiCluster server process:
"elasticsearch": "http://my-es-endpoint:9200"

Kibana Configuration

Starting in PiCluster 2.3, there are pre-set graphs available for viewing host metrics (cpu, memory, and disk).

Creating the Index Pattern

  1. Click on Management -> Index Patterns.
  2. Click  Create Index.
  3. Under Index Pattern, type  picluster-monitoring
  4. Click  Next Step
  5. Under  Time Filter field name, choose date.
  6. Click  Create.
  7. Repeat steps 1-6 for the  picluster-logging Index Pattern.

Importing the Graphs

To import the PiCluster Monitoring graphs in Kibana:
    1. Click on Management -> Saved Objects.
    2. Click import.
    3. Navigate to the PiCluster Git directory and choose kibana-graphs.json
    4. Click open.
    5. Repeat steps 1-4 for kibana-dashboard.json

Viewing the Dashboard

  1. Click on Dashboard
  2. Choose PiCluster Monitoring

Viewing the Graphs

  1. Click on  Visualize.
  2. Choose CPU, Disk, or Memory.

Viewing the PiCluster Logs

1. Click on  Discover.
2. Change the index to  picluster-logging

Feel like trying it out? Check out our dev branch to start playing with it now or wait for it to hit our main branch! To learn more about how PiCluster works, Check out our Wiki page.

How To Manage Vim Plugins Using Vundle On Linux

Manage Vim Plugins Using Vundle
Vim, undoubtedly, is one of the powerful and versatile tool to manipulate text files,  manage the system configuration files and writing code. The functionality of Vim can be extended to different levels using plugins. Usually, all plugins and additional configuration files will be stored in ~/.vim directory. Since all plugin files are stored in a single directory, the files from different plugins are mixed up together as you install more plugins. Hence, it is going to be a daunting task to track and manage all of them. This is where Vundle comes in help. Vundle, acronym of Vim Bundle, is an extremely useful plug-in to manage Vim plugins.
Vundle creates a separate directory tree for each plugin you install and stores the additional configuration files in the respective plugin directory. Therefore, there is no mix up files with one another. In a nutshell, Vundle allows you to install new plugins, configure existing plugins, update configured plugins, search for installed plugins and clean up unused plugins. All actions can be done in a single keypress with interactive mode. In this brief tutorial, let me show you how to install Vundle and how to manage Vim plugins using Vundle in GNU/Linux.

Installing Vundle

If you need Vundle, I assume you have already installed vim on your system. If not, install vim and git (to download vundle). Both packages are available in the official repositories of most GNU/Linux distributions.For instance, you can use the following command to install these packages on Debian based systems.
sudo apt-get install vim git
Download Vundle
Clone Vundle GitHub repository:
git clone ~/.vim/bundle/Vundle.vim
Configure Vundle
To tell vim to use the new plugin manager, we need to create ~/.vimrc file. This file is required to install, update, configure and remove plugins.
vim ~/.vimrc
Put the following lines on the top of this file:
set nocompatible              " be iMproved, required
filetype off                  " required

" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')

" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'

" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
" plugin on GitHub repo
Plugin 'tpope/vim-fugitive'
" plugin from
" Plugin 'L9'
" Git plugin not hosted on GitHub
Plugin 'git://'
" git repos on your local machine (i.e. when working on your own plugin)
Plugin 'file:///home/gmarik/path/to/plugin'
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" Install L9 and avoid a Naming conflict if you've already installed a
" different version somewhere else.
" Plugin 'ascenator/L9', {'name': 'newL9'}

" All of your Plugins must be added before the following line
call vundle#end()            " required
filetype plugin indent on    " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
" Brief help
" :PluginList       - lists configured plugins
" :PluginInstall    - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean      - confirms removal of unused plugins; append `!` to auto-approve removal
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
The lines which are marked as “required” are Vundle’s requirement. The rest of the lines are just examples. You can remove those lines if you don’t want to install that specified plugins. Once you finished, type :wq to save and close file.
Finally, open vim:
And type the following to install the plugins.

A new split window will open and all the plugins which we added in the .vimrc file will be installed automatically.

When the installation is completed, you can delete the buffer cache and close the split window by typing the following command:
You can also install the plugins without opening vim using the following command from the Terminal:
vim +PluginInstall +qall
For those using the fish shell, add the following line to your .vimrc file.
set shell=/bin/bash

Manage Vim Plugins Using Vundle

Add New Plugins
First, search for the available plugins using command:
To refresh the local list from the from the vimscripts site, add “!” at the end.
A new split window will open list all available plugins.

You can also narrow down your search by using directly specifying the name of the plugin like below.
:PluginSearch vim
This will list the plugin(s) that contains the words “vim”
You can, of course, specify the exact plugin name like below.
:PluginSearch vim-dasm
To install a plugin, move the cursor to the correct line and hit “i”. Now, the selected plugin will be installed.

Similarly, install all plugins you wanted to have in your system. Once installed, delete the Vundle buffer cache using command:
Now the plugin is installed. To make it autoload correctly, we need to add the installed plugin name to .vimrc file.
To do so, type:
:e ~/.vimrc
Add the following line.
Plugin 'vim-dasm'
Replace vim-dasm with your plugin name. Then, hit ESC key and type :wq to save the changes and close the file.
Please note that all of your Plugins must be added before the following line in your .vimrc file.
filetype plugin indent on
List installed Plugins
To list installed plugins, type the following from the vim editor:

Update plugins
To update the all installed plugins, type:
To reinstall all plugins, type:
Uninstall plugins
First, list out all installed plugins:
Then place the cursor to the correct line, and press “SHITF+d”.

Then, edit your .vimrc file:
:e ~/.vimrc
And delete the Plugin entry. Finally, type :wq to save the changes and exit from vim editor.
Alternatively, you can uninstall a plugin by removing its line from .vimrc file and run:
This command will remove all plugins which are no longer present in your .vimrc but still present the bundle directory.
At this point, you should have learned the basic usage about managing plugins using Vundle. For details, refer the help section by typing the following in your vim editor.
:h vundle

Also Read:

And, that’s all for now. I will be soon here with another useful guide. Until then, stay tuned with OSTechNix!