MYHOSPITALNOW.COM

Find Trusted Doctors & Hospitals

Discover healthcare providers, compare hospitals, and explore treatment options worldwide.

Free Treatment Quotes • Doctor Search • Hospital Comparison

Find Healthcare Options

www.myhospitalnow.com

Icinga Install and Configuration

This guide shows how to set up Icinga 2 with a MariaDB backend on Ubuntu. It covers preparing MariaDB, resetting a lost root password on a system install or a XAMPP install, writing a working client configuration, and installing Icinga 2, Icinga DB and Icinga Web 2. It fills in the headings above that have no content and fixes the problems in the .my.cnf example.

Xampp installation

MySql Root Password Reset

Ensure Correct Client Configuration

Make sure that your MySQL client is configured to connect to the MariaDB server. This involves specifying the host, port, user, and password that the MariaDB server uses. These configurations can be set in the MySQL client configuration file (typically .my.cnf in your home directory) as follows:


[client]
host = 127.0.0.1
user = root
password = your_password
port = 3306  # default MariaDB/MySQL port
Code language: PHP (php)


What the Icinga stack needs and where XAMPP fits

A current Icinga installation has several parts. Icinga 2 runs the checks. Icinga DB moves the monitoring state into a SQL database. Icinga Web 2 is the PHP web interface. MariaDB holds both the Icinga DB data and the Icinga Web 2 configuration database.

ComponentPackage (Ubuntu)Role
Icinga 2icinga2, monitoring-pluginsMonitoring daemon that runs checks and the REST API
Icinga DB Redisicingadb-redisFast state cache, listens on port 6380
Icinga DBicingadbWrites state from Redis into MariaDB or MySQL
Icinga Web 2icingaweb2, icingadb-web, icingacliWeb UI served by Apache and PHP
MariaDBmariadb-serverDatabases icingadb and icingaweb2

Note: XAMPP is a bundle for local development. It ships its own Apache, PHP and MariaDB under /opt/lampp. The Icinga packages expect the distribution's Apache, PHP and MariaDB, so running XAMPP next to them causes port clashes on 80 and 3306. On an Icinga server, use the distribution packages and keep XAMPP to desktops or labs.

Install and prepare MariaDB

sudo apt update
sudo apt install -y mariadb-server mariadb-client
sudo systemctl enable --now mariadb
sudo mariadb-secure-installation

On Ubuntu, root@localhost logs in with the unix_socket plugin by default. This means sudo mariadb gets you in with no password. Many "forgotten root password" cases are solved simply by running sudo mariadb. Use it to create separate databases and users for Icinga, and never connect Icinga as root:

sudo mariadb <<'SQL'
CREATE DATABASE icingadb;
CREATE USER 'icingadb'@'localhost' IDENTIFIED BY 'ChangeMe_DB1';
GRANT ALL ON icingadb.* TO 'icingadb'@'localhost';

CREATE DATABASE icingaweb2;
CREATE USER 'icingaweb2'@'localhost' IDENTIFIED BY 'ChangeMe_Web1';
GRANT ALL ON icingaweb2.* TO 'icingaweb2'@'localhost';
FLUSH PRIVILEGES;
SQLCode language: JavaScript (javascript)

Reset the MariaDB root password

Use this only when sudo mariadb does not work, for example because root was switched to password-only login and the password is lost. The server restarts with no permission checks and no network access, so nobody else can connect while it is open.

  1. Stop the service: sudo systemctl stop mariadb
  2. Create the socket directory if it is missing: sudo mkdir -p /run/mysqld && sudo chown mysql:mysql /run/mysqld
  3. Start without grant tables: sudo mysqld_safe --skip-grant-tables --skip-networking &
  4. Connect with mariadb -u root, then run the SQL below.
  5. Stop the temporary server with sudo mysqladmin shutdown, then run sudo systemctl start mariadb.
FLUSH PRIVILEGES;
ALTER USER 'root'@'localhost'
  IDENTIFIED VIA mysql_native_password USING PASSWORD('NewStrongPassword')
  OR unix_socket;Code language: JavaScript (javascript)

