# Icinga Master und Agents

Icinga Docs: [https://icinga.com/docs/icinga-2/latest/doc/02-installation/01-Debian/#install-icinga-2-on-debian](https://icinga.com/docs/icinga-2/latest/doc/02-installation/01-Debian/#install-icinga-2-on-debian)

### Debian Repository

```
apt update
apt -y install apt-transport-https wget gnupg

wget -O - https://packages.icinga.com/icinga.key | gpg --dearmor -o /usr/share/keyrings/icinga-archive-keyring.gpg

DIST=$(awk -F"[)(]+" '/VERSION=/ {print $2}' /etc/os-release); \
 echo "deb [signed-by=/usr/share/keyrings/icinga-archive-keyring.gpg] https://packages.icinga.com/debian icinga-${DIST} main" > \
 /etc/apt/sources.list.d/${DIST}-icinga.list
 echo "deb-src [signed-by=/usr/share/keyrings/icinga-archive-keyring.gpg] https://packages.icinga.com/debian icinga-${DIST} main" >> \
 /etc/apt/sources.list.d/${DIST}-icinga.list

apt update
```

## Install Icinga 2

```
apt install icinga2
```

Docs sind unvollständig!

Was fehlt?

- Einrichtung Icingaweb2 classic samt Einrichtung API User für Icingaweb2 und IcingaDB(+Icingadb-Web).
- Docs zu den DB Sachen.

Ergänzung:

[https://alibaba-cloud.medium.com/how-to-install-and-configure-icinga2-monitoring-tool-on-ubuntu-16-04-a582e949dd40](https://alibaba-cloud.medium.com/how-to-install-and-configure-icinga2-monitoring-tool-on-ubuntu-16-04-a582e949dd40)

/etc/icinga2/constants.conf anpassen und NodeName in FQDN ändern.

Ermitteln (testet gleich ob DNS funktioniert) mittels: hostname -f oder --fqdn

Danach icinga2 api setup ausführen.

Quelle: [https://github.com/Icinga/icinga2/issues/6649#issuecomment-638330961](https://github.com/Icinga/icinga2/issues/6649#issuecomment-638330961)

1\. Lösung:

```
I found https://github.com/Icinga/icinga2/issues/6649 23

the last post says
rm /var/lib/icinga2/ca/*
rm /var/lib/icinga2/certs/*
rm /var/cache/icinga2/*
icinga2 api setup
```

2\. Lösung (besser)

```codeblock-buttons
vi /etc/icinga2/constants.conf
icinga2 feature disable api
icinga2 daemon -C
icinga2 api setup
```

## Set up Check Plugins

```
apt install monitoring-plugins
```

## Set up Icinga 2 API

```
icinga2 api setup
```

Restart Icinga 2 for these changes to take effect.

```
systemctl restart icinga2
```

## Set up Icinga DB

Setting up Icinga 2’s Icinga DB feature is only required for Icinga 2 master nodes or single-node setups.

### Set up Redis Server

Tip:

Although the Redis server can run anywhere in an Icinga environment, we recommend to install it where the corresponding Icinga 2 node is running to keep latency between the components low.

#### Install Icinga DB Redis Package

```
apt install icingadb-redis
```

#### Run Icinga DB Redis

The `icingadb-redis` package automatically installs the necessary systemd unit files to run Icinga DB Redis. Please run the following command to enable and start its service:

```
systemctl enable --now icingadb-redis
```

#### Enable Remote Redis Connections <a id="bkmrk-"></a>[¶](https://icinga.com/docs/icinga-2/latest/doc/02-installation/01-Debian/#enable-remote-redis-connections "Permanent link")

By default, `icingadb-redis` only listens on `127.0.0.1`. If Icinga Web or Icinga 2 is running on another node, remote access to the Redis server must be allowed. This requires the following directives to be set in the `/etc/icingadb-redis/icingadb-redis.conf` configuration file:

- Set `protected-mode` to `no`, i.e. `protected-mode no`
- Set `bind` to the desired binding interface or bind all interfaces, e.g. `bind 0.0.0.0`

Warning:

By default, Redis has no authentication preventing others from accessing it. When opening Redis to an external interface, make sure to set a password, set up appropriate firewall rules, or configure TLS with certificate authentication on Redis and its consumers, i.e. Icinga 2, Icinga DB and Icinga Web.

Restart Icinga DB Redis for these changes to take effect:

```
systemctl restart icingadb-redis
```

### Enable Icinga DB Feature

To enable the `icingadb` feature use the following command:

```
icinga2 feature enable icingadb
```

Restart Icinga 2 for these changes to take effect:

```
systemctl restart icinga2
```

### Install Icinga DB Daemon

After installing Icinga 2, setting up a Redis server and enabling the `icingadb` feature, the Icinga DB daemon that synchronizes monitoring data between the Redis server and a database is now set up.

Tip:

Although the Icinga DB daemon can run anywhere in an Icinga environment, we recommend to install it where the corresponding Icinga 2 node and Redis server is running to keep latency between the components low.

The Icinga DB daemon package is also included in the Icinga repository, and since it is already set up, you have completed the instructions here and can proceed to [install the Icinga DB daemon on Debian](https://icinga.com/docs/icinga-db/latest/doc/02-Installation/03-Debian/#installing-icinga-db-package), which will also guide you through the setup of the database and Icinga DB Web.

## Backup

Ensure to include the following in your backups:

- Configuration files in `/etc/icinga2`
- Certificate files in `/var/lib/icinga2/ca` (Master CA key pair) and `/var/lib/icinga2/certs` (node certificates)
- Runtime files in `/var/lib/icinga2`

## Installing Icinga DB Package

```
apt install icingadb
```

## Install mariadb-server

```
apt install mariadb-server
```

## Setting up the Database

### Setting up a MySQL or MariaDB Database

Set up a MySQL database for Icinga DB:

change the placeholder "CHANGEME"

```
# mysql -u root -p

CREATE DATABASE icingadb;
CREATE USER 'icingadb'@'localhost' IDENTIFIED BY 'CHANGEME';
GRANT ALL ON icingadb.* TO 'icingadb'@'localhost';
```

After creating the database, import the Icinga DB schema using the following command:

```
mysql -u root -p icingadb </usr/share/icingadb/schema/mysql/schema.sql
```

## Configuring Icinga DB

Icinga DB installs its configuration file to `/etc/icingadb/config.yml`, pre-populating most of the settings for a local setup. Before running Icinga DB, adjust the Redis<span class="registered-sign">®</span> and database credentials and, if necessary, the connection configuration. The configuration file explains general settings. All available settings can be found under [Configuration](https://icinga.com/docs/icinga-db/latest/doc/03-Configuration/).

## Running Icinga DB

The `icingadb` package automatically installs the necessary systemd unit files to run Icinga DB. Please run the following command to enable and start its service:

```
systemctl enable --now icingadb
```

## Installing Icinga DB Web

With Icinga 2, Redis<span class="registered-sign">®</span>, Icinga DB and the database fully set up, it is now time to install Icinga DB Web, which connects to both Redis<span class="registered-sign">®</span> and the database to display and work with the monitoring data.

The Icinga DB Web package is also included in the Icinga repository, and since it is already set up, you have completed the instructions here and can proceed to [installing Icinga DB Web on Debian](https://icinga.com/docs/icinga-db-web/latest/doc/02-Installation/03-Debian/#installing-icinga-db-web-package), which will also guide you through the setup of the Icinga Web PHP framework, which is required to run the Icinga DB web module.

## Installing the Package

Use your distribution’s package manager to install the `icingadb-web` package as follows:

```
apt install icingadb-web
```

This concludes the installation. Now proceed with the [configuration](https://icinga.com/docs/icinga-db-web/latest/doc/03-Configuration/).

### Configuration

If Icinga Web has been installed but not yet set up, please visit Icinga Web and follow the web-based setup wizard.

[http://icingaweb\_fqdn/icingaweb2/setup](http://icingaweb_fqdn/icingaweb2)

#### Icingaweb2 Web-Wizard

Start:

#### Database Configuration

Connection configuration for the database to which Icinga DB synchronizes monitoring data.

1. Create a new resource for the Icinga DB database via the `Configuration → Application → Resources` menu.
2. Configure the resource you just created as the database connection for the Icinga DB Web module using the `Configuration → Modules → icingadb → Database` menu.

#### Redis<span class="registered-sign">®</span> Configuration

Connection configuration for the Redis<span class="registered-sign">®</span> server where Icinga 2 writes check results. This data is used to display the latest state information in Icinga DB Web.

1. Configure the connection to the Redis<span class="registered-sign">®</span> server through the `Configuration → Modules → icingadb → Redis` menu.