Aktionen

Zabbix Server + Agent unter Ubuntu 24.04 LTS installieren

Aus znilwiki

Changelog:

  • 10.06.2024 erste Version

Installation Ubuntu Server 24.04.x LTS (Long Term Support)


Einstellungen für die VM

Falls Ihr das System als virtuelle Maschine (VM) installiert so könnt Ihr folgenden Einstellungen als Beispiel nehmen.

  • Konfiguration: Typisch
  • Name und Speicherort: Nach eigener Wahl
  • Speicher: Nach eigener Wahl
  • Gastbetriebssystem: (*) Linux --> Ubuntu (64-Bit)
  • Netzwerk:
    • Wie viele Netzwerkkarten möchten Sie anschließen: 1
    • Netzwerk: Nach Wahl (VM Network?)
    • Adapter: VMXNET 3
  • Größe der virtuellen Festplatte:
    • Hängt von der Anzahl der Menge der Daten ab
    • Ich empfehle min 32GB für das Betriebssystem des Servers.
    • Die Festplatte kann bei einer VM nachträglich vergrößert werden - siehe dazu den Abschnitt in diesem Artikel weiter unten
    • Man kann auch jederzeit eine weitere Festplatte anhängen und die Daten dorthin migrieren
    • Thick-Provision Lazy-Zeroed

Danach Einstellungen der VM bearbeiten: Reiter Hardware:

  • Arbeitsspeicher:
    • 4GB oder mehr
  • CPUs:
    • Anzahl der virtuellen Sockets
      • 4 oder mehr
    • Anzahl der Cores pro Socket: 1 (Immer Anzahl der Sockets erhöhen)

Reiter Optionen

  • ...




Grundinstallation

Important.png
Hinweis: Ich habe die offizielle ISO verwendet: https://ubuntu.com/download/server


CD einlegen und los,
die Fragen beantwortet Ihr wie folgt (sind ggf. die Überschriften der Dialoge):

ClipCapIt-240527-140258.PNG Try or Install Ubuntu Server
ClipCapIt-240527-140440.PNG Deutsch
ClipCapIt-220427-115808.PNG German / German
Wenn er einen neueren Installer findet und fragt ob er auf diesen aktualisieren soll - Ja!
Install Ubuntu2204 Pic2.png Ubuntu Server
ClipCapIt-220427-120131.PNG Jetzt könnt Ihr schon die gewünschte feste IP-Adresse einstellen. Wählt dazu mit den Pfeiltasten den ens160 Eintrag aus und drückt Enter:
ClipCapIt-200521-152546.PNG ens192 => Bearbeite IPv4
ClipCapIt-200521-152642.PNG Manuell
ClipCapIt-200521-152742.PNG Bei Subnetz kommt nicht die Subnetzmaske sondern das Netzwerk mit Suffix. Bei einer 24 Maske (= 255.255.255.0) ist das die IP 0 mit Suffix /24
ClipCapIt-200521-153302.PNG Erledigt
ClipCapIt-220427-120259.PNG Bei Bedarf, sonst leer lassen
ClipCapIt-220427-120335.PNG Erledigt
ClipCapIt-220427-120400.PNG Nutzt die ganze Festplatte ohne LVM (also Haken entfernen). Die Festplatte lässt sich später trotzdem leicht vergrößern
ClipCapIt-220427-120443.PNG Erledigt
ClipCapIt-220427-120505.PNG Fortfahren
ClipCapIt-220427-120827.PNG Den Servernamen festlegen. Ich lege hier den Benutzer installadmin an. Wählt euren Benutzer und Passwort nach Wunsch (Aufschreiben!)
ClipCapIt-240527-140937.PNG Falls Ihr Ubuntu Pro habt, könnet Ihr es hier aktiveren, ansonsten einfach [Fortfahren]
ClipCapIt-240527-141106.PNG OpenSSH-Server auswählen => Erledigt (für Zugriff z.B. mit Putty)
ClipCapIt-240527-141137.PNG Erledigt

Ab jetzt heißt es abwarten. Wenn er kann lädt er gleich ein paar Sicherheitsupdates nach:

ClipCapIt-220427-121943.PNG Jetzt neustarten
ClipCapIt-220427-122036.PNG ISO aus der VM entfernen und Enter drücken
ClipCapIt-220427-122152.PNG Nach dem Reboot wartet ab bis diverse Meldungen abgelaufen sind

PuTTY

Ab dieser Stelle könnt Ihr PuTTY oder den SSH Client eurer Wahl nutzen - was ich dringend empfehle. Denn dann könnt Ihr hier vorgeschlagenen Befehle einfach per Copy&Paste übernehmen.
Die IP-Adresse habt Ihr zu diesem Zeitpunkt ja bereits festgelegt:

ClipCapIt-200521-155245.PNG ClipCapIt-200521-155339.PNG ClipCapIt-200521-160706.PNG

Nach der Anmeldung nutze ich immer gerne ein

sudo -i

Damit wechselt man dauerhaft zum root Benutzer und muss nicht vor jedem Befehl ein sudo stellen.


root wieder freischalten

Important.png
Hinweis: Ob nun wie ich immer als root arbeiten wollt oder aber als einfacher Benutzer und dann immer sudo verwendet müsst Ihr selbst wissen
  • Mit Benutzer installadmin anmelden
sudo -i
  • Kennwort des Benutzer installadmin eintippen
passwd root
  • neues Kennwort für "root" 2x eintippen
ClipCapIt-200521-161108.PNG
  • Lokal Anmelden kann man sich nun mit root - aber eine Anmeldung über SSH funktioniert dann immer noch nicht.
  • Damit diese auch funktioniert müsst ihr die sshd_config bearbeiten:
nano /etc/ssh/sshd_config

sucht nach der Zeile (STRG + W ist Suchen) nach

#PermitRootLogin without-password

und stellt den Cursor in die Zeile.
Drückt nun einmal F9 und 2x F10 - damit erstellt Ihr eine Kopie der Zeile.
Ändert die Kopie wie folgt ab:

PermitRootLogin yes
ClipCapIt-200521-161435.PNG

Speichert die Datei (STRG + x, dann y und Enter) und startet den ssh Dienst neu:

systemctl restart ssh.service

Ab dann klappt es auch mit dem SSH-Login für den Benutzer root, z.B. über puTTY
Jetzt 2x

exit

eintippen wodurch sich das PuTTY Fenster schließt - der (eingeschränkte) Benutzer installadmin hat sich somit abgemeldet

Important.png
Hinweis:

Ja, ich persönlich arbeite gerne als root und habe diesen für die Anmeldung freigeschaltet. Was ich nicht mache ist das Login per SSH mit Passwort zu erlauben. Ich hinterlege also immer einen SSH-Key für die Anmeldung und nutze diesen statt des Kennwortes. Die Lösung hier ist einfach gehalten, der Profi mögen anpassen wie er es braucht. Ein Anmeldung als eingeschränkter Benutzer geht natürlich auch, das erste was ich dann immer mache ist ein sudo -i um dauerhaft zum root zu wechseln

Anmelden als root

Startet PuTTY wieder und meldet euch diesmal gleich als Benutzer root an.


nano & Co auf Deutsch

nano war eben z.B. noch auf Englisch, mit

apt install -y language-pack-de

ist es (und vieles andere) auf deutsch.


root farbiger Prompt

Als root anmelden:

nano ~/.bashrc

Zeile 39 (Alt + C aktiviert Zeilennummernanzeige):

#force_color_prompt=yes

