Install Icinga 2 on Centos 8

Enable EPEL Repository

Icinga packages depend on other packages that are distributed in the EPEL repository.

dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

dnf config-manager --set-enabled PowerTools

Add Icinga 2 Repository

Icinga provides Icinga 2 packages from its dedicated repository. So, install the Icinga repository configuration rpm to automatically configure the Icinga repository.

rpm --import https://packages.icinga.com/icinga.key

dnf install -y https://packages.icinga.com/epel/icinga-rpm-release-8-latest.noarch.rpm

Install Icinga 2

After configuring the Icinga repository, install the Icinga 2 with dnf command.

dnf install -y icinga2

To start Icinga2 service, run:

systemctl start icinga2

To enable Icinga 2 service to start automatically on system startup, run:

systemctl enable icinga2

Install Nagios Plugins

Without plugins, Icinga 2 does not know how to monitor application services. So, install Nagios plugins to work with Icinga 2.

dnf install -y nagios-plugins-all

Firewall

Configure the firewall to allow client systems to send data to the Icinga 2 server.

firewall-cmd --permanent --add-port=5665/tcp
firewall-cmd --reload

Configuring DB IDO MySQL

The DB IDO module for Icinga 2 takes care of exporting all configuration and status information to the database.

At present, MySQL and PostgreSQL are supported. Here, we will use the MySQL / MariaDB server as a database server.

Install Database Server

Install the MariaDB server (v10.3) from the OS repository.

dnf install -y mariadb-server mariadb

Start and enable MariaDB service.

systemctl start mariadb
systemctl enable mariadb

Perform the initial setup of MariaDB using the mysql_secure_installation command to setup database root password and other important security measures.

sudo mysql_secure_installation
dnf install -y icinga2-ido-mysql

Create Database for IDO modules

Login to MariaDB using the following command.

mysql -u root -p

Create a database for IDO modules. Please note down the database details as we need this when we set up the Icinga web 2 interface.

CREATE DATABASE icinga2;
grant all privileges on icinga2.* to icinga2@localhost identified by 'icinga';
FLUSH PRIVILEGES;
quit

After creating the database, import the Icinga 2 IDO schema using the following command.

mysql -u root -p icinga2 < /usr/share/icinga2-ido-mysql/schema/mysql.sql

Enable IDO MySQL Module

By default, the IDO MySQL module (ido-mysql) is disabled. Let’s lists the available and enabled modules in Icinga 2.

icinga2 feature list

Output:
Disabled features: api command compatlog debuglog elasticsearch gelf graphite ido-mysql influxdb livestatus opentsdb perfdata statusdata syslog
Enabled features: checker mainlog notification

Enable ido-mysql module using the below command.

icinga2 feature enable ido-mysql

Also, enable the command feature, which helps Icinga web 2 interface or other Icinga add-ons to send commands to Icinga 2 via external command pipe.

icinga2 feature enable command

Restart the Icinga 2 server to have these enabled features take effect

systemctl restart icinga2

Configure IDO DB MySQL module

Once you have enabled the IDO module, the Icinga 2 places the new configuration file /etc/icinga2/features-enabled/ido-mysql.conf.

Edit the file to update the database credentials manually.

nano /etc/icinga2/features-enabled/ido-mysql.conf

Update the above file, as shown below.

user = "icinga2",
password = "icinga",
host = "localhost",
database = "icinga2"

Restart the Icinga 2 server to pickup the database changes

systemctl restart icinga2

Install Apache web server ans Icinga Web 2 on CentOS 8 using the commands:

sudo dnf install httpd icingacli icingaweb2 php-json php-ldap

The dependency packages like PHP and other extensions will be installed from the AppStream repository.

We need to start httpd, service and configure firewalld.

sudo systemctl enable --now httpd
sudo firewall-cmd --add-service={http,https} --permanent
sudo firewall-cmd --reload

Also start PHP-FPM service.

sudo systemctl enable --now php-fpm.service

Run the commands on CLI to start configurations:

sudo icingacli setup config webserver apache

Generate authentication token required for web setup. In order to generate a token use the command:

sudo icingacli setup token create

Starting Web Setup

Finally visit Icinga Web 2 in your browser to access the setup wizard and complete the installation: /icingaweb2/setup.

Leave a Reply