Installing Zabbix 4.2 and MySQL Server Percona 8 on Centos 7

Zabbix – a free system for monitoring and tracking the statuses of various services of a computer network, servers and network equipment, written by Alexei Vladyshev. MySQL, PostgreSQL, SQLite or Oracle Database are used to store data, the web interface is written in PHP.

Preparing to install Zabbix

Connecting EPEl and REMI repositories

[[email protected]]# yum -y install epel-release
[[email protected]]# yum -y install

Installing the necessary utilities

[[email protected]]# yum -y install htop nano mc wget zip unzip yum-utils

We connect the Zabbix repository and update

[[email protected]]# rpm -ivh
[[email protected]]# yum update

Zabbix frontend requires additional packages that are missing in the base installation. It is necessary to activate the repository of optional rpm packages on the system

[[email protected]]# yum-config-manager --enable rhel-7-server-optional-rpms

Installing MySQL Server Percona 8

Connect the Percona repository and switch to the Percona 8 version

[[email protected]]# rpm -ivh
[[email protected]]# percona-release setup ps80

Install Percona-server, run it and add it to startup

[[email protected]]# yum -y install percona-server-server
[[email protected]]# systemctl start mysqld
[[email protected]]# systemctl enable mysqld

We look at the default root password

[[email protected] ~]# grep -i password /var/log/mysqld.log
2019-08-07T10:03:19.576146Z 5 [Note] [MY-010454] [Server] A temporary password is generated for [email protected]: f.pjp.N?S1&q

We change it

[[email protected]]# mysql_secure_installation

We connect to MySQL, create a database, a user and set a password

[[email protected]]#  mysql -uroot -p'%your_password%'
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> create user 'zabbix'@'localhost' IDENTIFIED BY '%your_password%';
mysql> grant all privileges on zabbix.* to 'zabbix'@'localhost';
mysql> quit;

Installing Zabbix

Install Zabbix

[[email protected]]# yum -y install zabbix-server-mysql zabbix-web-mysql

Importing the original schema and server data into MySQL

[[email protected]]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix

Possible errors. At a certain point, I got an error:

Authentication plugin ‘caching_sha2_password’ cannot be loaded

Solution: Connect to the database and execute the command:

[[email protected]]#  mysql -uroot -p'%your_password%'
mysql> ALTER USER 'zabbix'@'localhost' IDENTIFIED WITH mysql_native_password BY '%your_password%';
mysql> quit;

We register the settings for connecting to the database in the Zabbix configuration file

[[email protected]]# nano /etc/zabbix/zabbix_server.conf

Launch Zabbix Server and add it to startup

[[email protected]]# systemctl start zabbix-server
[[email protected]]# systemctl enable zabbix-server

Apache configuration for Zabbix frontend is located in /etc/httpd/conf.d/zabbix.conf. In it, we need to uncomment and write our date.timezone value

[[email protected]]# nano /etc/httpd/conf.d/zabbix.conf
php_value date.timezone Europe/Moscow

Restarting the Apache web server

[[email protected]]# systemctl restart httpd

Open ports 80 and 443 in the firewall

[[email protected]]# firewall-cmd --zone=public --permanent --add-port=443/tcp
[[email protected]]# firewall-cmd --zone=public --permanent --add-port=80/tcp
[[email protected]]# firewall-cmd --reload

Now you can complete the Zabbix installation via the web interface. To do this, open the browser and go to: http: //% ip-adress% / zabbix

SELinux configuration

If the SELinux state is in forced mode, you need to run the following commands to allow connections between Zabbix frontend and server:

[[email protected]]# setsebool -P httpd_can_connect_zabbix on
[[email protected]]# setsebool -P httpd_can_network_connect_db on

Possible errors. When starting the zabbix server, an error appears in the logs:

cannot start alert manager service: Cannot bind socket to “/var/run/zabbix/zabbix_server_alerter.sock”

This is related to SELinix, we disable it:

[[email protected]]# setenforce 0
[[email protected]]# nano /etc/selinux/config

UPD: I found a solution on one of the forums, but did not test it

[[email protected]]# grep AVC /var/log/audit/audit.log* | audit2allow -M systemd-allow; semodule -i systemd-allow.pp

Installing Zabbix agent

Install Zabbix agent, start it and add it to startup

[[email protected]]# yum -y install zabbix-agent
[[email protected]]# systemctl start zabbix-agent
[[email protected]]# systemctl enable zabbix-agent

Default admin access in Zabbix:

Login: AdminPassword: zabbix