ändern zu (# entfernen):

force_color_prompt=yes


nun wieder Abmelden - ab der nächsten Anmeldung ist der neue Prompt aktiv.

ClipCapIt-200521-162422.PNG

Wer den sofort haben will (ohne neu Anmelden):

source ~/.bashrc

Feste IP-Adresse vergeben

Der Server hat dank des neuen Setupdialoges nun bereits eine feste IP-Adresse.
Solltet Ihr an dieser etwas ändern müssen so müssen wir erst das Cloud-Init deaktivieren:

nano /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg

Inhalt:

network: {config: disabled}

Dann könnte Ihr in der folgenden Datei etwas ändern, die Warnungen das es einen reboot nicht übersteht könnt Ihr ignorieren, dafür haben wir die andere Datei angelegt.

nano /etc/netplan/50-cloud-init.yaml
ClipCapIt-200521-162802.PNG

Updates einspielen

  • wieder anmelden als root bzw. zum root wechseln
  • Updates suchen für Betriebssystem: (aktualisiert den Katalog aus den Update-Quellen)
apt update
  • Updates einspielen:
apt upgrade -y
  • Nach Update überflüssige Pakete entfernen:
apt autoremove -y


Ich mache das normalerweise immer als Einzeiler:

apt update && apt upgrade -y && apt autoremove -y




Multipathing deinstallieren (wenn der Server eine VM ist)

Ab Werk wird nun das

/var/log/syslog

mit Multipath-Meldungen vollgemüllt:

2024-05-27T12:32:47.571374+00:00 ubuntu2404 systemd[1]: Started multipathd.service - Device-Mapper Multipath Device Controller.
2024-05-27T12:32:47.592304+00:00 ubuntu2404 kernel: systemd[1]: Listening on multipathd.socket - multipathd control socket.
2024-05-27T12:32:47.592385+00:00 ubuntu2404 kernel: systemd[1]: Starting multipathd.service - Device-Mapper Multipath Device Controller...
2024-05-27T12:32:48.141146+00:00 ubuntu2404 multipathd[467]: sda: failed to get udev uid: No data available
2024-05-27T12:32:48.141212+00:00 ubuntu2404 multipathd[467]: sda: failed to get path uid
2024-05-27T12:32:48.141278+00:00 ubuntu2404 multipathd[467]: uevent trigger error
2024-05-27T12:32:57.634912+00:00 ubuntu2404 multipathd[467]: sda: triggering change event to reinitialize
2024-05-27T12:32:57.667862+00:00 ubuntu2404 multipathd[467]: sda: failed to get udev uid: No data available
2024-05-27T12:32:57.667930+00:00 ubuntu2404 multipathd[467]: sda: failed to get path uid
2024-05-27T12:32:57.667959+00:00 ubuntu2404 multipathd[467]: uevent trigger error
2024-05-27T12:33:07.637080+00:00 ubuntu2404 multipathd[467]: sda: triggering change event to reinitialize
2024-05-27T12:33:07.676773+00:00 ubuntu2404 multipathd[467]: sda: failed to get udev uid: No data available
2024-05-27T12:33:07.676839+00:00 ubuntu2404 multipathd[467]: sda: failed to get path uid
2024-05-27T12:33:07.676865+00:00 ubuntu2404 multipathd[467]: uevent trigger error
2024-05-27T12:33:17.641466+00:00 ubuntu2404 multipathd[467]: sda: triggering change event to reinitialize
2024-05-27T12:33:17.709843+00:00 ubuntu2404 multipathd[467]: sda: failed to get sysfs uid: No such file or directory
2024-05-27T12:33:17.709915+00:00 ubuntu2404 multipathd[467]: sda: failed to get sgio uid: No such file or directory
2024-05-27T12:33:17.709942+00:00 ubuntu2404 multipathd[467]: sda: failed to get path uid
2024-05-27T12:33:17.709969+00:00 ubuntu2404 multipathd[467]: uevent trigger error
2024-05-27T12:33:28.134951+00:00 ubuntu2404 multipathd[467]: sda: not initialized after 3 udev retriggers
2024-05-27T12:33:29.139933+00:00 ubuntu2404 multipathd[467]: sda: add missing path
2024-05-27T12:33:29.140037+00:00 ubuntu2404 multipathd[467]: sda: failed to get sysfs uid: No such file or directory
2024-05-27T12:33:29.140063+00:00 ubuntu2404 multipathd[467]: sda: failed to get sgio uid: No such file or directory
2024-05-27T12:33:29.140086+00:00 ubuntu2404 multipathd[467]: sda: no WWID in state "undef
2024-05-27T12:33:29.140109+00:00 ubuntu2404 multipathd[467]: ", giving up
2024-05-27T12:33:29.140181+00:00 ubuntu2404 multipathd[467]: sda: check_path() failed, removing

Unter Ubuntu 24.04/22.04 scheint es nicht mehr ganz so schlimm wie unter 20.04 - aber in einer VM macht Multipath keinen Sinn, also deaktivieren und deinstallieren um das Syslog von den Meldungen befreien:

systemctl stop multipathd.service && systemctl disable multipathd.service
apt install kpartx libsgutils2-1.46-2 sg3-utils sg3-utils-udev
apt remove -y multipath-tools && apt purge -y multipath-tools

Die apt install Zeile ist da drin weil diese Pakete ggf. von anderen Anleitung vorausgesetzt werden. Die Pakte werden dadurch auf manuell installiert gesetzt und dann nicht bei einem apt autoremove deinstalliert


Cloud-Init deinstallieren (Wenn es keine VM bei einem Cloudanbieter ist)

Wenn Ihr die VM reboootet und die Console betrachtet tauchen kurz nach dem Reboot (Fehler-)Meldungen zum Cloud-init auf:

ClipCapIt-200521-163633.PNG

Das Cloud-Init ist - wenn ich mich recht erinnere - dafür da falls eure VM z.B. bei Amazon AWS, Azure oder andere Anbieter läuft um z.B. die Netzwerkinformationen vom Hoster/Provider zu erhalten.
Brauchen wir nicht, also weg damit:

echo 'datasource_list: [ None ]' | tee /etc/cloud/cloud.cfg.d/90_dpkg.cfg
apt purge -y cloud-init
rm -rf /etc/cloud/ && sudo rm -rf /var/lib/cloud/
apt install eatmydata libeatmydata1 python-babel-localedata python3-babel python3-jinja2 python3-json-pointer python3-jsonpatch python3-jsonschema python3-markupsafe python3-pyrsistent python3-tz -y
reboot

Die apt install Zeile ist da drin weil diese Pakete ggf. von anderen Anleitung vorausgesetzt werden. Die Pakte werden dadurch auf manuell installiert gesetzt und dann nicht bei einem apt autoremove deinstalliert


Zeitzone setzen

In meiner VM ist die Uhrzeit zu diesem Zeitpunkt falsch (gebt mal probeweise date ein) - weil der ESXi-Host auf UTC Zeit läuft und die Ubuntu in der VM die richtige Zeitzone nicht eingestellt hat.
Wir korrigieren das mit

timedatectl set-timezone Europe/Berlin

ein

date

sollte dann die richtige Uhrzeit ausspucken.


Zeitserver setzen

Important.png
Hinweis: Wenn Ihr diesen Schritt überspringt, wird ntp.ubuntu.com als Zeitserver verwendet

Für die Zeitsynchronisierung ist der Dienst systemd-timesyncd.service zuständig, dieser wird über die Datei

nano /etc/systemd/timesyncd.conf

konfiguriert:

#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it under the
#  terms of the GNU Lesser General Public License as published by the Free
#  Software Foundation; either version 2.1 of the License, or (at your option)
#  any later version.
#
# Entries in this file show the compile time defaults. Local configuration
# should be created by either modifying this file (or a copy of it placed in
# /etc/ if the original file is shipped in /usr/), or by creating "drop-ins" in
# the /etc/systemd/timesyncd.conf.d/ directory. The latter is generally
# recommended. Defaults can be restored by simply deleting the main
# configuration file and all drop-ins located in /etc/.
#
# Use 'systemd-analyze cat-config systemd/timesyncd.conf' to display the full config.
#
# See timesyncd.conf(5) for details.

[Time]
NTP=192.168.1.81
FallbackNTP=192.168.1.198 de.pool.ntp.org
RootDistanceMaxSec=30
#PollIntervalMinSec=32
#PollIntervalMaxSec=2048
#ConnectionRetrySec=30
#SaveIntervalSec=60

Sowohl die Liste der NTP= als auch der FallbackNTP= erwartet eine per Leerzeichen getrennte Liste der möglichen Server.
Laut Anleitung hört der Dienst aber beim ersten Treffer auf zu suchen. In der Praxis setzt also einen NTP-Server und ggf. die Fallback. Setzt Ihr einen Wert nicht, lasst diesen also auskommentiert, so gilt der Default-Wert, beim Fallback gilt dann FallbackNTP=ntp.ubuntu.com.
Nach der Änderung müsst Ihr den Dienst einmal neu starten:

systemctl restart systemd-timesyncd.service

und mit folgenden Befehl könnt Ihr den Status abfragen:

timedatectl show-timesync

Beispielausgabe:

LinkNTPServers=fd00::1eed:6fff:fe71:f1c0
SystemNTPServers=192.168.1.81
FallbackNTPServers=192.168.1.198 de.pool.ntp.org
ServerName=192.168.1.81
ServerAddress=192.168.1.81
RootDistanceMaxUSec=30s
PollIntervalMinUSec=32s
PollIntervalMaxUSec=34min 8s
PollIntervalUSec=2min 8s
NTPMessage={ Leap=0, Version=3, Mode=4, Stratum=3, Precision=-23, RootDelay=20.324ms, RootDispersion=28.579ms, Reference=C0A801C6, OriginateTimestamp=Tue 2024-06-04 08:22:24 CEST, 
ReceiveTimestamp=Tue 2024-06-04 08:22:24 CEST, TransmitTimestamp=Tue 2024-06-04 08:22:24 CEST, DestinationTimestamp=Tue 2024-06-04 08:22:24 CEST, Ignored=no, PacketCount=2, Jitter=239us }
Frequency=1158037

Wenn die untere Zeile mit NTPMessage= nicht erscheint, habt Ihr ein Problem!
Mit

journalctl -fu systemd-timesyncd.service

könnte Ihr nach dem Grund suchen. Steht da etwas wie Server has to large root distance. Disconnecting und es gegen einen Domänencontroller geht so stellt sicher das

  • Es der PDC ist
  • Dieser sich auch selbst mit einer externen Quelle synchronisiert
  • Stellt ggf. den Wert von RootDistanceMaxUSec=30s noch höher.

Automatische Updates deaktivieren

Ich persönlich möchte nicht das der Zabbix-Server automatisch Updates einspielt.
Die automatischen Updates aktualisieren - soweit ich das beobachten konnte - nur den Kernel. Aber auch das möchte ich nicht. Ich möchte das geplant durchführen.
Die automatischen Updates verhindern wir mit

apt remove -y unattended-upgrades

Benötigte Programme für Zabbix installieren

Die nachfolgende Zeile installiert alles notwendige um alle Features eines Zabbix-Server zu nutzen. Als Datenbank wird MariaDB verwendet.
Wer lieber MySQL verwenden will muss in der Zeile mariadb-server durch mysql-server ersetzen:

apt install dnsutils htop make gcc libc6-dev libmysqlclient-dev libcurl4-openssl-dev libssh2-1-dev libsnmp-dev libiksemel-dev mariadb-server libopenipmi-dev fping php-gd snmp libsnmp-base openjdk-11-jdk unixodbc unixodbc-dev libxml2 libxml2-dev snmp-mibs-downloader snmpd snmptrapd snmptt sblim-wbemcli php-ldap traceroute ipmitool libldap2-dev php-bcmath php-mbstring php-xml fonts-dejavu-core libnet-snmp-perl libnet-ip-perl libnet-netmask-perl libnet-dns-perl libxml-writer-perl language-pack-en -y
Face-wink.png
Tipp: Zum kopieren der oberen Zeile mit der Maus vor das apt gehen und 3x Klicken. Ggf. mehrmals versuchen - bis die ganze Zeile markiert ist. Diese kann dann so in z.B. PuTTY eingefügt werden


Mit der obigen Zeite werden gewiss einige Pakete zuviel installiert - unter anderem alles was nötig wäre um Zabbix auch direkt aus dem Quellcode zu kompilieren. Aber es sind dann auch definitiv alle notwendigen Voraussetzungen für jegliche Zabbix-Abfrage vorhanden, z.B. für den Empfang von SNMP-Traps - und anderem zum Beispiel die ganzen PHP-Pakete inklusive LDAP.


Zabbix Server installieren

Ich würde in einer Produktivumgebung immer eine der LTS-Varianten installieren. Auch wenn es einem in den Finger juckt wegen der neuen Features.
Ihr müsstet spätestens nach 6 Monaten ein Upgrade auf die nächste Version durchführen!
Ich persönlich nutze auch privat nur die LTS-Version. Die Zwischenversionen installiere ich separat zum Testen.


Zabbix Repository hinzufügen

Für die Version 7.0.x LTS (Support bis 31.06.2029)
wget https://repo.zabbix.com/zabbix/7.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_7.0-1+ubuntu24.04_all.deb
dpkg -i zabbix-release_7.0-1+ubuntu24.04_all.deb
apt update && apt upgrade -y
rm zabbix-release_*
Für die Version 6.4.x (Support bis 31.12.2024)
wget https://repo.zabbix.com/zabbix/6.4/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.4-1+ubuntu24.04_all.deb
dpkg -i zabbix-release_6.4-1+ubuntu24.04_all.deb
apt update && apt upgrade -y
rm zabbix-release_*
Für die Version 6.0.x (Support bis 28.02.2027)
wget https://repo.zabbix.com/zabbix/6.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.0-6+ubuntu24.04_all.deb
dpkg -i zabbix-release_6.0-6+ubuntu24.04_all.deb
apt update && apt upgrade -y
rm zabbix-release_*
Important.png
Hinweis: Das apt update && apt upgrade -y ist notwendig da ich bemerkt habe das darüber auch das Zabbix-Repo selbst geupdatet wurde. (Kann sich wieder ändern, schadet aber auch nicht)

Zabbix installieren

Die Installation der ausführbaren Dateien erfolgt bei allen Varianten nach /sbin !

Warning.png
Warnung: Achtet nachfolgend immer darauf ob Ihr den Zabbix Server oder den Zabbix Proxy installieren wollt!

Fehlermeldungen zum Zabbix Java Gateway ignorieren!


Button Zabbix SERVER.png Als Server

Ab Version 6.0

apt install -y zabbix-server-mysql zabbix-sql-scripts zabbix-frontend-php zabbix-apache-conf zabbix-agent2 zabbix-get zabbix-sender zabbix-java-gateway zabbix-web-service



Button Zabbix PROXY.png Als Proxy

Ab Version 6.0

apt install -y zabbix-proxy-mysql zabbix-sql-scripts zabbix-agent2 zabbix-get zabbix-sender zabbix-java-gateway



Java Gateway deaktivieren

Die wenigsten werden es nutzen - doch diese Anleitung ist so gemacht das sich danach alle Features von Zabbix nutzen lassen.
Wann braucht Ihr es? Wenn Ihr Java-Applikationen habt die Ihr aus dieser Applikation selbst monitoren wollt. Dazu müssen beim Start der Applikation extra Parameter hierfür übergeben werden (nämlich unter anderen die Daten des Java-Gateways).

Wer es nicht braucht (und gerade nur Bahnhof verstanden hat) deaktiviert es mit

systemctl stop zabbix-java-gateway.service &&  systemctl disable zabbix-java-gateway.service

Bei der Installation gab es ggf. Fehlermeldungen das der Dienst nicht gestartet werden konnte - das würde jetzt aber funktionieren.



MariaDB (MySQL) Datenbank optimieren

Important.png
Hinweis:Es funktioniert auch alles ohne diese Optimierungen! Diese kann man machen wenn der Server etwas größer wird weil wir hunderte von Servern und Geräten überwachen! In diesem Fall sollte auch der Festplattenplatz entsprechend dimensoniert sein! Für einen einfachen Server könnt Ihr das hier auch überspringen!

Die Einrichtung wird auch hier beschrieben - allerdings etwas knapp: https://www.zabbix.com/documentation/current/manual/appendix/install/db_scripts

Die Zabbix-Datenbank kann recht groß werden und jeder Zugriff zählt. Ich habe mir deshalb mal aus diversen Quellen im Internet Tipps zusammengesucht um die Performance der Datenbank zu steigern.

MariaDB Einstellungen bearbeiten (wer MySQL einsetzt findet die passende Datei unter nano /etc/mysql/mysql.conf.d/mysqld.cnf):

nano /etc/mysql/mariadb.conf.d/50-server.cnf

und unterhalb von

[mysqld]

Diese Zeilen einfügen (und die Kommentare lesen / beachten!!!):

# Größe der Logdatei statt 10MB
innodb_log_file_size = 512M
# Transaktionswerte nach Möglichkeit nicht in den Doublewritebuffer schreiben
innodb_doublewrite = 0
# Transaktionen schon bestätigen sobald diese im Cache stehen:
innodb_flush_log_at_trx_commit = 2
# Wieviel Hauptspeicher soll zum Puffern verwendet werden? Nehmt die Hälfte des vorhandenen Speichers (bei 4GB RAM also 2G, bei 1G also 512M)
innodb_buffer_pool_size = 1G
# Eigenes Fehlerprotokoll wieder aktivieren
log_error = /var/log/mysql/error.log


mit STRG + x den nano verlassen und speichern bestätigen j + Enter)

Warning.png
Warnung: Prüft unbedingt den Wert von innodb_buffer_pool_size!!! Dieser Wert darf nicht größer sein als der tatsächlich vorhandene RAM, sonst startet MySQL nicht


Prüft ggf. ob diese Zeilen dann nicht doppelt vorkommen!

Wenn Ihr später immer mehr Poller, Pinger und andere Zabbix-Prozesse startet müsst Ihr auch die Anzahl der möglichen Verbindungen zu MySQL Datenbank erhöhen.
Auch jeder Nutzer der auf dem Webinterface arbeitet verbraucht Verbindungen. Im zabbix_server.log steht dann eine Meldung mit "too many connection".

Sucht die Zeile

#max_connections        = 100

und ändert diese auf

max_connections        = 300


Damit nach einen Upgrade das Fehlerlogging weiter funktioniert entfernt das Kommentarzeichen auch in der folgenden Zeile: log_error = /var/log/mysql/error.log also das # am Anfang entfernen
Den Ordner für das Log anlegen und den Besitzer setzen:

mkdir /var/log/mysql
chown -R mysql:mysql /var/log/mysql

Nun müssen wir den mysql Server einmal neu starten:

systemctl restart mariadb.service


Ob Ihr alles richtig gemacht habt könnt Ihr im Log kontrollieren:

cat /var/log/mysql/error.log

Die Ausgabe sollte dann etwa so aussehen:

2024-06-10 14:36:36 0 [Note] Starting MariaDB 10.11.7-MariaDB-2ubuntu2 source revision  as process 18765
2024-06-10 14:36:36 0 [Note] InnoDB: Compressed tables use zlib 1.3
2024-06-10 14:36:36 0 [Note] InnoDB: Number of transaction pools: 1
2024-06-10 14:36:36 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
2024-06-10 14:36:36 0 [Note] InnoDB: Using liburing
2024-06-10 14:36:36 0 [Note] InnoDB: Initializing buffer pool, total size = 4.000GiB, chunk size = 64.000MiB
2024-06-10 14:36:36 0 [Note] InnoDB: Initialized memory pressure event listener
2024-06-10 14:36:36 0 [Note] InnoDB: Completed initialization of buffer pool
2024-06-10 14:36:36 0 [Note] InnoDB: Buffered log writes (block size=512 bytes)
2024-06-10 14:36:37 0 [Note] InnoDB: End of log at LSN=47108
2024-06-10 14:36:37 0 [Note] InnoDB: 128 rollback segments are active.
2024-06-10 14:36:37 0 [Note] InnoDB: Setting file './ibtmp1' size to 12.000MiB. Physically writing the file full; Please wait ...
2024-06-10 14:36:37 0 [Note] InnoDB: File './ibtmp1' size is now 12.000MiB.
2024-06-10 14:36:37 0 [Note] InnoDB: log sequence number 47108; transaction id 16
2024-06-10 14:36:37 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2024-06-10 14:36:37 0 [Note] Plugin 'FEEDBACK' is disabled.
2024-06-10 14:36:37 0 [Warning] You need to use --log-bin to make --expire-logs-days or --binlog-expire-logs-seconds work.
2024-06-10 14:36:37 0 [Note] Server socket created on IP: '127.0.0.1'.
2024-06-10 14:36:37 0 [Note] InnoDB: Buffer pool(s) load completed at 240610 14:36:37
2024-06-10 14:36:37 0 [Note] /usr/sbin/mariadbd: ready for connections.
Version: '10.11.7-MariaDB-2ubuntu2'  socket: '/run/mysqld/mysqld.sock'  port: 3306  Ubuntu 24.04

