{"id":45,"date":"2022-05-12T20:30:42","date_gmt":"2022-05-12T19:30:42","guid":{"rendered":"http:\/\/192.168.41.160:8081\/?p=45"},"modified":"2024-10-21T15:19:29","modified_gmt":"2024-10-21T13:19:29","slug":"zabbix-6-0-mariadb-und-nginx","status":"publish","type":"post","link":"https:\/\/timo-brunn.de\/index.php\/2022\/05\/12\/zabbix-6-0-mariadb-und-nginx\/","title":{"rendered":"Zabbix 6.0 (MariaDB und NGINX)"},"content":{"rendered":"\n<div class=\"wp-block-columns alignwide is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\"><div class=\"has-text-align-right wp-block-post-date\"><time datetime=\"2022-05-12T20:30:42+02:00\">Mai 12, 2022<\/time><\/div>\n\n\n<h2 class=\"wp-block-heading\">Vorwort<\/h2>\n\n\n\n<p>F\u00fcr das Monitoring meiner Systeme habe ich mich f\u00fcr <a href=\"https:\/\/www.zabbix.com\" data-type=\"URL\" data-id=\"https:\/\/www.zabbix.com\" target=\"_blank\" rel=\"noreferrer noopener\">Zabbix <\/a>entschieden.<\/p>\n\n\n\n<p>In diesem Eintrag geht es um die Installation eines einfachen Zabbix Servers auf AlmaLinux 8.5. <br>Als Datenbank nutzen wir eine MariaDB. Als Webserver einen NGINX.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Installation MariaDB<\/h2>\n\n\n\n<p>Zum aktuellen Datum ist in den AlmaLinux 8.5 Repos eine MariaDB 10.3.28 als Standardmodul vorhanden.<br>Zabbix braucht allerdings eine 10.5. Hierf\u00fcr m\u00fcssen wir auf das passende Modul wechseln.<br>Die Installation erfolgt ganz einfach \u00fcber yum<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">sudo yum module enable mariadb:10.5\nsudo yum install mariadb-server<\/code><\/pre>\n\n\n\n<p>Jetzt k\u00f6nnen wir direkt die MariaDB starten<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">sudo systemctl enable --now mariadb.service<\/code><\/pre>\n\n\n\n<p>Danach m\u00fcssen wir noch folgendes Program starten:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">sudo mysql_secure_installation<\/code><\/pre>\n\n\n\n<p>Hier bekommen wir dann folgende Fragen beantworten:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"\" class=\"\">Enter current password for root (enter for none):<\/code><\/pre>\n\n\n\n<p>Hier einfach <strong>ENTER <\/strong>dr\u00fccken<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">Set root password? [Y\/n]<\/code><\/pre>\n\n\n\n<p>Hier dann einmal <strong>Y<\/strong> eingeben und ein Passwort vergeben<\/p>\n\n\n\n<p>Folgendes dann alles mit <strong>Y <\/strong>best\u00e4tigen<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">Remove anonymous users? [Y\/n]\nDisallow root login remotely? [Y\/n]\nRemove test database and access to it? [Y\/n]\nReload privilege tables now? [Y\/n]<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Anlegen SQL Zabbix DB<\/h2>\n\n\n\n<p>Jetzt m\u00fcssen wir noch eine Datenbank f\u00fcr unsere Zabbix installation anlegen.<\/p>\n\n\n\n<p>Daf\u00fcr m\u00fcssen wir uns erstmal in der MySql shell anmelden.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">mysql -u root -p<\/code><\/pre>\n\n\n\n<p>Hier dann das Kennwort, das wir vorhin vergeben haben eingeben.<br>Dann k\u00f6nnen wir auch gleich die Datenbank anlegen.<br><strong>&#8222;DBNAME&#8220; <\/strong>mit eurem Datenbanknamen ersetzen. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\">create database DBNAME character set utf8 collate utf8_bin;<\/code><\/pre>\n\n\n\n<p>Danach brauchen wir noch einen SQL Benutzer f\u00fcr Zabbix und k\u00f6nnen diesem auch gleich die Berechtigungen vergeben.<br> <strong>&#8222;meinpasswort&#8220;<\/strong> mit eurem Wunschkennwort ersetzen.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\">create user zabbix@localhost identified by 'meinpasswort';\ngrant all privileges on DBNAME.* to zabbix@localhost;\nFLUSH PRIVILEGES;\nquit;<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Installation von Zabbix<\/h2>\n\n\n\n<p>Hierf\u00fcr m\u00fcssen wir erstmal das Repo f\u00fcr Zabbix 5.4-1 Hinzuf\u00fcgen.<br>Ich empfehle hier das aktuelle Repo von der Offiziellen Zabbix Seite Rauszusuchen<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">sudo rpm -Uvh https:\/\/repo.zabbix.com\/zabbix\/6.0\/rhel\/8\/x86_64\/zabbix-release-6.0-1.el8.noarch.rpm\nsudo dnf clean all <\/code><\/pre>\n\n\n\n<p>Danach installieren wir einfach alle Pakete<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">sudo yum install zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent <\/code><\/pre>\n\n\n\n<p>Jetzt m\u00fcssen wir noch das Zabbix Schema in die DB importieren. <strong>&#8222;DBNAME&#8220; <\/strong>wieder mit eurem Datenbanknamen ersetzen. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">zcat \/usr\/share\/doc\/zabbix-sql-scripts\/mysql\/server.sql.gz | mysql -u zabbix -p DBNAME<\/code><\/pre>\n\n\n\n<p>Danach einmal das Kennwort f\u00fcr den Zabbix Benutzer eingeben.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">PHP und Zabbix Konfiguration<\/h2>\n\n\n\n<p>Damit Zabbix mit der Datenbank sprechen kann, m\u00fcssen wir die DB Zugangsdaten in der Konfigurationsdatei anpassen.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">sudo nano \/etc\/zabbix\/zabbix_server.conf <\/code><\/pre>\n\n\n\n<p>Hier m\u00fcssen entsprechend die folgenden Werte angepasst werden:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>DBHost<\/td><td>Die IP-Adresse oder der FQDN des Datenbank Hosts. Hier &#8222;<strong>localhost<\/strong>&#8222;<\/td><\/tr><tr><td>DBName<\/td><td>Das ist der name der Datebank (in dieser anleitung &#8222;<strong>DBNAME<\/strong>&#8222;)<\/td><\/tr><tr><td>DBUser<\/td><td>Der Benutzername des Datenbankbenutzers (hier &#8222;<strong>zabbix<\/strong>&#8222;)<\/td><\/tr><tr><td>DBPassword<\/td><td>Das Passwort f\u00fcr den Benutzer<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">NGINX Konfiguration<\/h2>\n\n\n\n<p>Wir m\u00fcssen jetzt noch den &#8222;VHost&#8220; f\u00fcr Zabbix aktivieren. Hierf\u00fcr wurde automatisch eine Konfiguration im NGINX Ordner angelegt.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">sudo nano \/etc\/nginx\/conf.d\/zabbix.conf<\/code><\/pre>\n\n\n\n<p>Hier m\u00fcssen diese beiden Zeilen auskommentiert werden und wie folgend angepasst werden<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"nginx\" class=\"language-nginx\">listen 80 default_server;\nserver_name _; <\/code><\/pre>\n\n\n\n<p>In der Datei <strong>\/etc\/nginx\/nginx.conf<\/strong> habe ich folgendes auskommentiert. Ich m\u00f6chte das auf diesem Server der Default Server das Zabbix ist.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"nginx\" class=\"language-nginx\">    #server {\n    #    listen       80 default_server;\n    #    listen       [::]:80 default_server;\n    #    server_name  _;\n    #    root         \/usr\/share\/nginx\/html;\n\n        # Load configuration files for the default server block.\n    #    include \/etc\/nginx\/default.d\/*.conf;\n\n    #    location \/ {\n    #    }\n\n    #    error_page 404 \/404.html;\n    #        location = \/40x.html {\n    #    }\n\n    #    error_page 500 502 503 504 \/50x.html;\n    #        location = \/50x.html {\n    #    }\n    #}\n<\/code><\/pre>\n\n\n\n<p>Danach m\u00fcssen wir einmal die Dienste starten und aktivieren.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">sudo systemctl restart zabbix-server zabbix-agent nginx php-fpm\nsudo systemctl enable zabbix-server zabbix-agent nginx php-fpm <\/code><\/pre>\n\n\n\n<p>Danach m\u00fcssen wir noch http und zabbix-agent durch die Firewall lassen<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">sudo firewall-cmd --add-service=http --permanent\nsudo firewall-cmd --add-service=zabbix-agent --permanent\nsudo firewall-cmd --reload<\/code><\/pre>\n\n\n\n<p>Danach k\u00f6nnen wir Zabbix \u00fcber die IP-Adresse vom Server aufrufen.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Web Setup<\/h2>\n\n\n\n<p>Die erste Seite die wir sehen ist die Sprachauswahl. Ich installiere Zabbix hier in US Englisch<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full is-style-twentytwentyone-border\"><img loading=\"lazy\" decoding=\"async\" width=\"850\" height=\"533\" src=\"http:\/\/192.168.41.160:8081\/wp-content\/uploads\/2022\/05\/image.png\" alt=\"\" class=\"wp-image-126\" srcset=\"https:\/\/timo-brunn.de\/wp-content\/uploads\/2022\/05\/image.png 850w, https:\/\/timo-brunn.de\/wp-content\/uploads\/2022\/05\/image-300x188.png 300w, https:\/\/timo-brunn.de\/wp-content\/uploads\/2022\/05\/image-768x482.png 768w\" sizes=\"auto, (max-width: 850px) 100vw, 850px\" \/><\/figure>\n\n\n\n<p>Danach wird einmal gepr\u00fcft, ob die PHP Konfiguration passt.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full is-style-twentytwentyone-border\"><img loading=\"lazy\" decoding=\"async\" width=\"851\" height=\"544\" src=\"http:\/\/192.168.41.160:8081\/wp-content\/uploads\/2022\/05\/image-1.png\" alt=\"\" class=\"wp-image-127\" srcset=\"https:\/\/timo-brunn.de\/wp-content\/uploads\/2022\/05\/image-1.png 851w, https:\/\/timo-brunn.de\/wp-content\/uploads\/2022\/05\/image-1-300x192.png 300w, https:\/\/timo-brunn.de\/wp-content\/uploads\/2022\/05\/image-1-768x491.png 768w\" sizes=\"auto, (max-width: 851px) 100vw, 851px\" \/><\/figure>\n\n\n\n<p>Nun m\u00fcssen wir einmal die Datenbankverbindung herstellen.<br>Hier bei &#8222;<strong>DBNAME<\/strong>&#8220; den Namen der Datenbank angeben und die Zugangsdaten weiter unten.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full is-style-twentytwentyone-border\"><img loading=\"lazy\" decoding=\"async\" width=\"849\" height=\"553\" src=\"http:\/\/192.168.41.160:8081\/wp-content\/uploads\/2022\/05\/image-2.png\" alt=\"\" class=\"wp-image-128\" srcset=\"https:\/\/timo-brunn.de\/wp-content\/uploads\/2022\/05\/image-2.png 849w, https:\/\/timo-brunn.de\/wp-content\/uploads\/2022\/05\/image-2-300x195.png 300w, https:\/\/timo-brunn.de\/wp-content\/uploads\/2022\/05\/image-2-768x500.png 768w\" sizes=\"auto, (max-width: 849px) 100vw, 849px\" \/><\/figure>\n\n\n\n<p>Nun kann man Servername, Zeitzone und Design angeben<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full is-style-twentytwentyone-border\"><img loading=\"lazy\" decoding=\"async\" width=\"864\" height=\"556\" src=\"http:\/\/192.168.41.160:8081\/wp-content\/uploads\/2022\/05\/image-3.png\" alt=\"\" class=\"wp-image-129\" srcset=\"https:\/\/timo-brunn.de\/wp-content\/uploads\/2022\/05\/image-3.png 864w, https:\/\/timo-brunn.de\/wp-content\/uploads\/2022\/05\/image-3-300x193.png 300w, https:\/\/timo-brunn.de\/wp-content\/uploads\/2022\/05\/image-3-768x494.png 768w\" sizes=\"auto, (max-width: 864px) 100vw, 864px\" \/><\/figure>\n\n\n\n<p>Danach landen wir auf der Loginseite vom Zabbix und K\u00f6nnen uns mit dem Benutzername &#8222;<strong>Admin<\/strong>&#8220; und dem Passwort &#8222;<strong>zabbix<\/strong>&#8220; einloggen<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full is-style-twentytwentyone-border\"><img loading=\"lazy\" decoding=\"async\" width=\"364\" height=\"420\" src=\"http:\/\/192.168.41.160:8081\/wp-content\/uploads\/2022\/05\/image-4.png\" alt=\"\" class=\"wp-image-130\" srcset=\"https:\/\/timo-brunn.de\/wp-content\/uploads\/2022\/05\/image-4.png 364w, https:\/\/timo-brunn.de\/wp-content\/uploads\/2022\/05\/image-4-260x300.png 260w\" sizes=\"auto, (max-width: 364px) 100vw, 364px\" \/><\/figure>\n<\/div>\n<\/div>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Vorwort F\u00fcr das Monitoring meiner Systeme habe ich mich f\u00fcr Zabbix entschieden. In diesem Eintrag geht es um die Installation eines einfachen Zabbix Servers auf AlmaLinux 8.5. Als Datenbank nutzen wir eine MariaDB. Als Webserver einen NGINX. Installation MariaDB Zum aktuellen Datum ist in den AlmaLinux 8.5 Repos eine MariaDB 10.3.28 als Standardmodul vorhanden.Zabbix braucht [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,12,31,40,5,4,28],"tags":[17,15,14,16],"class_list":["post-45","post","type-post","status-publish","format-standard","hentry","category-almalinux","category-german","category-linux","category-netzwerk","category-nginx","category-webserver","category-zabbix","tag-centos","tag-deutsch","tag-german","tag-nginx"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/timo-brunn.de\/index.php\/wp-json\/wp\/v2\/posts\/45","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/timo-brunn.de\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/timo-brunn.de\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/timo-brunn.de\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/timo-brunn.de\/index.php\/wp-json\/wp\/v2\/comments?post=45"}],"version-history":[{"count":20,"href":"https:\/\/timo-brunn.de\/index.php\/wp-json\/wp\/v2\/posts\/45\/revisions"}],"predecessor-version":[{"id":281,"href":"https:\/\/timo-brunn.de\/index.php\/wp-json\/wp\/v2\/posts\/45\/revisions\/281"}],"wp:attachment":[{"href":"https:\/\/timo-brunn.de\/index.php\/wp-json\/wp\/v2\/media?parent=45"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/timo-brunn.de\/index.php\/wp-json\/wp\/v2\/categories?post=45"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/timo-brunn.de\/index.php\/wp-json\/wp\/v2\/tags?post=45"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}