Zabbix. Zabbix 6 + Almalinux 8. Installation

Материал из Wiki
Перейти к навигации Перейти к поиску

Common settings

Selinux disable

sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config

reboot

Check selinux status

sestatus

Nginx

Installation

yum -y install nginx

systemctl start nginx

systemctl enable nginx

Check

curl http://localhost

PHP

dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm

dnf module list php

dnf module reset php

dnf module enable php:remi-8.1

yum -y install php php-fpm php-cli php-mysql php-gd php-ldap php-odbc php-pdo php-pecl-memcache php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap php-bcmath

systemctl start php-fpm

systemctl enable php-fpm

mv /etc/php-fpm.d/www.conf /etc/php-fpm.d/www.conf.ORIG

nano /etc/php-fpm.d/www.conf

[www]
user = nginx
group = nginx
;listen = 127.0.0.1:9000
listen = /var/run/php-fpm/php-fpm.sock
listen.mode = 0660
listen.owner = nginx
listen.group = nginx
listen.allowed_clients = 127.0.0.1
pm = dynamic
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35
slowlog = /var/log/php-fpm/www-slow.log
php_admin_value[error_log] = /var/log/php-fpm/www-error.log
php_admin_flag[log_errors] = on
php_value[session.save_handler] = files
php_value[session.save_path]    = /var/lib/php/session
php_value[soap.wsdl_cache_dir]  = /var/lib/php/wsdlcache

systemctl restart php-fpm

ll /var/run/php-fpm/php-fpm.sock

nano /etc/yum.repos.d/mariadb.repo

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.5/rhel8-amd64
module_hotfixes=1
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

yum -y install MariaDB-server MariaDB-client

systemctl start mariadb

systemctl enable mariadb

/usr/bin/mysql_secure_installation

mv /etc/my.cnf.d/server.cnf /etc/my.cnf.d/server.cnf.ORIG

nano /etc/my.cnf.d/server.cnf

[mysqld]
bind-address = 0.0.0.0
character_set_server=utf8
collation-server=utf8_bin
init_connect="SET NAMES utf8 collate utf8_bin"
port = 3306
socket = /var/lib/mysql/mysql.sock
innodb_file_format=barracuda
innodb_file_per_table=1
innodb_buffer_pool_size = 2G # set this value to half of the total amount of RAM
innodb_buffer_pool_instances=1
innodb_flush_log_at_trx_commit = 0
innodb_log_file_size = 512M
innodb_strict_mode = 0
innodb_log_files_in_group = 3

systemctl restart mariadb

systemctl status mariadb

Zabbix

Repo

rpm -Uvh https://repo.zabbix.com/zabbix/6.4/rhel/8/x86_64/zabbix-release-6.4-1.el8.noarch.rpm

Dnf cache clean

dnf clean all

dnf makecache

Installation

dnf install -y zabbix-server-mysql zabbix-web-mysql zabbix-sql-scripts

Create DB

mysql -uroot -p

> create database zabbix character set utf8 collate utf8_bin;

> grant all privileges on zabbix.* to zabbix@localhost identified by 'password';

> exit

DB Template deploy

zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql -uzabbix -p zabbix

Zabbix server settings

nano /etc/zabbix/zabbix_server.conf

Timeout - Waiting for a zabbix agent response

...
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=PassWord
ListenIP=0.0.0.0
Timeout=10
...

Zabbix server service

systemctl start zabbix-server

systemctl enable zabbix-server

Check log

cat /var/log/zabbix/zabbix_server.log

Nginx config

mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.ORIG

nano /etc/nginx/nginx.conf

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;
}

nano /etc/nginx/conf.d/default.conf

server {
   listen       80;
   server_name  zabbix.loc;
   root /usr/share/zabbix;
   location / {
   index index.php index.html index.htm;
   }
   location ~ \.php$ {
   fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
   fastcgi_index index.php;
   fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name;
   include fastcgi_params;
   fastcgi_param PHP_VALUE "
   max_execution_time = 300
   memory_limit = 128M
   post_max_size = 16M
   upload_max_filesize = 2M
   max_input_time = 300
   date.timezone = Europe/Moscow
   always_populate_raw_post_data = -1
   ";
   fastcgi_buffers 8 256k;
   fastcgi_buffer_size 128k;
   fastcgi_intercept_errors on;
   fastcgi_busy_buffers_size 256k;
   fastcgi_temp_file_write_size 256k;
       }
}

Nginx reload

nginx -s reload

You have to change permissions to make nginx work properly

chown -R nginx:nginx /var/lib/php/session

chown -R nginx:nginx /etc/zabbix/web

DNS

nano /etc/hosts

...
<Zabbix_local_IP> zabbix.loc
...

Firewall

firewall-cmd --permanent --zone=public --add-service=zabbix-server

firewall-cmd --reload

OR

systemctl stop firewalld

systemctl disable firewalld

Zabbix-agent

yum -y install zabbix-agent

systemctl start zabbix-agent

systemctl enable zabbix-agent

Next you can continue installation via Web

http://<Zabbix_local_IP>/