Wichtig ist immer die Zeile mit dem Socket und Port (hier die vorletzte) - da muss der Port auftauchen auf dem der Server lauscht, in der Regel 3306



MariaDB/MySQL Datenbank erstellen und einrichten

  • Zabbix Datenbank anlegen: (ab Zabbix 6.0)
mysql -u root -e "create database zabbix character set utf8mb4 collate utf8mb4_bin"
mysql -u root -e "create user 'zabbix'@'localhost' identified by 'zabbix'"
mysql -u root -e "grant all privileges on zabbix.* to 'zabbix'@'localhost'"
mysql -u root -e "SET GLOBAL log_bin_trust_function_creators = 1"

Die Datenbank heißt zabbix, der Datenbankbenutzer "zabbix" mit dem Passwort "zabbix" - wenn er also nach einem Passwort fragt nun dieses eingeben. Falls das jemand für unsicher hält - nun der MySQL Server sollte - wenn man es nicht ändert - eh nur lokale Anfragen erlauben, sprich von extern komme ich gar nicht ran.
Aber selbstverständlich könnt Ihr ein entsprechendes Passwort setzen, Ihr müsst dies nur im weiteren Verlauf der Anleitung beachten:

  • beim dem Anlegen des Benutzers setzt Ihr euer Passwort bei identified by 'zabbix'" ein (das zabbix durch euer Passwort ersetzen
  • Nachfolgend immer wenn es -pzabbix wieder das Wort zabbix durch euer Passwort ersetzen oder aber einfach nur -p angeben - dann fragt er jedes mal nach
Important.png
Hinweis: Hinschauen! Hier folgen 2 unterschiedliche Wege für Server oder Proxy!


Button Zabbix SERVER.png Bei einem Server:
Ab Version 6.0

zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -pzabbix zabbix


Button Zabbix PROXY.png Bei einem Proxy: Auf einem Proxy darf nur die schema.sql importiert werden!!!!
Solltet Ihr aus versehen alle Schema importiert haben so löscht die Datenbank noch einmal und fangt von vorne an! Der Proxy funktioniert nicht wenn er alle Schemas hat!

Ab Version 6.0

cat /usr/share/zabbix-sql-scripts/mysql/proxy.sql | mysql --default-character-set=utf8mb4 -uzabbix -pzabbix zabbix

Konfigurationsdateien anpassen

Nun die Konfigurationsdatei bearbeiten:

Button Zabbix SERVER.png für einen Server:

nano /etc/zabbix/zabbix_server.conf
  • folgende Zeilen finden und auf diese Werte ändern, ggf. den # davor entfernen, STRG + W ist suchen!
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix

LogSlowQueries=20000

StartIPMIPollers=1
StartPollersUnreachable=5
StartPingers=10
StartVMwareCollectors=5

#Die Cache Werte ggf. dem vorhandenen Arbeitsspeicher anpassen!
#Oder nicht ändern - Zabbix warnt euch wenn ein Wert ausgeschöpft ist und vergrößert werden muss - wenn das Template "Zabbix Server" zugeordnet wurde
VMwareCacheSize=64M
CacheSize=128M
HistoryCacheSize=64M
HistoryIndexCacheSize=16M
TrendCacheSize=64M
TrendFunctionCacheSize=64M
ValueCacheSize=64M

Timeout=30

# Problem mit fping6 beheben (ja, richtig, nichts hinter dem = Zeichen!)
Fping6Location=

Hier klicken (Toggle) für die ganze zabbix_server.conf
# This is a configuration file for Zabbix server daemon
# To get more information about Zabbix, visit https://www.zabbix.com

############ GENERAL PARAMETERS #################

### Option: ListenPort
#       Listen port for trapper.
#
# Mandatory: no
# Range: 1024-32767
# Default:
# ListenPort=10051

### Option: SourceIP
#       Source IP address for outgoing connections.
#
# Mandatory: no
# Default:
# SourceIP=

### Option: LogType
#       Specifies where log messages are written to:
#               system  - syslog
#               file    - file specified with LogFile parameter
#               console - standard output
#
# Mandatory: no
# Default:
# LogType=file

### Option: LogFile
#       Log file name for LogType 'file' parameter.
#
# Mandatory: yes, if LogType is set to file, otherwise no
# Default:
# LogFile=

LogFile=/var/log/zabbix/zabbix_server.log

### Option: LogFileSize
#       Maximum size of log file in MB.
#       0 - disable automatic log rotation.
#
# Mandatory: no
# Range: 0-1024
# Default:
# LogFileSize=1

LogFileSize=0

### Option: DebugLevel
#       Specifies debug level:
#       0 - basic information about starting and stopping of Zabbix processes
#       1 - critical information
#       2 - error information
#       3 - warnings
#       4 - for debugging (produces lots of information)
#       5 - extended debugging (produces even more information)
#
# Mandatory: no
# Range: 0-5
# Default:
# DebugLevel=3

### Option: PidFile
#       Name of PID file.
#
# Mandatory: no
# Default:
# PidFile=/tmp/zabbix_server.pid

PidFile=/run/zabbix/zabbix_server.pid

### Option: SocketDir
#       IPC socket directory.
#               Directory to store IPC sockets used by internal Zabbix services.
#
# Mandatory: no
# Default:
# SocketDir=/tmp

SocketDir=/run/zabbix

### NOTE: Support for Oracle DB is deprecated since Zabbix 7.0 and will be removed in future versions.

### Option: DBHost
#       Database host name.
#       If set to localhost, socket is used for MySQL.
#       If set to empty string, socket is used for PostgreSQL.
#       If set to empty string, the Net Service Name connection method is used to connect to Oracle database; also see
#       the TNS_ADMIN environment variable to specify the directory where the tnsnames.ora file is located.
#
# Mandatory: no
# Default:
DBHost=localhost

### Option: DBName
#       Database name.
#       If the Net Service Name connection method is used to connect to Oracle database, specify the service name from
#       the tnsnames.ora file or set to empty string; also see the TWO_TASK environment variable if DBName is set to
#       empty string.
#
# Mandatory: yes
# Default:
# DBName=

DBName=zabbix

### Option: DBSchema
#       Schema name. Used for PostgreSQL.
#
# Mandatory: no
# Default:
# DBSchema=

### Option: DBUser
#       Database user.
#
# Mandatory: no
# Default:
# DBUser=

DBUser=zabbix

### Option: DBPassword
#       Database password.
#       Comment this line if no password is used.
#
# Mandatory: no
# Default:
DBPassword=zabbix

### Option: DBSocket
#       Path to MySQL socket.
#
# Mandatory: no
# Default:
# DBSocket=

### Option: DBPort
#       Database port when not using local socket.
#       If the Net Service Name connection method is used to connect to Oracle database, the port number from the
#       tnsnames.ora file will be used. The port number set here will be ignored.
#
# Mandatory: no
# Range: 1024-65535
# Default:
# DBPort=

### Option: AllowUnsupportedDBVersions
#       Allow server to work with unsupported database versions.
#       0 - do not allow
#       1 - allow
#
# Mandatory: no
# Default:
# AllowUnsupportedDBVersions=0

### Option: HistoryStorageURL
#       History storage HTTP[S] URL.
#
# Mandatory: no
# Default:
# HistoryStorageURL=

### Option: HistoryStorageTypes
#       Comma separated list of value types to be sent to the history storage.
#
# Mandatory: no
# Default:
# HistoryStorageTypes=uint,dbl,str,log,text

### Option: HistoryStorageDateIndex
#       Enable preprocessing of history values in history storage to store values in different indices based on date.
#       0 - disable
#       1 - enable
#
# Mandatory: no
# Default:
# HistoryStorageDateIndex=0

### Option: ExportDir
#       Directory for real time export of events, history and trends in newline delimited JSON format.
#       If set, enables real time export.
#
# Mandatory: no
# Default:
# ExportDir=

### Option: ExportFileSize
#       Maximum size per export file in bytes.
#       Only used for rotation if ExportDir is set.
#
# Mandatory: no
# Range: 1M-1G
# Default:
# ExportFileSize=1G

### Option: ExportType
#       List of comma delimited types of real time export - allows to control export entities by their
#       type (events, history, trends) individually.
#       Valid only if ExportDir is set.
#
# Mandatory: no
# Default:
# ExportType=events,history,trends

############ ADVANCED PARAMETERS ################

### Option: StartPollers
#       Number of pre-forked instances of pollers.
#
# Mandatory: no
# Range: 0-1000
# Default:
# StartPollers=5

### Option: StartAgentPollers
#       Number of pre-forked instances of asynchronous Zabbix agent pollers. Also see MaxConcurrentChecksPerPoller.
#
# Mandatory: no
# Range: 0-1000
# Default:
# StartAgentPollers=1

### Option: StartHTTPAgentPollers
#       Number of pre-forked instances of asynchronous HTTP agent pollers. Also see MaxConcurrentChecksPerPoller.
#
# Mandatory: no
# Range: 0-1000
# Default:
# StartHTTPAgentPollers=1

### Option: StartSNMPPollers
#       Number of pre-forked instances of asynchronous SNMP pollers. Also see MaxConcurrentChecksPerPoller.
#
# Mandatory: no
# Range: 0-1000
# Default:
# StartSNMPPollers=1

### Option: MaxConcurrentChecksPerPoller
#       Maximum number of asynchronous checks that can be executed at once by each HTTP agent poller or agent poller.
#
# Mandatory: no
# Range: 1-1000
# Default:
# MaxConcurrentChecksPerPoller=1000

### Option: StartIPMIPollers
#       Number of pre-forked instances of IPMI pollers.
#               The IPMI manager process is automatically started when at least one IPMI poller is started.
#
# Mandatory: no
# Range: 0-1000
# Default:
# StartIPMIPollers=0
StartIPMIPollers=1


### Option: StartPreprocessors
#       Number of pre-started instances of preprocessing workers.
#
# Mandatory: no
# Range: 1-1000
# Default:
# StartPreprocessors=3

### Option: StartConnectors
#       Number of pre-forked instances of connector workers.
#               The connector manager process is automatically started when connector worker is started.
#
# Mandatory: no
# Range: 0-1000
# Default:
# StartConnectors=0

### Option: StartPollersUnreachable
#       Number of pre-forked instances of pollers for unreachable hosts (including IPMI and Java).
#       At least one poller for unreachable hosts must be running if regular, IPMI or Java pollers
#       are started.
#
# Mandatory: no
# Range: 0-1000
# Default:
# StartPollersUnreachable=1
StartPollersUnreachable=10

### Option: StartHistoryPollers
#       Number of pre-forked instances of history pollers.
#       Only required for calculated checks.
#       A database connection is required for each history poller instance.
#
# Mandatory: no
# Range: 0-1000
# Default:
# StartHistoryPollers=5

### Option: StartTrappers
#       Number of pre-forked instances of trappers.
#       Trappers accept incoming connections from Zabbix sender, active agents and active proxies.
#       At least one trapper process must be running to display server availability and view queue
#       in the frontend.
#
# Mandatory: no
# Range: 0-1000
# Default:
# StartTrappers=5

### Option: StartPingers
#       Number of pre-forked instances of ICMP pingers.
#
# Mandatory: no
# Range: 0-1000
# Default:
# StartPingers=1
StartPingers=10

### Option: StartDiscoverers
#       Number of pre-started instances of discovery workers.
#
# Mandatory: no
# Range: 0-1000
# Default:
# StartDiscoverers=5

### Option: StartHTTPPollers
#       Number of pre-forked instances of HTTP pollers.
#
# Mandatory: no
# Range: 0-1000
# Default:
# StartHTTPPollers=1

### Option: StartTimers
#       Number of pre-forked instances of timers.
#       Timers process maintenance periods.
#       Only the first timer process handles host maintenance updates. Problem suppression updates are shared
#       between all timers.
#
# Mandatory: no
# Range: 1-1000
# Default:
# StartTimers=1

### Option: StartEscalators
#       Number of pre-forked instances of escalators.
#
# Mandatory: no
# Range: 1-100
# Default:
# StartEscalators=1

### Option: StartAlerters
#       Number of pre-forked instances of alerters.
#       Alerters send the notifications created by action operations.
#
# Mandatory: no
# Range: 1-100
# Default:
# StartAlerters=3

### Option: JavaGateway
#       IP address (or hostname) of Zabbix Java gateway.
#       Only required if Java pollers are started.
#
# Mandatory: no
# Default:
# JavaGateway=

### Option: JavaGatewayPort
#       Port that Zabbix Java gateway listens on.
#
# Mandatory: no
# Range: 1024-32767
# Default:
# JavaGatewayPort=10052

### Option: StartJavaPollers
#       Number of pre-forked instances of Java pollers.
#
# Mandatory: no
# Range: 0-1000
# Default:
# StartJavaPollers=0

### Option: StartVMwareCollectors
#       Number of pre-forked vmware collector instances.
#
# Mandatory: no
# Range: 0-250
# Default:
# StartVMwareCollectors=0
 StartVMwareCollectors=5

