Installing Monit

Getting Started

Before installing SQream with Monit, verify that you have followed the required recommended pre-installation configurations.

The procedures in the Installing Monit guide must be performed on each SQream cluster node.

Overview

Monit is a free open source supervision utility for managing and monitoring Unix and Linux. Monit lets you view system status directly from the command line or from a native HTTP web server. Monit can be used to conduct automatic maintenance and repair, such as executing meaningful causal actions in error situations.

SQream uses Monit as a watchdog utility, but you can use any other utility that provides the same or similar functionality.

The Installing Monit procedures describes how to install, configure, and start Monit.

You can install Monit in one of the following ways:

Installing Monit on CentOS:

To install Monit on CentOS:

  1. Install Monit as a superuser on CentOS:

    $ sudo yum install monit
    

Installing Monit on CentOS Offline:

Installing Monit on CentOS offline can be done in either of the following ways:

Building Monit from Source Code

To build Monit from source code:

  1. Copy the Monit package for the current version:

    $ tar zxvf monit-<x.y.z>.tar.gz
    

The value x.y.z denotes the version numbers.

  1. Navigate to the directory where you want to store the package:

    $ cd monit-x.y.z
    
  2. Configure the files in the package:

    $ ./configure (use ./configure --help to view available options)
    
  3. Build and install the package:

    $ make && make install
    

The following are the default storage directories:

  • The Monit package: /usr/local/bin/

  • The monit.1 man-file: /usr/local/man/man1/

  1. Optional - To change the above default location(s), use the –prefix option to ./configure.

  1. Optional - Create an RPM package for CentOS directly from the source code:

    $ rpmbuild -tb monit-x.y.z.tar.gz
    

Building Monit from Pre-Built Binaries

To build Monit from pre-built binaries:

  1. Copy the Monit package for the current version:

    $ tar zxvf monit-x.y.z-linux-x64.tar.gz
    

    The value x.y.z denotes the version numbers.

  2. Navigate to the directory where you want to store the package:

  3. Copy the bin/monit and /usr/local/bin/ directories:

    $ cp bin/monit /usr/local/bin/
    
  4. Copy the conf/monitrc and /etc/ directories:

    $ cp conf/monitrc /etc/
    

For examples of pre-built Monit binarties, see Download Precompiled Binaries.

Back to top

Installing Monit on Ubuntu:

To install Monit on Ubuntu:

  1. Install Monit as a superuser on Ubuntu:

    $ sudo apt-get install monit
    

Back to top

Installing Monit on Ubuntu Offline:

You can install Monit on Ubuntu when you do not have an internet connection.

To install Monit on Ubuntu offline:

  1. Compress the required file:

    $ tar zxvf monit-<x.y.z>-linux-x64.tar.gz
    

    NOTICE: <x.y.z> denotes the version number.

  2. Navigate to the directory where you want to save the file:

    $ cd monit-x.y.z
    
  3. Copy the bin/monit directory into the /usr/local/bin/ directory:

    $ cp bin/monit /usr/local/bin/
    
  4. Copy the conf/monitrc directory into the /etc/ directory:

    $ cp conf/monitrc /etc/
    

Back to top

Configuring Monit

When the installation is complete, you can configure Monit. You configure Monit by modifying the Monit configuration file, called monitrc. This file contains blocks for each service that you want to monitor.

The following is an example of a service block:

$ #SQREAM1-START
$ check process sqream1 with pidfile /var/run/sqream1.pid
$ start program = "/usr/bin/systemctl start sqream1"
$ stop program = "/usr/bin/systemctl stop sqream1"
$ #SQREAM1-END

For example, if you have 16 services, you can configure this block by copying the entire block 15 times and modifying all service names as required, as shown below:

$ #SQREAM2-START
$ check process sqream2 with pidfile /var/run/sqream2.pid
$ start program = "/usr/bin/systemctl start sqream2"
$ stop program = "/usr/bin/systemctl stop sqream2"
$ #SQREAM2-END

For servers that don’t run the metadataserver and serverpicker commands, you can use the block example above, but comment out the related commands, as shown below:

$ #METADATASERVER-START
$ #check process metadataserver with pidfile /var/run/metadataserver.pid
$ #start program = "/usr/bin/systemctl start metadataserver"
$ #stop program = "/usr/bin/systemctl stop metadataserver"
$ #METADATASERVER-END

To configure Monit:

  1. Copy the required block for each required service.

  2. Modify all service names in the block.

  3. Copy the configured monitrc file to the /etc/monit.d/ directory:

    $ cp monitrc /etc/monit.d/
    
  4. Set file permissions to 600 (full read and write access):

    $ sudo chmod 600 /etc/monit.d/monitrc
    
  5. Reload the system to activate the current configurations:

    $ sudo systemctl daemon-reload
    
  6. Optional - Navigate to the /etc/sqream directory and create a symbolic link to the monitrc file:

    $ cd /etc/sqream
    $ sudo ln -s /etc/monit.d/monitrc monitrc
    

Starting Monit

After configuring Monit, you can start it.

To start Monit:

  1. Start Monit as a super user:

    $ sudo systemctl start monit
    
  2. View Monit’s service status:

    $ sudo systemctl status monit
    
  3. If Monit is functioning correctly, enable the Monit service to start on boot:

    $ sudo systemctl enable monit