The first FLUSH PRIVILEGES loads the grant tables again so that ALTER USER is allowed. The OR unix_socket clause keeps sudo mariadb working as well as the new password.

XAMPP on Linux: the root account has no password after a fresh install. Run sudo /opt/lampp/lampp security to set passwords for MariaDB, phpMyAdmin and the XAMPP pages. To reset a lost password, stop the database with sudo /opt/lampp/lampp stopmysql and add skip-grant-tables under [mysqld] in /opt/lampp/etc/my.cnf. Then start it with startmysql, connect with /opt/lampp/bin/mysql -u root, run the same SQL with only the mysql_native_password part, remove the option and restart.

Corrected client configuration

The .my.cnf example above has two problems. host = 127.0.0.1 forces a TCP connection, while the Ubuntu default for root is socket authentication. As a result the file fails with ERROR 1698 or ERROR 1045 even when the password is right. The file also puts the root password in plain text with no protection. The version below uses a dedicated account and locks down the file permissions:

# ~/.my.cnf  (read by the mysql and mariadb clients)
[client]
user     = icingadb
password = ChangeMe_DB1
# 'localhost' uses the Unix socket; use 127.0.0.1 only when you need TCP
host     = localhost
socket   = /run/mysqld/mysqld.sock
# For XAMPP use: socket = /opt/lampp/var/mysql/mysql.sockCode language: PHP (php)
chmod 600 ~/.my.cnf
mariadb -e "SELECT CURRENT_USER();"Code language: PHP (php)

Expected output is a single row showing icingadb@localhost. The client ignores the file if it is world-writable, so chmod 600 is required, not just good practice.

Install Icinga 2 and Icinga DB

Add the official Icinga repository. The Ubuntu archive packages are older and do not include Icinga DB. For the full walkthrough, see How to Install Icinga 2 on Ubuntu.

sudo apt install -y wget gnupg apt-transport-https
wget -qO - https://packages.icinga.com/icinga.key \
  | sudo gpg --dearmor -o /usr/share/keyrings/icinga-archive-keyring.gpg
. /etc/os-release
echo "deb [signed-by=/usr/share/keyrings/icinga-archive-keyring.gpg] https://packages.icinga.com/ubuntu icinga-${VERSION_CODENAME} main" \
  | sudo tee /etc/apt/sources.list.d/icinga.list
sudo apt update

sudo apt install -y icinga2 monitoring-plugins icingadb-redis icingadb
sudo systemctl enable --now icinga2 icingadb-redis
sudo icinga2 feature enable icingadb

# Import the Icinga DB schema
sudo mariadb icingadb < /usr/share/icingadb/schema/mysql/schema.sqlCode language: PHP (php)

Edit the database block in /etc/icingadb/config.yml so it matches the user created earlier, then start the services:

database:
  type: mysql
  host: localhost
  port: 3306
  database: icingadb
  user: icingadb
  password: ChangeMe_DB1

redis:
  host: localhost
  port: 6380
sudo systemctl enable --now icingadb
sudo icinga2 api setup
sudo systemctl restart icinga2

Install Icinga Web 2 and run the setup wizard

Icinga Web 2 sends commands, such as rescheduling a check, through the Icinga 2 API. Create an API user for it in /etc/icinga2/conf.d/api-users.conf. The enable the Icinga API guide explains this in more detail.

object ApiUser "icingaweb2" {
  password = "ChangeMe_Api1"
  permissions = [ "actions/*", "objects/modify/*", "objects/query/*", "status/query" ]
}Code language: JavaScript (javascript)
sudo icinga2 daemon -C && sudo systemctl restart icinga2
sudo apt install -y icingaweb2 icingadb-web icingacli libapache2-mod-php php-mysql
sudo icingacli setup token create
  1. Open http://<server-ip>/icingaweb2/setup and paste the token.
  2. Enable the Icinga DB module.
  3. Configuration database: type MySQL, host localhost, database icingaweb2, user icingaweb2.
  4. Create the first admin user for the web UI.
  5. Icinga DB resource: database icingadb, user icingadb. Redis: localhost, port 6380.
  6. Command transport: API on localhost:5665 with the icingaweb2 API user, then finish and log in.