### Option: VMwareFrequency
#       How often Zabbix will connect to VMware service to obtain a new data.
#
# Mandatory: no
# Range: 10-86400
# Default:
# VMwareFrequency=60

### Option: VMwarePerfFrequency
#       How often Zabbix will connect to VMware service to obtain performance data.
#
# Mandatory: no
# Range: 10-86400
# Default:
# VMwarePerfFrequency=60

### Option: VMwareCacheSize
#       Size of VMware cache, in bytes.
#       Shared memory size for storing VMware data.
#       Only used if VMware collectors are started.
#
# Mandatory: no
# Range: 256K-2G
# Default:
# VMwareCacheSize=8M
VMwareCacheSize=64M

### Option: VMwareTimeout
#       Specifies how many seconds vmware collector waits for response from VMware service.
#
# Mandatory: no
# Range: 1-300
# Default:
# VMwareTimeout=10

### Option: SNMPTrapperFile
#       Temporary file used for passing data from SNMP trap daemon to the server.
#       Must be the same as in zabbix_trap_receiver.pl or SNMPTT configuration file.
#
# Mandatory: no
# Default:
# SNMPTrapperFile=/tmp/zabbix_traps.tmp

SNMPTrapperFile=/var/log/snmptrap/snmptrap.log

### Option: StartSNMPTrapper
#       If 1, SNMP trapper process is started.
#
# Mandatory: no
# Range: 0-1
# Default:
# StartSNMPTrapper=0

### Option: ListenIP
#       List of comma delimited IP addresses that the trapper should listen on.
#       Trapper will listen on all network interfaces if this parameter is missing.
#
# Mandatory: no
# Default:
# ListenIP=0.0.0.0

### Option: HousekeepingFrequency
#       How often Zabbix will perform housekeeping procedure (in hours).
#       Housekeeping is removing outdated information from the database.
#       To prevent Housekeeper from being overloaded, no more than 4 times HousekeepingFrequency
#       hours of outdated information are deleted in one housekeeping cycle, for each item.
#       To lower load on server startup housekeeping is postponed for 30 minutes after server start.
#       With HousekeepingFrequency=0 the housekeeper can be only executed using the runtime control option.
#       In this case the period of outdated information deleted in one housekeeping cycle is 4 times the
#       period since the last housekeeping cycle, but not less than 4 hours and not greater than 4 days.
#
# Mandatory: no
# Range: 0-24
# Default:
# HousekeepingFrequency=1

### Option: MaxHousekeeperDelete
#       The table "housekeeper" contains "tasks" for housekeeping procedure in the format:
#       [housekeeperid], [tablename], [field], [value].
#       No more than 'MaxHousekeeperDelete' rows (corresponding to [tablename], [field], [value])
#       will be deleted per one task in one housekeeping cycle.
#       If set to 0 then no limit is used at all. In this case you must know what you are doing!
#
# Mandatory: no
# Range: 0-1000000
# Default:
# MaxHousekeeperDelete=5000

### Option: CacheSize
#       Size of configuration cache, in bytes.
#       Shared memory size for storing host, item and trigger data.
#
# Mandatory: no
# Range: 128K-64G
# Default:
# CacheSize=32M
CacheSize=128M

### Option: CacheUpdateFrequency
#       How often Zabbix will perform update of configuration cache, in seconds.
#
# Mandatory: no
# Range: 1-3600
# Default:
# CacheUpdateFrequency=10

### Option: StartDBSyncers
#       Number of pre-forked instances of DB Syncers.
#
# Mandatory: no
# Range: 1-100
# Default:
# StartDBSyncers=4

### Option: HistoryCacheSize
#       Size of history cache, in bytes.
#       Shared memory size for storing history data.
#
# Mandatory: no
# Range: 128K-2G
# Default:
# HistoryCacheSize=16M
HistoryCacheSize=64M

### Option: HistoryIndexCacheSize
#       Size of history index cache, in bytes.
#       Shared memory size for indexing history cache.
#
# Mandatory: no
# Range: 128K-2G
# Default:
# HistoryIndexCacheSize=4M
HistoryIndexCacheSize=16M

### Option: TrendCacheSize
#       Size of trend write cache, in bytes.
#       Shared memory size for storing trends data.
#
# Mandatory: no
# Range: 128K-2G
# Default:
# TrendCacheSize=4M
TrendCacheSize=64M

### Option: TrendFunctionCacheSize
#       Size of trend function cache, in bytes.
#       Shared memory size for caching calculated trend function data.
#
# Mandatory: no
# Range: 128K-2G
# Default:
# TrendFunctionCacheSize=4M
TrendFunctionCacheSize=64M

### Option: ValueCacheSize
#       Size of history value cache, in bytes.
#       Shared memory size for caching item history data requests.
#       Setting to 0 disables value cache.
#
# Mandatory: no
# Range: 0,128K-64G
# Default:
# ValueCacheSize=8M
ValueCacheSize=64M

### Option: Timeout
#       Specifies timeout for communications (in seconds).
#
# Mandatory: no
# Range: 1-30
# Default:
# Timeout=3

Timeout=30

### Option: TrapperTimeout
#       Specifies how many seconds trapper may spend processing new data.
#
# Mandatory: no
# Range: 1-300
# Default:
# TrapperTimeout=300

### Option: UnreachablePeriod
#       After how many seconds of unreachability treat a host as unavailable.
#
# Mandatory: no
# Range: 1-3600
# Default:
# UnreachablePeriod=45

### Option: UnavailableDelay
#       How often host is checked for availability during the unavailability period, in seconds.
#
# Mandatory: no
# Range: 1-3600
# Default:
# UnavailableDelay=60

### Option: UnreachableDelay
#       How often host is checked for availability during the unreachability period, in seconds.
#
# Mandatory: no
# Range: 1-3600
# Default:
# UnreachableDelay=15

### Option: AlertScriptsPath
#       Full path to location of custom alert scripts.
#       Default depends on compilation options.
#       To see the default path run command "zabbix_server --help".
#
# Mandatory: no
# Default:
# AlertScriptsPath=/usr/lib/zabbix/alertscripts

### Option: ExternalScripts
#       Full path to location of external scripts.
#       Default depends on compilation options.
#       To see the default path run command "zabbix_server --help".
#
# Mandatory: no
# Default:
# ExternalScripts=/usr/lib/zabbix/externalscripts

### Option: FpingLocation
#       Location of fping.
#       Make sure that fping binary has root ownership and SUID flag set.
#
# Mandatory: no
# Default:
# FpingLocation=/usr/sbin/fping

FpingLocation=/usr/bin/fping

### Option: Fping6Location
#       Location of fping6.
#       Make sure that fping6 binary has root ownership and SUID flag set.
#       Make empty if your fping utility is capable to process IPv6 addresses.
#
# Mandatory: no
# Default:
# Fping6Location=/usr/sbin/fping6

Fping6Location=

### Option: SSHKeyLocation
#       Location of public and private keys for SSH checks and actions.
#
# Mandatory: no
# Default:
# SSHKeyLocation=

### Option: LogSlowQueries
#       How long a database query may take before being logged (in milliseconds).
#       Only works if DebugLevel set to 3, 4 or 5.
#       0 - don't log slow queries.
#
# Mandatory: no
# Range: 1-3600000
# Default:
# LogSlowQueries=0

LogSlowQueries=20000

### Option: TmpDir
#       Temporary directory.
#
# Mandatory: no
# Default:
# TmpDir=/tmp

### Option: StartProxyPollers
#       Number of pre-forked instances of pollers for passive proxies.
#
# Mandatory: no
# Range: 0-250
# Default:
# StartProxyPollers=1

### Option: ProxyConfigFrequency
#       How often Zabbix Server sends configuration data to a Zabbix Proxy in seconds.
#       This parameter is used only for proxies in the passive mode.
#
# Mandatory: no
# Range: 1-3600*24*7
# Default:
# ProxyConfigFrequency=10

### Option: ProxyDataFrequency
#       How often Zabbix Server requests history data from a Zabbix Proxy in seconds.
#       This parameter is used only for proxies in the passive mode.
#
# Mandatory: no
# Range: 1-3600
# Default:
# ProxyDataFrequency=1

### Option: StartLLDProcessors
#       Number of pre-forked instances of low level discovery processors.
#
# Mandatory: no
# Range: 1-100
# Default:
# StartLLDProcessors=2

### Option: AllowRoot
#       Allow the server to run as 'root'. If disabled and the server is started by 'root', the server
#       will try to switch to the user specified by the User configuration option instead.
#       Has no effect if started under a regular user.
#       0 - do not allow
#       1 - allow
#
# Mandatory: no
# Default:
# AllowRoot=0

### Option: User
#       Drop privileges to a specific, existing user on the system.
#       Only has effect if run as 'root' and AllowRoot is disabled.
#
# Mandatory: no
# Default:
# User=zabbix

### Option: Include
#       You may include individual files or all files in a directory in the configuration file.
#       Installing Zabbix will create include directory in /usr/local/etc, unless modified during the compile time.
#
# Mandatory: no
# Default:
# Include=

# Include=/usr/local/etc/zabbix_server.general.conf
# Include=/usr/local/etc/zabbix_server.conf.d/
# Include=/usr/local/etc/zabbix_server.conf.d/*.conf

### Option: SSLCertLocation
#       Location of SSL client certificates.
#       This parameter is used in web monitoring and for communication with Vault.
#       Default depends on compilation options.
#       To see the default path run command "zabbix_server --help".
#
# Mandatory: no
# Default:
# SSLCertLocation=${datadir}/zabbix/ssl/certs

### Option: SSLKeyLocation
#       Location of private keys for SSL client certificates.
#       This parameter is used in web monitoring and for communication with Vault.
#       Default depends on compilation options.
#       To see the default path run command "zabbix_server --help".
#
# Mandatory: no
# Default:
# SSLKeyLocation=${datadir}/zabbix/ssl/keys

### Option: SSLCALocation
#       Override the location of certificate authority (CA) files for SSL server certificate verification.
#       If not set, system-wide directory will be used.
#       This parameter is used in web monitoring, SMTP authentication, HTTP agent items and for communication with Vault.
#
# Mandatory: no
# Default:
# SSLCALocation=

### Option: StatsAllowedIP
#       List of comma delimited IP addresses, optionally in CIDR notation, or DNS names of external Zabbix instances.
#       Stats request will be accepted only from the addresses listed here. If this parameter is not set no stats requests
#       will be accepted.
#       If IPv6 support is enabled then '127.0.0.1', '::127.0.0.1', '::ffff:127.0.0.1' are treated equally
#       and '::/0' will allow any IPv4 or IPv6 address.
#       '0.0.0.0/0' can be used to allow any IPv4 address.
#       Example: StatsAllowedIP=127.0.0.1,192.168.1.0/24,::1,2001:db8::/32,zabbix.example.com
#
# Mandatory: no
# Default:
# StatsAllowedIP=
StatsAllowedIP=127.0.0.1

####### LOADABLE MODULES #######

### Option: LoadModulePath
#       Full path to location of server modules.
#       Default depends on compilation options.
#       To see the default path run command "zabbix_server --help".
#
# Mandatory: no
# Default:
# LoadModulePath=${libdir}/modules

### Option: LoadModule
#       Module to load at server startup. Modules are used to extend functionality of the server.
#       Formats:
#               LoadModule=<module.so>
#               LoadModule=<path/module.so>
#               LoadModule=</abs_path/module.so>
#       Either the module must be located in directory specified by LoadModulePath or the path must precede the module name.
#       If the preceding path is absolute (starts with '/') then LoadModulePath is ignored.
#       It is allowed to include multiple LoadModule parameters.
#
# Mandatory: no
# Default:
# LoadModule=

####### TLS-RELATED PARAMETERS #######

### Option: TLSCAFile
#       Full pathname of a file containing the top-level CA(s) certificates for
#       peer certificate verification.
#
# Mandatory: no
# Default:
# TLSCAFile=

### Option: TLSCRLFile
#       Full pathname of a file containing revoked certificates.
#
# Mandatory: no
# Default:
# TLSCRLFile=

### Option: TLSCertFile
#       Full pathname of a file containing the server certificate or certificate chain.
#
# Mandatory: no
# Default:
# TLSCertFile=

### Option: TLSKeyFile
#       Full pathname of a file containing the server private key.
#
# Mandatory: no
# Default:
# TLSKeyFile=

####### For advanced users - TLS ciphersuite selection criteria #######

### Option: TLSCipherCert13
#       Cipher string for OpenSSL 1.1.1 or newer in TLS 1.3.
#       Override the default ciphersuite selection criteria for certificate-based encryption.
#
# Mandatory: no
# Default:
# TLSCipherCert13=

### Option: TLSCipherCert
#       GnuTLS priority string or OpenSSL (TLS 1.2) cipher string.
#       Override the default ciphersuite selection criteria for certificate-based encryption.
#       Example for GnuTLS:
#               NONE:+VERS-TLS1.2:+ECDHE-RSA:+RSA:+AES-128-GCM:+AES-128-CBC:+AEAD:+SHA256:+SHA1:+CURVE-ALL:+COMP-NULL:+SIGN-ALL:+CTYPE-X.509
#       Example for OpenSSL:
#               EECDH+aRSA+AES128:RSA+aRSA+AES128
#
# Mandatory: no
# Default:
# TLSCipherCert=

### Option: TLSCipherPSK13
#       Cipher string for OpenSSL 1.1.1 or newer in TLS 1.3.
#       Override the default ciphersuite selection criteria for PSK-based encryption.
#       Example:
#               TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256
#
# Mandatory: no
# Default:
# TLSCipherPSK13=

