zabbix monitoring installation-linux

zabbix6.4 Chinese documentation 1. Introduction (zabbix.com)

Zabbix is an enterprise-grade open source distributed monitoring solution.

1.zabbix structure system

Server:

The server is the central repository for all configuration, statistics, and operational data.

Proxy:

Zabbix proxy can collect performance and availability data on behalf of Zabbix server. Proxies are an optional part of a Zabbix deployment; but are useful for spreading the load on a single Zabbix server.

Agent:

The Zabbix agent is deployed on the monitored target to actively monitor local resources and applications and report the collected data to the Zabbix server. Starting from Zabbix 4.4, two types of agents are available: Zabbix agent (lightweight, supported on many platforms, written in C) and Zabbix agent 2 (very flexible, easy to extend with plugins, written in Go).

Data Storage:

All configuration information and data collected by Zabbix is stored in the database.

Web interface:

For easy access from anywhere and any platform, Zabbix provides a web-based interface. This interface is part of the Zabbix server and usually (but not necessarily) runs on the same device as the server.

2. Source code installation

1. Download Zabbix sources

wget https://cdn.zabbix.com/zabbix/sources/stable/6.4/zabbix-6.4.8.tar.gz

Unzip the source code

tar -xvzf zabbix-6.4.8.tar.gz -C /opt/zabbix/

2. Create zabbix user

groupadd –system zabbix

useradd –system -g zabbix -d /usr/lib/zabbix -s /sbin/nologin -c “Zabbix Monitoring System” zabbix

3. Create Zabbix database

A database is required for serve, proxy and front-end

Zabbix supports a variety of databases, I choose mysql (8.00.30 +) here

The only encoding supported by Zabbix is UTF-8.

(1) Create zabbix database user and user

mysql> create database zabbix character set utf8mb4 collate utf8mb4_bin;

mysql> create user 'zabbix'@'localhost' identified by '123456';

mysql> grant all privileges on zabbix.* to 'zabbix'@'localhost';

mysql> SET GLOBAL log_bin_trust_function_creators = 1;

(2) Import data into the database. For Zabbix agent database, only schema.sql should be imported (not images.sql or data.sql). These SQL files are all in the source code folder database/mysql

Because my mysql is in a docker container, I have to do a few more steps.

Copy these SQL files into docker
[root@VM-12-12-centos mysql]# sudo docker cp /opt/zabbix/zabbix-6.4.8/database/mysql/data.sql 10d74d587551:/home/mysql/

[root@VM-12-12-centos mysql]# sudo docker cp /opt/zabbix/zabbix-6.4.8/database/mysql/images.sql 10d74d587551:/home/mysql/

[root@VM-12-12-centos mysql]# sudo docker cp /opt/zabbix/zabbix-6.4.8/database/mysql/schema.sql 10d74d587551:/home/mysql/

Import Data

bash-4.4# mysql -uzabbix -p123456 zabbix < /home/mysql/schema.sql

bash-4.4# mysql -uzabbix -p123456 zabbix < /home/mysql/images.sql bash-4.4# mysql -uzabbix -p123456 zabbix < /home/mysql/data.sql

After successfully importing the schema, you can disable log_bin_trust_function_creators:

SET GLOBAL log_bin_trust_function_creators = 0;

4. Configuration source code

To configure the source code for Zabbix server and agent, you can execute commands similar to the following:

/opt/zabbix/zabbix-6.4.8/configure –enable-server –enable-agent –with-mysql –enable-ipv6 –with-net-snmp –with-libcurl –with-libxml2 – -with-openipmi

If an error is reported, which library is missing, use yum to install it.

until displayed

****************************************************** ************
* Now run 'make install' *
* *
* Thank you for using Zabbix! *
* <http://www.zabbix.com> *
*************************************************** *********

indicates success

5.make and install source code

Compile and install

make install

6. Edit configuration file

  • Edit the Zabbix agent configuration file /usr/local/etc/zabbix_agentd.conf
LogFile=/tmp/zabbix_agentd.log

Server=127.0.0.1

ServerActive=127.0.0.1

Hostname=Zabbix server

  • Edit the Zabbix server configuration file /usr/local/etc/zabbix_server.conf
LogFile=/tmp/zabbix_server.log

DBHost=localhost

DBUser=zabbix

DBPassword=123456

DBSocket=/tmp/mysql8.sock

DBPort=3308

7. Start the daemon process

Start the server

shell> zabbix_server

Check whether the /tmp/zabbix_server.log log is opened successfully

enabling Zabbix agent checks on host “Zabbix server”: interface became available

Indicates successful opening

Start the client on the monitored machine

shell> zabbix_agentd

Check whether the /tmp/zabbix_agentd.log log is opened successfully

8. Install zabbix web interface

The Zabbix front-end is written in PHP, so running it requires a PHP-supported web server (Apache, Nginx).

The prerequisite is to install PHP7.4 + and one of Apache and Nginx

Then copy the zabbix web page php source code in the ui/ directory under the zabbix source code to a directory and start it with php

After starting, use the browser to enter the front-end URL to install

Complete the configuration and extension of PHP and just display OK

Configuration database

Download and save to specified location

Configuration completed.

The default username is Admin and the password is zabbix.

Home page

9. Solve the problem of Chinese garbled characters

We will find that when the web-side graphics display Chinese Garbled code!

This is because the font of this web PHP project is not friendly to Chinese support, so just find the font file in the directory where the web PHP project is located and replace it with a Chinese-friendly font.

solve:

Find the font for the zabbix web project

[root@VM-12-12-centos fonts]# ls
DejaVuSans.ttf
[root@VM-12-12-centos fonts]# pwd
/www/wwwroot/zabbix/assets/fonts

Find a thin Chinese font in the C:\Windows\Fonts\ directory of the Windows system and upload it to the server to replace DejaVuSans.ttf

[root@VM-12-12-centos fonts]# ls
DejaVuSans.ttf STXIHEI.TTF
[root@VM-12-12-centos fonts]# cp STXIHEI.TTF DejaVuSans.ttf
cp: overwrite DejaVuSans.ttf’? y
[root@VM-12-12-centos fonts]# ls
DejaVuSans.ttf STXIHEI.TTF
[root@VM-12-12-centos fonts]# rm -rf STXIHEI.TTF
[root@VM-12-12-centos fonts]# ls
DejaVuSans.ttf

Refresh the web page

Chinese can be displayed normally. . .