Verify the installation

sudo systemctl is-active icinga2 icingadb icingadb-redis mariadb apache2
sudo icinga2 daemon -C | tail -n 3
sudo mariadb icingadb -e "SELECT name FROM host LIMIT 5;"Code language: JavaScript (javascript)

All five services should print active. The configuration check should end with Finished validating the configuration file(s). The query should list your local host. If the host table is empty, Icinga DB is not receiving data, so check journalctl -u icingadb.

Common errors and fixes

ErrorCauseFix
ERROR 1698 (28000): Access denied for user 'root'@'localhost'root uses unix_socket authenticationUse sudo mariadb, or add password login as shown in the reset section
ERROR 1045 ... (using password: YES)Wrong password, or the user exists for localhost but you connected via 127.0.0.1Check the .my.cnf values and use host = localhost
ERROR 2002 Can't connect ... through socketServer not running, or the client points at the wrong socket (XAMPP vs system)Start the right server and set socket in .my.cnf
MariaDB fails to start: port 3306 in useXAMPP MariaDB and system MariaDB running togetherStop one: sudo /opt/lampp/lampp stop
Web UI: Failed to send external Icinga commandAPI user missing or wrong permissionsCheck api-users.conf, restart Icinga 2, then fix the command transport

Frequently asked questions

Can I run Icinga with XAMPP's MariaDB?

It can work if you point Icinga DB at XAMPP's socket or port, but it is not recommended. Icinga packages are built for the distribution's MariaDB, Apache and PHP, and XAMPP is meant for local development.

Should I still use the IDO MySQL feature?

No, not for new installations. Icinga DB replaces the IDO database backend, which is deprecated, and Icinga Web 2 uses it through the Icinga DB Web module.

What is the default URL for Icinga Web 2?

With the Apache configuration from the package, the UI is at http://<server>/icingaweb2/, and the first-run wizard is at /icingaweb2/setup.

I lost the Icinga Web 2 setup token. How do I get it back?

Run sudo icingacli setup token show to print it again, or sudo icingacli setup token create to make a new one.

Which databases does Icinga DB support?

Icinga DB supports MySQL, MariaDB and PostgreSQL. The schema files are under /usr/share/icingadb/schema/.

Related tutorials

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services โ€” all in one place.

Explore Hospitals
I'm Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms. I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.

Related Posts

Complete Guide for Socket based vs TCP Based Application Connection

Hereโ€™s a clear, end-to-end tutorial you can keep handy. It explains what โ€œsocket-basedโ€ vs โ€œTCP-basedโ€ really means, how to tell which one youโ€™re using, and how to…

Read More

keycloak: Installing keycloak with mysql (socket + TCP enabled)

To run Keycloak 17+ (Quarkus) with MySQL on the same server (XAMPP/LAMPP). It covers two supported setups. Pick A (TCP) for a production-style config, or B (UNIX…

Read More

Managing MariaDB Root Password and Connection Behavior in XAMPP (Ubuntu)

โ˜๏ธ Introduction When working with MariaDB/MySQL inside XAMPP on Ubuntu, many developers face confusing issues related to root password behavior, localhost vs 127.0.0.1 access, and authentication plugins.This…

Read More

List of Compreshive Checklist to do Security Audit in XAMPP server

Conducting a security audit on a XAMPP server is crucial, especially if you’re considering moving a local development environment to a production setting. XAMPP is primarily designed…

Read More

Datadog Tutorials: How to Monitor Apache using Datadog in Windows

To monitor Apache on Windows with Datadog, you expose Apache's mod_status page on localhost, then point the Datadog Agent's built-in Apache check at http://localhost/server-status?auto. The steps above…

Read More

How to Reset or Recover Forgotten mySql root Password

To reset a forgotten MySQL or MariaDB root password, stop the server, restart it with grant checks turned off (skip-grant-tables), set a new password with ALTER USER,…

Read More
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
0
Would love your thoughts, please comment.x
()
x