### Option: TLSCipherPSK
#       GnuTLS priority string or OpenSSL (TLS 1.2) cipher string.
#       Override the default ciphersuite selection criteria for PSK-based encryption.
#       Example for GnuTLS:
#               NONE:+VERS-TLS1.2:+ECDHE-PSK:+PSK:+AES-128-GCM:+AES-128-CBC:+AEAD:+SHA256:+SHA1:+CURVE-ALL:+COMP-NULL:+SIGN-ALL
#       Example for OpenSSL:
#               kECDHEPSK+AES128:kPSK+AES128
#
# Mandatory: no
# Default:
# TLSCipherPSK=

### Option: TLSCipherAll13
#       Cipher string for OpenSSL 1.1.1 or newer in TLS 1.3.
#       Override the default ciphersuite selection criteria for certificate- and PSK-based encryption.
#       Example:
#               TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256
#
# Mandatory: no
# Default:
# TLSCipherAll13=

### Option: TLSCipherAll
#       GnuTLS priority string or OpenSSL (TLS 1.2) cipher string.
#       Override the default ciphersuite selection criteria for certificate- and PSK-based encryption.
#       Example for GnuTLS:
#               NONE:+VERS-TLS1.2:+ECDHE-RSA:+RSA:+ECDHE-PSK:+PSK:+AES-128-GCM:+AES-128-CBC:+AEAD:+SHA256:+SHA1:+CURVE-ALL:+COMP-NULL:+SIGN-ALL:+CTYPE-X.509
#       Example for OpenSSL:
#               EECDH+aRSA+AES128:RSA+aRSA+AES128:kECDHEPSK+AES128:kPSK+AES128
#
# Mandatory: no
# Default:
# TLSCipherAll=

### Option: DBTLSConnect
#       Setting this option enforces to use TLS connection to database.
#       required    - connect using TLS
#       verify_ca   - connect using TLS and verify certificate
#       verify_full - connect using TLS, verify certificate and verify that database identity specified by DBHost
#                     matches its certificate
#       On MySQL starting from 5.7.11 and PostgreSQL following values are supported: "required", "verify_ca" and
#       "verify_full".
#       On MariaDB starting from version 10.2.6 "required" and "verify_full" values are supported.
#       Default is not to set any option and behavior depends on database configuration
#
# Mandatory: no
# Default:
# DBTLSConnect=

### Option: DBTLSCAFile
#       Full pathname of a file containing the top-level CA(s) certificates for database certificate verification.
#       Supported only for MySQL and PostgreSQL
#
# Mandatory: no
#       (yes, if DBTLSConnect set to one of: verify_ca, verify_full)
# Default:
# DBTLSCAFile=

### Option: DBTLSCertFile
#       Full pathname of file containing Zabbix server certificate for authenticating to database.
#       Supported only for MySQL and PostgreSQL
#
# Mandatory: no
# Default:
# DBTLSCertFile=

### Option: DBTLSKeyFile
#       Full pathname of file containing the private key for authenticating to database.
#       Supported only for MySQL and PostgreSQL
#
# Mandatory: no
# Default:
# DBTLSKeyFile=

### Option: DBTLSCipher
#       The list of encryption ciphers that Zabbix server permits for TLS protocols up through TLSv1.2
#       Supported only for MySQL
#
# Mandatory no
# Default:
# DBTLSCipher=

### Option: DBTLSCipher13
#       The list of encryption ciphersuites that Zabbix server permits for TLSv1.3 protocol
#       Supported only for MySQL, starting from version 8.0.16
#
# Mandatory no
# Default:
# DBTLSCipher13=

### Option: Vault
#       Specifies vault:
#               HashiCorp - HashiCorp KV Secrets Engine - Version 2
#               CyberArk  - CyberArk Central Credential Provider
#
# Mandatory: no
# Default:
# Vault=HashiCorp

### Option: VaultToken
#       Vault authentication token that should have been generated exclusively for Zabbix server with read only permission
#       to paths specified in Vault macros and read only permission to path specified in optional VaultDBPath
#       configuration parameter.
#       It is an error if VaultToken and VAULT_TOKEN environment variable are defined at the same time.
#
# Mandatory: no
#       (yes, if Vault is explicitly set to HashiCorp)
# Default:
# VaultToken=

### Option: VaultURL
#       Vault server HTTP[S] URL. System-wide CA certificates directory will be used if SSLCALocation is not specified.
#
# Mandatory: no
# Default:
# VaultURL=https://127.0.0.1:8200

### Option: VaultPrefix
#       Custom prefix for Vault path or query depending on the Vault.
#       Most suitable defaults will be used if not specified.
#       Note that 'data' is automatically appended after mountpoint for HashiCorp if VaultPrefix is not specified.
#       Example prefix for HashiCorp:
#               /v1/secret/data/
#       Example prefix for CyberArk:
#               /AIMWebService/api/Accounts?
# Mandatory: no
# Default:
# VaultPrefix=

### Option: VaultDBPath
#       Vault path or query depending on the Vault from where credentials for database will be retrieved by keys.
#       Keys used for HashiCorp are 'password' and 'username'.
#       Example path:
#               secret/zabbix/database
#       Keys used for CyberArk are 'Content' and 'UserName'.
#       Example query:
#               AppID=zabbix_server&Query=Safe=passwordSafe;Object=zabbix_server_database
#       This option can only be used if DBUser and DBPassword are not specified.
#
# Mandatory: no
# Default:
# VaultDBPath=

### Option: VaultTLSCertFile
#       Name of the SSL certificate file used for client authentication. The certificate file must be in PEM1 format.
#       If the certificate file contains also the private key, leave the SSL key file field empty. The directory
#       containing this file is specified by configuration parameter SSLCertLocation.
#
# Mandatory: no
# Default:
# VaultTLSCertFile=

### Option: VaultTLSKeyFile
#       Name of the SSL private key file used for client authentication. The private key file must be in PEM1 format.
#       The directory containing this file is specified by configuration parameter SSLKeyLocation.
#
# Mandatory: no
# Default:
# VaultTLSKeyFile=

### Option: StartReportWriters
#       Number of pre-forked report writer instances.
#
# Mandatory: no
# Range: 0-100
# Default:
# StartReportWriters=0

### Option: WebServiceURL
#       URL to Zabbix web service, used to perform web related tasks.
#       Example: http://localhost:10053/report
#
# Mandatory: no
# Default:
# WebServiceURL=

### Option: ServiceManagerSyncFrequency
#       How often Zabbix will synchronize configuration of a service manager (in seconds).
#
# Mandatory: no
# Range: 1-3600
# Default:
# ServiceManagerSyncFrequency=60

### Option: ProblemHousekeepingFrequency
#       How often Zabbix will delete problems for deleted triggers (in seconds).
#
# Mandatory: no
# Range: 1-3600
# Default:
# ProblemHousekeepingFrequency=60

## Option: StartODBCPollers
#       Number of pre-forked ODBC poller instances.
#
# Mandatory: no
# Range: 0-1000
# Default:
# StartODBCPollers=1

### Option: EnableGlobalScripts
#    Enable global scripts on Zabbix server.
#       0 - disable
#       1 - enable
#
# Mandatory: no
# Default:
# EnableGlobalScripts=1
EnableGlobalScripts=0

# Option: AllowSoftwareUpdateCheck
#       Allow Zabbix UI to receive information about software updates from zabbix.com
#       0 - disable software update checks
#       1 - enable software update checks
#
# Mandatory: no
# Default:
# AllowSoftwareUpdateCheck=1

### Option: SMSDevices
#       List of comma delimited modem files allowed to use Zabbix server
#       SMS sending not possible if this parameter is not set
#       Example: SMSDevices=/dev/ttyUSB0,/dev/ttyUSB1
#
# Mandatory: no
# Default:
# SMSDevices=

####### For advanced users - TCP-related fine-tuning parameters #######

## Option: ListenBacklog
#       The maximum number of pending connections in the queue. This parameter is passed to
#       listen() function as argument 'backlog' (see "man listen").
#
# Mandatory: no
# Range: 0 - INT_MAX (depends on system, too large values may be silently truncated to implementation-specified maximum)
# Default: SOMAXCONN (hard-coded constant, depends on system)
# ListenBacklog=


####### High availability cluster parameters #######

## Option: HANodeName
#       The high availability cluster node name.
#       When empty, server is working in standalone mode; a node with empty name is registered with address for the frontend to connect to.
#
# Mandatory: no
# Default:
# HANodeName=

## Option: NodeAddress
#       IP or hostname with optional port to specify how frontend should connect to the server.
#       Format: <address>[:<port>]
#
#       If IP or hostname is not set, then ListenIP value will be used. In case ListenIP is not set, localhost will be used.
#       If port is not set, then ListenPort value will be used. In case ListenPort is not set, 10051 will be used.
#       This option can be overridden by address specified in frontend configuration.
#
# Mandatory: no
# Default:
# NodeAddress=localhost:10051

####### Browser monitoring #######

### Option: WebDriverURL
#       WebDriver interface HTTP[S] URL. For example http://localhost:4444 used with Selenium WebDriver standalone server.
#
# Mandatory: no
# Default:
# WebDriverURL=

### Option: StartBrowserPollers
#       Number of pre-forked instances of browser item pollers.
#
# Mandatory: no
# Range: 0-1000
# Default:
# StartBrowserPollers=1



Button Zabbix PROXY.png Bei einem Proxy:

nano /etc/zabbix/zabbix_proxy.conf
  • folgende Zeilen finden und auf diese Werte ändern, ggf. den # davor entfernen, STRG + W ist suchen!
ProxyMode=0

#IP oder DNS Name des Zabbix-Servers an den gemeldet werden soll. Falls der Port nicht 10051 ist dann mit : dahinter setzen
Server=123.123.123.123     

# Hostname -> unter diesem Namen müssen wir den Proxy auch auf dem Hauptserver anlegen!
Hostname=zabbixproxy

DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix

EnableRemoteCommands=1

Timeout=30

StartVMwareCollectors=5
# Nachfolgend: Richtig, nichts darf hinter dem = stehen!
Fping6Location=



Important.png

Hinweis:Unter Ubuntu 24.04 istfping und fping6 das gleiche Programm. Die 6er Variante ist nur ein symbolischer Link auf die normale Version. Auf meinem Proxy zickte er deswegen rum (der hat eine IPv6 konfiguriert). Wenn den Eintrag wie zuvor beschrieben abändert geht es ohne Probleme.
Die Fehlermeldung die er bringt ist

Cannot detect the minimum interval of /usr/bin/fping6



Automatischen Start beim Booten einrichten

Die notwendigen Skripte werden bei der Installation aus den Repository direkt mit installiert, wir müssen diese nur noch aktivieren:
Button Zabbix SERVER.png Auf einem Server

systemctl enable zabbix-server.service




Button Zabbix PROXY.png Auf einem Proxy

systemctl enable zabbix-proxy.service




Button Zabbix AGENT.png und noch der Agent

systemctl enable zabbix-agent2.service




Start von Zabbix testen

Nun müsste man den Zabbix Server wie andere Dienste auch über systemctl starten können

systemctl start zabbix-server

Wenn alles in Ordnung ist gibt es keine Rückmeldung durch systemctl, also fragen wir nach dem Status:

systemctl status zabbix-server

Ausgabe:

● zabbix-server.service - Zabbix Server
     Loaded: loaded (/usr/lib/systemd/system/zabbix-server.service; enabled; preset: enabled)
     Active: active (running) since Mon 2024-06-10 14:53:01 CEST; 9s ago
    Process: 19072 ExecStart=/usr/sbin/zabbix_server -c $CONFFILE (code=exited, status=0/SUCCESS)
   Main PID: 19074 (zabbix_server)
      Tasks: 89 (limit: 9444)
     Memory: 78.1M (peak: 79.0M)
        CPU: 224ms
     CGroup: /system.slice/zabbix-server.service
             ├─19074 /usr/sbin/zabbix_server -c /etc/zabbix/zabbix_server.conf
             ├─19077 "/usr/sbin/zabbix_server: ha manager"
             ├─19078 "/usr/sbin/zabbix_server: service manager #1 [processed 0 events, updated 0 event tags, deleted 0 problems, synced 0 service updates, idle 5.005142 sec>
             ├─19079 "/usr/sbin/zabbix_server: configuration syncer [synced configuration in 0.135607 sec, idle 10 sec]"
             ├─19083 "/usr/sbin/zabbix_server: alert manager #1 [sent 0, failed 0 alerts, idle 5.042655 sec during 5.042817 sec]"
             ├─19084 "/usr/sbin/zabbix_server: alerter #1 started"
             ├─19085 "/usr/sbin/zabbix_server: alerter #2 started"
             ├─19086 "/usr/sbin/zabbix_server: alerter #3 started"
             ├─19087 "/usr/sbin/zabbix_server: preprocessing manager #1 [queued 1, processed 2 values, idle 5.337594 sec during 5.338002 sec]"
             ├─19088 "/usr/sbin/zabbix_server: lld manager #1 [processed 0 LLD rules, idle 5.006159sec during 5.006252 sec]"
             ├─19089 "/usr/sbin/zabbix_server: lld worker #1 started"
             ├─19090 "/usr/sbin/zabbix_server: lld worker #2 started"
             ├─19091 "/usr/sbin/zabbix_server: ipmi manager #1 [scheduled 0, polled 0 values, idle 5.015535 sec during 5.015640 sec]"
             ├─19093 "/usr/sbin/zabbix_server: housekeeper [startup idle for 30 minutes]"
             ├─19094 "/usr/sbin/zabbix_server: timer #1 [updated 0 hosts, suppressed 0 events in 0.001857 sec, idle 58 sec]"
             ├─19095 "/usr/sbin/zabbix_server: http poller #1 [got 0 values in 0.000041 sec, idle 5 sec]"
             ├─19097 "/usr/sbin/zabbix_server: browser poller #1 [got 0 values in 0.000025 sec, idle 5 sec]"
             ├─19099 "/usr/sbin/zabbix_server: discovery manager #1 [processing 0 rules, 0 unsaved checks]"
             ├─19100 "/usr/sbin/zabbix_server: history syncer #1 [processed 1 values, 1 triggers in 0.003581 sec, idle 1 sec]"
             ├─19101 "/usr/sbin/zabbix_server: history syncer #2 [processed 0 values, 0 triggers in 0.000027 sec, idle 1 sec]"
             ├─19102 "/usr/sbin/zabbix_server: history syncer #3 [processed 0 values, 0 triggers in 0.000015 sec, idle 1 sec]"
             ├─19110 "/usr/sbin/zabbix_server: history syncer #4 [processed 0 values, 0 triggers in 0.000008 sec, idle 1 sec]"
             ├─19113 "/usr/sbin/zabbix_server: escalator #1 [processed 0 escalations in 0.000793 sec, idle 3 sec]"
             ├─19114 "/usr/sbin/zabbix_server: ipmi poller #1 started"
             ├─19115 "/usr/sbin/zabbix_server: proxy poller #1 [exchanged data with 0 proxies in 0.000026 sec, idle 5 sec]"
             ├─19116 "/usr/sbin/zabbix_server: self-monitoring [processed data in 0.000019 sec, idle 1 sec]"
             ├─19117 "/usr/sbin/zabbix_server: vmware collector #1 [updated 0, removed 0 VMware services, idle 5.000000 sec during 5.000436 sec]"
             ├─19118 "/usr/sbin/zabbix_server: vmware collector #2 [updated 0, removed 0 VMware services, idle 5.000000 sec during 5.000354 sec]"
             ├─19119 "/usr/sbin/zabbix_server: vmware collector #3 [updated 0, removed 0 VMware services, idle 5.000000 sec during 5.000397 sec]"
             ├─19120 "/usr/sbin/zabbix_server: vmware collector #4 [updated 0, removed 0 VMware services, idle 5.000000 sec during 5.000504 sec]"
             ├─19123 "/usr/sbin/zabbix_server: vmware collector #5 [updated 0, removed 0 VMware services, idle 5.000000 sec during 5.000393 sec]"
             ├─19124 "/usr/sbin/zabbix_server: task manager [processed 0 task(s) in 0.001907 sec, idle 5 sec]"
             ├─19125 "/usr/sbin/zabbix_server: poller #1 [got 0 values in 0.000017 sec, idle 5 sec]"
             ├─19127 "/usr/sbin/zabbix_server: poller #2 [got 0 values in 0.000028 sec, idle 5 sec]"
             ├─19128 "/usr/sbin/zabbix_server: poller #3 [got 0 values in 0.000014 sec, idle 5 sec]"
             ├─19129 "/usr/sbin/zabbix_server: poller #4 [got 0 values in 0.000022 sec, idle 5 sec]"
             ├─19130 "/usr/sbin/zabbix_server: poller #5 [got 0 values in 0.000012 sec, idle 5 sec]"
             ├─19131 "/usr/sbin/zabbix_server: unreachable poller #1 [got 0 values in 0.000014 sec, idle 5 sec]"
             ├─19132 "/usr/sbin/zabbix_server: unreachable poller #2 [got 0 values in 0.000016 sec, idle 5 sec]"
             ├─19133 "/usr/sbin/zabbix_server: unreachable poller #3 [got 0 values in 0.000016 sec, idle 5 sec]"
             ├─19134 "/usr/sbin/zabbix_server: unreachable poller #4 [got 0 values in 0.000015 sec, idle 5 sec]"
             ├─19135 "/usr/sbin/zabbix_server: unreachable poller #5 [got 0 values in 0.000013 sec, idle 5 sec]"
             ├─19136 "/usr/sbin/zabbix_server: unreachable poller #6 [got 0 values in 0.000022 sec, idle 5 sec]"

Zum Verlassen q drücken.
Genaueres können wir uns auch noch einmal im Log-File ansehen:

tail -fn 1000 /var/log/zabbix/zabbix_server.log

Ausgabe:

19074:20240610:145301.788 Starting Zabbix Server. Zabbix 7.0.0 (revision 49955f1fb5c).
19074:20240610:145301.788 ****** Enabled features ******
19074:20240610:145301.788 SNMP monitoring:           YES
19074:20240610:145301.788 IPMI monitoring:           YES
19074:20240610:145301.788 Web monitoring:            YES
19074:20240610:145301.788 VMware monitoring:         YES
19074:20240610:145301.788 SMTP authentication:       YES
19074:20240610:145301.788 ODBC:                      YES
19074:20240610:145301.788 SSH support:               YES
19074:20240610:145301.788 IPv6 support:              YES
19074:20240610:145301.788 TLS support:               YES
19074:20240610:145301.788 ******************************
19074:20240610:145301.788 using configuration file: /etc/zabbix/zabbix_server.conf
19074:20240610:145301.801 current database version (mandatory/optional): 07000000/07000000
19074:20240610:145301.801 required mandatory version: 07000000
19077:20240610:145301.804 starting HA manager
19077:20240610:145301.806 HA manager started in active mode
19074:20240610:145301.812 server #0 started [main process]
19078:20240610:145301.812 server #1 started [service manager #1]
19079:20240610:145301.813 server #2 started [configuration syncer #1]
19083:20240610:145301.951 server #3 started [alert manager #1]
19084:20240610:145301.951 server #4 started [alerter #1]
19085:20240610:145301.952 server #5 started [alerter #2]
19086:20240610:145301.952 server #6 started [alerter #3]
19087:20240610:145301.953 server #7 started [preprocessing manager #1]
19088:20240610:145301.953 server #8 started [lld manager #1]
19089:20240610:145301.953 server #9 started [lld worker #1]
19090:20240610:145301.954 server #10 started [lld worker #2]
19093:20240610:145301.955 server #12 started [housekeeper #1]
19091:20240610:145301.955 server #11 started [ipmi manager #1]
19094:20240610:145301.955 server #13 started [timer #1]
19097:20240610:145301.956 server #15 started [browser poller #1]
19095:20240610:145301.957 server #14 started [http poller #1]
19100:20240610:145301.958 server #17 started [history syncer #1]
19099:20240610:145301.958 server #16 started [discovery manager #1]
19102:20240610:145301.958 server #19 started [history syncer #3]
19101:20240610:145301.958 server #18 started [history syncer #2]
19087:20240610:145301.958 [3] thread started [preprocessing worker #3]
19087:20240610:145301.958 [1] thread started [preprocessing worker #1]
19110:20240610:145301.959 server #20 started [history syncer #4]
19087:20240610:145301.959 [2] thread started [preprocessing worker #2]
19113:20240610:145301.960 server #21 started [escalator #1]
19099:20240610:145301.960 for a discovery process with 5 workers, the user limit of 1024 file descriptors is insufficient. The maximum number of concurrent checks per worker has been reduced to 122
19115:20240610:145301.961 server #23 started [proxy poller #1]
19116:20240610:145301.962 server #24 started [self-monitoring #1]
19118:20240610:145301.963 server #26 started [vmware collector #2]
19117:20240610:145301.963 server #25 started [vmware collector #1]
19119:20240610:145301.963 server #27 started [vmware collector #3]
19120:20240610:145301.963 server #28 started [vmware collector #4]
19114:20240610:145301.963 server #22 started [ipmi poller #1]
19124:20240610:145301.964 server #30 started [task manager #1]
19123:20240610:145301.964 server #29 started [vmware collector #5]
19125:20240610:145301.964 server #31 started [poller #1]
19127:20240610:145301.965 server #32 started [poller #2]
19128:20240610:145301.966 server #33 started [poller #3]
19130:20240610:145301.966 server #35 started [poller #5]
19131:20240610:145301.967 server #36 started [unreachable poller #1]
19129:20240610:145301.967 server #34 started [poller #4]
19133:20240610:145301.968 server #38 started [unreachable poller #3]
19132:20240610:145301.968 server #37 started [unreachable poller #2]
19134:20240610:145301.970 server #39 started [unreachable poller #4]
19135:20240610:145301.971 server #40 started [unreachable poller #5]
19136:20240610:145301.971 server #41 started [unreachable poller #6]
19137:20240610:145301.973 server #42 started [unreachable poller #7]
19138:20240610:145301.974 server #43 started [unreachable poller #8]
19139:20240610:145301.974 server #44 started [unreachable poller #9]
19140:20240610:145301.975 server #45 started [unreachable poller #10]
19141:20240610:145301.976 server #46 started [trapper #1]
19142:20240610:145301.977 server #47 started [trapper #2]
19144:20240610:145301.978 server #48 started [trapper #3]
19145:20240610:145301.978 server #49 started [trapper #4]
19146:20240610:145301.979 server #50 started [trapper #5]
19151:20240610:145301.981 server #51 started [icmp pinger #1]
19152:20240610:145301.982 server #52 started [icmp pinger #2]
19099:20240610:145301.982 thread started [discovery worker #1]
19154:20240610:145301.982 server #53 started [icmp pinger #3]
19099:20240610:145301.982 thread started [discovery worker #4]
19099:20240610:145301.982 thread started [discovery worker #2]
19099:20240610:145301.982 thread started [discovery worker #5]
19099:20240610:145301.982 thread started [discovery worker #3]
19159:20240610:145301.983 server #54 started [icmp pinger #4]
19160:20240610:145301.983 server #55 started [icmp pinger #5]
19161:20240610:145301.984 server #56 started [icmp pinger #6]
19162:20240610:145301.984 server #57 started [icmp pinger #7]
19163:20240610:145301.984 server #58 started [icmp pinger #8]
19164:20240610:145301.985 server #59 started [icmp pinger #9]
19165:20240610:145301.985 server #60 started [icmp pinger #10]
19166:20240610:145301.986 server #61 started [alert syncer #1]
19167:20240610:145301.986 server #62 started [history poller #1]
19169:20240610:145301.987 server #63 started [history poller #2]
19170:20240610:145301.987 server #64 started [history poller #3]
19172:20240610:145301.988 server #66 started [history poller #5]
19174:20240610:145301.989 server #67 started [availability manager #1]
19171:20240610:145301.989 server #65 started [history poller #4]
19180:20240610:145301.991 server #68 started [trigger housekeeper #1]
19182:20240610:145301.991 server #69 started [odbc poller #1]
19183:20240610:145301.992 server #70 started [http agent poller #1]
19183:20240610:145301.992 thread started
19185:20240610:145301.992 server #71 started [agent poller #1]
19185:20240610:145301.992 thread started
19187:20240610:145301.993 server #72 started [snmp poller #1]
19187:20240610:145301.993 thread started
19189:20240610:145301.993 server #73 started [configuration syncer worker #1]
19191:20240610:145301.994 server #74 started [internal poller #1]
19192:20240610:145301.994 server #75 started [proxy group manager #1]
19185:20240610:145303.995 enabling Zabbix agent checks on host "Zabbix server": interface became available

Wie Ihr seht ist der erste Host schon im Monitoring - Der Server selbst (der Agent startet automatisch bei der Installation).

Bei einem Proxy kann es noch folgende Fehlermeldung geben:

failed to update local proxy configuration copy: Can't open JSON object or array ""failed"}"


Naja, wir müssen den Proxy auf unserem Zabbix-Server unter

Administration - Proxies

noch anlegen - und zwar bitte genau mit dem gleichen Namen wie in der zabbix_proxy.conf unter Hostname= angegeben - dann ist der Fehler weg.

ClipCapIt-240610-152502.PNG


Bei Erfolg sollte das dann so aussehen:

Zabbix General Proxys.png

An den Sekunden unter 'Last seen (age)' sehen wir die letzte Kontaktaufnahme.
Wenn da überhaupt etwas steht hatten wir Erfolg!



Webinterface installieren (nur Server)

  • Schon jetzt findet Ihr die Weboberfläche unter http://servername/zabbix (nach einem Neustart, aber mit falscher Zeitzone)
  • Wenn es aber ein exklusiver Server für Zabbix ist möchte ich auf die Eingabe von /zabbix verzichten - das wird nachfolgend beschrieben.
  • Ich installiere hier also so das man den Server später nur mit http://servername aufrufen kann

Konfigurationsdatei bearbeiten

Button Zabbix SERVER.png

nano /etc/apache2/sites-available/000-default.conf

und den gesamten Inhalt durch den folgenden ersetzen: (F9 löscht eine Zeile)
Ab Zabbix 6.0

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /usr/share/zabbix
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
 
    <Directory "/usr/share/zabbix">
        Options FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all
        <IfModule mod_php.c>
            php_value max_execution_time 300
            php_value memory_limit 128M
            php_value post_max_size 16M
            php_value upload_max_filesize 2M
            php_value max_input_time 300
            php_value max_input_vars 10000
            php_value always_populate_raw_post_data -1
            php_value date.timezone Europe/Berlin
        </IfModule>
    </Directory>
    <Directory "/usr/share/zabbix/conf">
        Order deny,allow
        Deny from all
        <files *.php>
            Order deny,allow
            Deny from all
        </files>
    </Directory>
    <Directory "/usr/share/zabbix/app">
        Order deny,allow
        Deny from all
        <files *.php>
            Order deny,allow
            Deny from all
        </files>
    </Directory>
    <Directory "/usr/share/zabbix/include">
        Order deny,allow
        Deny from all
        <files *.php>
            Order deny,allow
            Deny from all
        </files>
    </Directory>
    <Directory "/usr/share/zabbix/local">
        Order deny,allow
        Deny from all
        <files *.php>
            Order deny,allow
            Deny from all
        </files>
    </Directory>
    <Directory "/usr/share/zabbix/vendor">
        Order deny,allow
        Deny from all
        <files *.php>
            Order deny,allow
            Deny from all
        </files>
    </Directory>
</VirtualHost>

Danach Webserver neu starten:

systemctl restart apache2.service


Nun auf die Weboberfläche gehen, die sollte unter http://IP-Adresse oder http://DNS-Name verfügbar sein.
Anmerkung: So ein Linux trägt sich nicht von allein in den DNS Server ein, ggf. müsst Ihr den da von Hand nachtragen.



Webinterface konfigurieren

Ihr ruft den Zabbix-Server im Browser auf:

ClipCapIt-240610-150403.PNG


Wenn Ihr den Inhalt der 000-default.conf wie zuvor beschrieben geändert habt sollte hier alles grün sein:

ClipCapIt-240610-150440.PNG


Die Datenbankkonfiguration, in die letzten 3 Felder muss überall "zabbix" stehen:

ClipCapIt-240610-150609.PNG


In dem leeren Feld könnt Ihr den Namen des Servers angeben. Dieser wird oben rechts und auf den Web-Tabs angezeigt:

ClipCapIt-240610-150655.PNG


Noch eben die Zusammenfassung bestätigen:

ClipCapIt-240610-150727.PNG


Geschafft!

ClipCapIt-240610-150756.PNG


ClipCapIt-240610-150829.PNG
Benutzername: Admin
Passwort:     zabbix
Important.png
Hinweis: Admin mit großem A!





Empfang von SNMP-Traps einrichten

Important.png
Hinweis:Neue Methode! Statt snmptt wird ein Perl-Script von Zabbix.com verwendet. snmptt machte bei mir unter Ubuntu 22.04 jede menge Ärger
Die Lösung stammt in Teilen von https://sbcode.net/zabbix/snmp-traps/

Button Zabbix SERVER.png und Button Zabbix PROXY.png

fehlende Pakete nachinstallieren

Wir Installieren ggf. die benötigten Pakete nach (sollten schon vorhanden sein):

apt install -y snmp snmpd snmp-mibs-downloader snmptrapd libnet-snmp-perl libnet-ip-perl libnet-netmask-perl libnet-dns-perl libxml-writer-perl




snmptrapd aktivieren und konfigurieren

snmpd deaktivieren:

systemctl stop snmpd.service && systemctl disable snmpd.service

snmptrapd reparieren:

nano /lib/systemd/system/snmptrapd.service

und ganz unten folgenden Text anhängen (sofern noch nicht vorhanden:)

[Install]
WantedBy=multi-user.target

snmptrapd aktivieren:

systemctl enable snmptrapd.service

snmptrapd konfigurieren:

nano /etc/snmp/snmptrapd.conf

und fügen die folgenden Zeilen ans Ende:

perl do "/usr/bin/zabbix_trap_receiver.pl";
disableAuthorization yes

und starten den Dienst:

systemctl restart snmptrapd.service

zabbix_trap_receiver.pl einrichten

Aktuelles Skript herunterladen - der Download ist von meiner Webseite, das original findet Ihr unter https://git.zabbix.com/projects/ZBX/repos/zabbix/raw/misc/snmptrap/zabbix_trap_receiver.pl
Der direkte Download von dort funktioniert aber nicht (immer):

wget https://git.zabbix.com/projects/ZBX/repos/zabbix/raw/misc/snmptrap/zabbix_trap_receiver.pl -O /usr/bin/zabbix_trap_receiver.pl

falls der nicht geht, nehmt diesen Link:

wget https://znil.net/images/zabbix_trap_receiver.pl -O /usr/bin/zabbix_trap_receiver.pl

und ausführbar machen

chmod a+x /usr/bin/zabbix_trap_receiver.pl


Für den Fall das der Download nicht zur Verfügung steht hier der Inhalt der Datei:

#!/usr/bin/env perl

#
# Copyright (C) 2001-2024 Zabbix SIA
#
# This program is free software: you can redistribute it and/or modify it under the terms of
# the GNU Affero General Public License as published by the Free Software Foundation, version 3.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License along with this program.
# If not, see <https://www.gnu.org/licenses/>.
#

#########################################
#### ABOUT ZABBIX SNMP TRAP RECEIVER ####
#########################################

# This is an embedded perl SNMP trapper receiver designed for sending data to the server.
# The receiver will pass the received SNMP traps to Zabbix server or proxy running on the
# same machine. Please configure the server/proxy accordingly.
#
# Read more about using embedded perl with Net-SNMP:
#       http://net-snmp.sourceforge.net/wiki/index.php/Tut:Extending_snmpd_using_perl

#################################################
#### ZABBIX SNMP TRAP RECEIVER CONFIGURATION ####
#################################################

### Option: SNMPTrapperFile
#       Temporary file used for passing data to the server (or proxy). Must be the same
#       as in the server (or proxy) configuration file.
#
# Mandatory: yes
# Default:
$SNMPTrapperFile = '/tmp/zabbix_traps.tmp';

### Option: DateTimeFormat
#       The date time format in strftime() format. Please make sure to have a corresponding
#       log time format for the SNMP trap items.
#
# Mandatory: yes
# Default:
$DateTimeFormat = '%Y-%m-%dT%T%z';

###################################
#### ZABBIX SNMP TRAP RECEIVER ####
###################################

use Fcntl qw(O_WRONLY O_APPEND O_CREAT);
use POSIX qw(strftime);
use NetSNMP::TrapReceiver;

sub zabbix_receiver
{
        my (%pdu_info) = %{$_[0]};
        my (@varbinds) = @{$_[1]};

        # open the output file
        unless (sysopen(OUTPUT_FILE, $SNMPTrapperFile, O_WRONLY|O_APPEND|O_CREAT, 0666))
        {
                print STDERR "Cannot open [$SNMPTrapperFile]: $!\n";
                return NETSNMPTRAPD_HANDLER_FAIL;
        }

        # get the host name
        my $hostname = $pdu_info{'receivedfrom'} || 'unknown';
        if ($hostname ne 'unknown')
        {
                $hostname =~ /\[(.*?)\].*/;                    # format: "UDP: [127.0.0.1]:41070->[127.0.0.1]"
                $hostname = $1 || 'unknown';
        }

        # print trap header
        #       timestamp must be placed at the beginning of the first line (can be omitted)
        #       the first line must include the header "ZBXTRAP [IP/DNS address] "
        #              * IP/DNS address is the used to find the corresponding SNMP trap items
        #              * this header will be cut during processing (will not appear in the item value)
        printf OUTPUT_FILE "%s ZBXTRAP %s\n", strftime($DateTimeFormat, localtime), $hostname;

        # print the PDU info
        print OUTPUT_FILE "PDU INFO:\n";
        foreach my $key(keys(%pdu_info))
        {
                if ($pdu_info{$key} !~ /^[[:print:]]*$/)
                {
                        my $OctetAsHex = unpack('H*', $pdu_info{$key}); # convert octet string to hex
                        $pdu_info{$key} = "0x$OctetAsHex";              # apply 0x prefix for consistency
                }

                printf OUTPUT_FILE "  %-30s %s\n", $key, $pdu_info{$key};
        }

        # print the variable bindings:
        print OUTPUT_FILE "VARBINDS:\n";
        foreach my $x (@varbinds)
        {
                printf OUTPUT_FILE "  %-30s type=%-2d value=%s\n", $x->[0], $x->[2], $x->[1];
        }

        close (OUTPUT_FILE);

        return NETSNMPTRAPD_HANDLER_OK;
}

NetSNMP::TrapReceiver::register("all", \&zabbix_receiver) or
        die "failed to register Zabbix SNMP trap receiver\n";

print STDOUT "Loaded Zabbix SNMP trap receiver\n";

MIBS nutzen

Die MIBS übersetzen die OID in lesbare Namen. Um diese zu nutzen:

nano /etc/snmp/snmp.conf

und dort aus

mibs :

ein

#mibs :

machen. Dann den dienst neu starten:

systemctl restart snmptrapd.service

logrotate für /tmp/zabbix_traps.tmp erstellen

Gerade wenn viele Einträge in der Datei

/tmp/zabbix_traps.tmp

landen kann das schon mal einigen Platz kosten.
Deshalb nutzen wir logrotate an um die Größe der Datei zu begrenzen.

nano /etc/logrotate.d/zabbix_traps

und folgenden Inhalt einfügen / anpassen:

/tmp/zabbix_traps.tmp {
        su snmptt Debian-snmp
        create 666 snmptt Debian-snmp
        missingok
        notifempty
        daily
        rotate 4
        size 1M
        compress
        sharedscripts
        maxage 365
}




Zabbix Server oder Proxy konfigurieren

Die Konfigurationsdatei zum bearbeiten öffnen:

nano /etc/zabbix/zabbix_server.conf
oder
nano /etc/zabbix/zabbix_proxy.conf

und folgende Zeilen suchen und ändern bzw. Kommentarzeichen davor entfernen:

SNMPTrapperFile=/tmp/zabbix_traps.tmp
StartSNMPTrapper=1


Danach müssen wir den Zabbix Server oder Proxy Dienst neu starten:

systemctl restart zabbix-server.service
oder
systemctl restart zabbix-proxy.service




Trapper-Datei anlegen / Testen

Die Datei /tmp/zabbix_traps.tmp gibt es noch nicht.
Die wird aber ggf. erst beim ersten eintreffenden Trap erstellt. Deshalb:

snmptrap -v 1 -c public localhost 1.3.6.1.4.1.2.3 "" 6 3 0000 s s "Zabbix-SNMP-Traps"

Damit senden wir einen Test-Trap an uns selbst.
Nun sollte es die Datei geben:

ls -l /tmp/zabbix_traps.tmp

Ausgabe:

-rw-r--r-- 1 root root 158 Sep  6 09:55 /tmp/zabbix_traps.tmp

Der Inhalt sollte wie folgt sein:

cat /tmp/zabbix_traps.tmp
12:03:21 2023/03/20 ZBXTRAP 127.0.0.1
PDU INFO:
  community                      public
  requestid                      0
  transactionid                  1
  receivedfrom                   UDP: [127.0.0.1]:48627->[127.0.0.1]:162
  errorindex                     0
  notificationtype               TRAP
  version                        0
  errorstatus                    0
  messageid                      0
VARBINDS:
  DISMAN-EVENT-MIB::sysUpTimeInstance type=67 value=Timeticks: (0) 0:00:00.00
  SNMPv2-MIB::snmpTrapOID.0      type=6  value=OID: SNMPv2-SMI::enterprises.2.3.0.3
  SNMPv2-SMI::snmpV2             type=4  value=STRING: "Zabbix-SNMP-Traps"
  SNMP-COMMUNITY-MIB::snmpTrapAddress.0 type=64 value=IpAddress: 10.88.1.88
  SNMP-COMMUNITY-MIB::snmpTrapCommunity.0 type=4  value=STRING: "public"
  SNMPv2-MIB::snmpTrapEnterprise.0 type=6  value=OID: SNMPv2-SMI::enterprises.2.3

Nach einem Reboot ist Datei weg bis der erste Trap eintrifft - was Zabbix aber nicht zu stören scheint.


Agent konfigurieren (nur Proxy)

Wir wollen natürlich unseren 'Zabbix Proxy' gleich mit überwachen!
Wenn es ein Server ist, ist dieser gleich automatisch mit drin (ist der erste Host der schon in der Liste steht, ist sogar schon aktiv!) Bearbeiten wir zunächst die Konfigurationsdatei:

nano /etc/zabbix/zabbix_agent2.conf

und ändert folgende Zeile:

Hostname=zabbixproxy.domain.local

Den Namen passt Ihr natürlich an eure Bedürfnisse an - wichtig ist nur das Ihr den Host auf dem Zabbix-Server unter exakt dem gleichen Namen anlegt!

Important.png
Hinweis: Ihr wollt die zabbix_agentd.conf ändern, NICHT die zabbix_agent.conf - man beachte den feinen Unterschied!



Das Start-Skript haben wir vorhin schon aktiviert.
Am besten bootet Ihr euren Zabbix Proxy nun einmal durch und prüft hinterher ob die Prozesse für den Agenten und den Server laufen.


Windows-Freigabe für Agenten-Dateien einrichten

In meinen früheren Anleitungen wurde in diesem Abschnitt beschrieben wie man eine Samba-Freigabe erstellt in welcher der Zabbix-Agent abgelegt wird.
Das mache ich in der Praxis nicht mehr - neuere Windows-Versionen finden es unvorstellbar das man auf eine Freigabe ohne Passwort zugreifen möchte.
Man könnte den Zabbix-Server zwar dazu zum Mitglied in der Domäne machen ... aber inzwischen erstelle ich einfach eine passende Freigabe auf einen der Windows-Server, in der Regel einer der Domänencontroller.
Das Installationspaket hat nur ein paar MByte, da findet sich ein Plätzchen.


Zabbix Reporting-Services installieren / aktivieren

Installiert sollte es schon sein, falls nicht:

apt install zabbix-web-service

Dann aktivieren und starten:

systemctl enable zabbix-web-service.service
systemctl start zabbix-web-service.service

Der Dienst lauscht per Default auf Port 10053 was in der /etc/zabbix/zabbix_web_service.conf konfiguriert wird.
Anfragen nimmt er nur von lokal entgegen (127.0.0.1 / ::1)
Nun den Dienst auch noch im Zabbix-Server bekannt machen:

nano /etc/zabbix/zabbix_server.conf

und die folgenden Zeilen ändern:

StartReportWriters=3
WebServiceURL=http://localhost:10053/report

Im Anschluß Zabbix einmal neu starten:

systemctl restart zabbix-server.service


Im Webinterface müsst ihr nun einmal hinterlegen wir die Reporting-Services das Zabbix-Frontend erreichen können:
Unter Administration . General - Other bei Frontend URL folgendes setzen:

http://localhost/


Jetzt muss noch Google-Chromium installiert werden, den braucht der Dienst zum erstellen der PDFs. Da wir keine GUI auf dem Zabbix-Server haben laden wir den Browser einfach direkt als Paket herunter und installieren diesen:

wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
dpkg -i google-chrome-stable_current_amd64.deb
apt install -f
dpkg --configure -a

Ja, das ist etwas umständlich, wir installieren Chrome, er meckert über fehlende Abhängigkeiten, die beheben wir dann und lassen das Konfigurieren noch mal laufen.
Dafür ist der dann installiert ohne das wir eine grafische Oberfläche auf dem Server installieren mussten.


Datensicherung des Zabbix-Servers

Bevorzugt installiere ich Zabbix-Server als Virtuelle Maschinen / VM.
Die Backup-Software sichert am besten einfach die gesamte VM.
Eigentlich macht quasi jede Backup-Software hierzu während der Sicherung einen Snapshot, sichert die Festplattendaten und löst dann den Snapshot wieder auf.
Wer dabei sicher gehen will das die Datenbank in einem konsistenten Zustand gesichert wird kann folgendes tun:


Methode 1: Cold Backup - Zabbix und Datenbank anhalten

Bei dieser Methode passiert folgendes:

  • Die Zabbix-Server und die Datenbank werden vor einem Snapshot angehalten
  • Der Snapshot wird erstellt
  • Die Datenbank und der Zabbix-Server werden wieder gestartet


Unter VMware funktioniert das mit 2 Skripten die wir wie folgt anlegen:

nano /usr/sbin/pre-freeze-script

mit folgendem Inhalt:

#!/bin/sh
echo "$(date) pre-freeze start" >> /tmp/snapshot.log
systemctl stop zabbix-server.service
systemctl stop mysql.service
echo "$(date) pre-freeze stop" >> /tmp/snapshot.log


und

nano /usr/sbin/post-thaw-script
#!/bin/sh
echo "$(date) post-thaw start" >> /tmp/snapshot.log
systemctl start mysql.service
systemctl start zabbix-server.service
echo "$(date) post-thaw stop" >> /tmp/snapshot.log


Jetzt müssen wir die beiden Skripte noch ausführbar machen und dem root zuordnen:

chmod 0700 /usr/sbin/pre-freeze-script
chmod 0700 /usr/sbin/post-thaw-script
chown root:root /usr/sbin/pre-freeze-script
chown root:root /usr/sbin/post-thaw-script


Voraussetzung ist das die VMware-Tools installiert sind!
Dabei ist es egal ob es sich um die Original VMware-Tools oder um die Open-VM-Tools aus den Repositories handelt.
Nun können wir die Skripts testen indem wir einen Snapshot mit den folgenden Einstellungen erstellen:

ClipCapIt-200521-204401.PNG


Wenn wir uns die Logs ansehen sollte

  • Ein Eintrag in die Datei /tmp/snapshot.log vorgenommen
  • Der Zabbix-Server gestoppt
  • Der MySQL-Server gestoppt
  • Wieder ein Eintrag in die Datei /tmp/snapshot.log geschrieben
  • Der MySQL-Server wieder gestartet
  • Der Zabbix-Server wieder gestartet

werden.

Important.png
Hinweis: Das ganze funktioniert sowohl mit den original VMware-Tools als auch den Open-VM-Tools!





Methode 2: Hot Backup - Datenbank einfrieren

Bei dieser Methode passiert folgendes:

  • Die Datenbank wird vor einem Snapshot auf "READ ONLY" gesetzt - zuvor werden noch alle Daten geschrieben ("FLUSH TABLES")
  • Der Snapshot wird erstellt
  • Die Datenbank wird wieder für Schreibzugriffe freigegeben


Unter VMware funktioniert das mit 2 Skripten die wir wie folgt anlegen:

nano /usr/sbin/pre-freeze-script

mit folgendem Inhalt:

Warning.png
Warnung: Vergesst nicht das Passwort in Zeile 9 zu setzen (steht auf Leer was per Default passen sollte)
#!/bin/sh
# 2018-04-20 Bernhard Linz
# Original script by Pascal Di Marco, check https://www.veeam.com/wp-consistent-protection-mysql-mariadb.html for more information
# Log will be write to syslog and(!) to /tmp/snapshot.log
echo "$0 pre-freeze start" | logger
echo "-------------------------------------------------------------------------------------" >> /tmp/snapshot.log
echo "$0 $(date '+%Y-%m-%d %H:%M:%S') pre-freeze start" >> /tmp/snapshot.log
# Set Username and Passwort for MySQL Access. Set mysql_password="" if no password needed
mysql_username="root"
mysql_password=""
timeout=300

# ************************************************************************************************
# No Changes behind this line!
# ************************************************************************************************
# Check if username + password is used
if [ -n "$mysql_password" ]; then
    use_credentials="-u$mysql_username -p$mysql_password"
else
    use_credentials=""
fi

# Name of the Lockfile
lock_file=/tmp/mysql_tables_read_lock

sleep_time=$((timeout+10))
rm -f $lock_file
echo "$0 executing FLUSH TABLES WITH READ LOCK" | logger
echo "$0 $(date '+%Y-%m-%d %H:%M:%S') executing FLUSH TABLES WITH READ LOCK" >> /tmp/snapshot.log

# Start READ LOCK - Process will send to background (and will still run after script is completed. Lock will stop if process is stopped
# After READ ONLY mode is entered the lockfile will be created. Process will stop when getting stop signal from post-thaw-script or timeout reached
mysql $use_credentials -e "FLUSH TABLES WITH READ LOCK; system touch $lock_file; system nohup sleep $sleep_time; system echo lock released|logger; " > /dev/null &
# get the PID of the mysql process
mysql_pid=$!

echo "$0 child pid $mysql_pid" | logger
echo "$0 $(date '+%Y-%m-%d %H:%M:%S') child pid $mysql_pid" >> /tmp/snapshot.log

# Waiting for the lockfile ...
c=0
while [ ! -f $lock_file ]
do
    # check if mysql is running
    if ! ps -p $mysql_pid 1>/dev/null ; then
        echo "$0 mysql command has failed (bad credentials?)" | logger
        echo "$0 $(date '+%Y-%m-%d %H:%M:%S') mysql command has failed (bad credentials?)" >> /tmp/snapshot.log
        exit 1
    fi
    sleep 1
    c=$((c+1))
    # check if the script run into timeout
    if [ $c -gt $timeout ]; then
        echo "$0 timed out waiting for lock" | logger
        echo "$0 $(date '+%Y-%m-%d %H:%M:%S') timed out waiting for lock" >> /tmp/snapshot.log
        touch $lock_file
        kill $mysql_pid
    fi
done
# write PID into the lockfile
echo $mysql_pid > $lock_file

echo "$0 pre-freeze stop" | logger
echo "$0 $(date '+%Y-%m-%d %H:%M:%S') pre-freeze stop" >> /tmp/snapshot.log

exit 0


und

nano /usr/sbin/post-thaw-script
#!/bin/sh
# 2018-04-20 Bernhard Linz
# Original script by Pascal Di Marco, check https://www.veeam.com/wp-consistent-protection-mysql-mariadb.html for more information
# Log will be write to syslog and(!) to /tmp/snapshot.log
echo "$0 post-thaw start" | logger
echo "$0  $(date '+%Y-%m-%d %H:%M:%S') post-thaw start" >> /tmp/snapshot.log

lock_file=/tmp/mysql_tables_read_lock

# get PID from lockfile
mysql_pid=$(cat $lock_file)
echo "$0 sending sigterm to $mysql_pid" | logger
echo "$0  $(date '+%Y-%m-%d %H:%M:%S') sending sigterm to $mysql_pid" >> /tmp/snapshot.log
# and send stop to process
pkill -9 -P $mysql_pid
rm -f $lock_file

echo "$0 post-thaw stop" | logger
echo "$0  $(date '+%Y-%m-%d %H:%M:%S') post-thaw stop" >> /tmp/snapshot.log

exit 0


Jetzt müssen wir die beiden Skripte noch ausführbar machen und dem root zuordnen:

chmod 0700 /usr/sbin/pre-freeze-script
chmod 0700 /usr/sbin/post-thaw-script
chown root:root /usr/sbin/pre-freeze-script
chown root:root /usr/sbin/post-thaw-script


Voraussetzung ist das die VMware-Tools installiert sind!
Dabei ist es egal ob es sich um die Original VMware-Tools oder um die Open-VM-Tools aus den Repositories handelt.
Nun können wir die Skripts testen indem wir einen Snapshot mit den folgenden Einstellungen erstellen:

ClipCapIt-200521-204401.PNG


Beispielausgabe aus der

cat /tmp/snapshot.log
-------------------------------------------------------------------------------------
/usr/sbin/pre-freeze-script 2023-03-20 12:49:14 pre-freeze start
/usr/sbin/pre-freeze-script 2023-03-20 12:49:14 executing FLUSH TABLES WITH READ LOCK
/usr/sbin/pre-freeze-script 2023-03-20 12:49:14 child pid 11824
/usr/sbin/pre-freeze-script 2023-03-20 12:49:15 pre-freeze stop
/usr/sbin/post-thaw-script  2023-03-20 12:49:18 post-thaw start
/usr/sbin/post-thaw-script  2023-03-20 12:49:18 sending sigterm to 11824
/usr/sbin/post-thaw-script  2023-03-20 12:49:18 post-thaw stop


Falls es mit dem Passwort mal hakt so müsste das auch dort stehen:

/usr/sbin/pre-freeze-script 2018-06-13 12:01:04 mysql command has failed (bad credentials?)

Mehr Details stehen ggf. im syslog

tail -f -n 500 /var/log/syslog

Zabbix selbst nimmt den Vorgang relativ locker und meldet maximal einige slow query bei inserts.
In den meisten Umgebungen geht das so schnell das nicht einmal diese kommen (4 bis 5 Sekunden).

Important.png
Hinweis: Das ganze funktioniert sowohl mit den original VMware-Tools als auch den Open-VM-Tools!





Festplatte im laufenden Betrieb vergrößern

Ihr habt den NextCloud-Server nach dieser Anleitung hier als VM installiert (und ohne LVM) und nun geht euch der Platz aus?
Kein Problem, Ihr könnt die Festplatte im laufenden Betrieb vergößern!


Schritt 1: Platz an die Festplatte anhängen

  • Stellt sicher das auf der VM zur zeit kein Snapshot aktiv ist!
  • Vergrößert die Festplatte um den benötigten Speicherplatz

in dem Beispiel hier wird der Platz von 50 auf 100GB vergrößert.


Schritt 2: Betriebssystem die neue Größe erkennen lassen

Die einfachste und sicherste Methode ist den Server neu zu starten.
Wer will kann es aber auch im laufenden Betrieb durchführen, und das geht so:

Wir müssen die Festplattenkontroller-Adapternummer ermitteln:

grep mpt /sys/class/scsi_host/host*/proc_name

findet er nichts probiert

grep pvscsi /sys/class/scsi_host/host*/proc_name

Beispielausgaben (eine von beiden wird kommen):

/sys/class/scsi_host/host32/proc_name:mptspi
/sys/class/scsi_host/host2/proc_name:vmw_pvscsi

Die Nummer ist in diesem Fall host32! Die brauchen wir für den nächsten Befehl:

find /sys -name rescan | grep host32

Beispielausgabe:

/sys/devices/pci0000:00/0000:00:10.0/host32/target32:0:0/32:0:0:0/rescan

Ok, an die Festplatte schicken wir jetzt eine 1 um den Rescan auszulösen:

echo 1 > /sys/devices/pci0000:00/0000:00:10.0/host32/target32:0:0/32:0:0:0/rescan

Fertig!

Im Anschluß zur Kontrolle ein

fdisk -l

Die Ausgabe sollte ähnlich wie diese sein:

Festplatte /dev/sda: 100 GiB, 107374182400 Bytes, 209715200 Sektoren
Festplattenmodell: Virtual disk
Einheiten: Sektoren von 1 * 512 = 512 Bytes
Sektorgröße (logisch/physikalisch): 512 Bytes / 512 Bytes
E/A-Größe (minimal/optimal): 512 Bytes / 512 Bytes
Festplattenbezeichnungstyp: gpt
Festplattenbezeichner: 9BE90D25-A550-48DB-9E50-6CAC38D87217

Gerät       Anfang     Ende Sektoren Größe Typ
/dev/sda1     2048  2203647  2201600    1G EFI-System
/dev/sda2  2203648 52426751 50223104 23,9G Linux-Dateisystem

Wir können sehen das sda nun 100GB groß ist, in der letzten Zeile sehen wir aber das die Partition sda2 zur Zeit noch 23,9Gb groß ist - prima!

Schritt 3: Partition vergrößern

Das /var/www Verzeichnis unserer zweiten Partition der Festplatte befindet sich auf dem Gerät

/dev/sda2

wenn Ihr nach dieser Anleitung installiert hattet. Kontrollieren könnte Ihr das z.B. mit

df -h

und dann schauen was links vom Verzeichnis / steht:

Dateisystem    Größe Benutzt Verf. Verw% Eingehängt auf
tmpfs           392M    1,2M  391M    1% /run
/dev/sda2        63G    8,8G   51G   15% /
tmpfs           2,0G       0  2,0G    0% /dev/shm
tmpfs           5,0M       0  5,0M    0% /run/lock
tmpfs           392M     12K  392M    1% /run/user/0

Die nächsten Befehle gehen von /dev/sda2, wenn der Pfad anderes ist müsst Ihr diesen anpassen!

growpart /dev/sda 2
resize2fs /dev/sdb2

Ja, beim ersten Befehl ist da ein Leerzeichen zwischen dem sda und der 2, beim zweiten Befehl nicht.

Schritt 4: Das war schon alles!

Ihr könnt mit

df -h

es einmal kontrollieren - aber das war schon alles:

Dateisystem    Größe Benutzt Verf. Verw% Eingehängt auf
tmpfs           391M    1,2M  390M    1% /run
/dev/sda2        32G    7,6G   23G   26% /
tmpfs           2,0G       0  2,0G    0% /dev/shm
tmpfs           5,0M       0  5,0M    0% /run/lock
/dev/sdb1        99G    655M   93G    1% /var/www
tmpfs           391M    4,0K  391M    1% /run/user/1000

Kommentare

Loading comments...