ZABBIX quick start deployment

Time:2020-10-25

For some special reasons, part of the environment is not built on the cloud, but on the hosted physical machine, which leads to many things that the cloud can help us to do, now we have to do them ourselves.
For example: monitoring system.

in line withDo not want to be the front end of operation and maintenance is not a good full stackI urgently need to build a complete set of monitoring system to liberate my hands.

What do I want this monitoring system to look like?

  1. Free open source
  2. Getting started is relatively easy
  3. Support multi platform distributed monitoring

Considering the above requirements, I finally choseZabbix

Looking around the Internet, we didn’t find a suitable introductory tutorial. Either the tutorial was too old or the writing was not detailed enough. The learning curve was very steep. It was very hard to deploy. However, ZABBIX’s important thing was not to deploy, but to learn how to use it.

So this note is for quick deployment of ZABBIX.

Meet ZABBIX

ZabbixIt is an enterprise level distributed open source monitoring scheme.

A complete monitoring system is composed of a service machine (ZABBIX server) and a client (ZABBIX zgent). The operation process is as follows:
zabbix agentIt needs to be installed on the monitored host, which is responsible for collecting various data on a regular basis and sending it to thezabbix serverThe ZABBIX server stores the data in its own database,zabbix web According to the data, display and plot in the front end. There are two modes for agent to collect data: active and passive

  • Active: the agent requests the server to obtain the active list of monitoring items, and actively submits the data to be detected in the monitoring items to the server / proxy.
  • Passive: the server requests the agent to obtain the data of monitoring items, and the agent returns the data.

working principle:

ZABBIX quick start deployment

install

System environment:

  • Ubuntu 18.04 LTS
  • Mysql 5.7
  • PHP 7.2
  • Nginx
  • Zabbix 5.0

1. Install the database

Before formal installation, it is recommended to go firstOfficial websiteFind your own ZABBIX server platform.

ZABBIX quick start deployment

According to their own actual environment to find their own download links, such as I amZabbix 5.0 + Ubuntu 18.04 + Mysql + Nginx, so my installation method should be:

$ wget https://repo.zabbix.com/zabbix/5.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_5.0-1+bionic_all.deb
$ dpkg -i zabbix-release_5.0-1+bionic_all.deb
$ apt update

2. Install ZABBIX server, web front end and agent

$ apt install zabbix-server-mysql zabbix-frontend-php zabbix-nginx-conf zabbix-agent
  • ZABBIX server: used to receive and process data from ZABBIX agent
  • Web front end: ZABBIX’s interactive interface
  • ZABBIX agent: the host that needs to be monitored

3. Initial database

After installing the database, you can’t log in directly because you don’t know the password of the root user, so you need to reset the password of the root user. There are many ways to reset the password. Here, I recommend the one I often use.

# vim /etc/mysql/conf.d/mysql.conf  
#Maybe the name of the configuration file you edited is different from mine, but it doesn't matter.

#Add the following two lines of configuration
[mysqld]
skip-grant-tables

Restart MySQL service:

$ service mysql restart

Now the root user has no password, so the next step is to change the password of the root user

$ mysql -hlocalhost -uroot -p

mysql > UPDATE mysql.user SET authentication_string=PASSWORD('password'), plugin='mysql_native_password' WHERE User='root' AND Host='localhost';

Then modify the configuration file again, comment out the following line of configuration, and finally restart the MySQL service.

The default user of MySQL is root. It is not recommended to use the root user to manage the ZABBIX database directly. Therefore, it is recommended to create a new user to manage the database

$ mysql -hlocalhost -uroot -p

mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> create user [email protected] identified by 'password';
mysql> grant all privileges on zabbix.* to [email protected];
mysql> flush privileges;
mysql> quit;

Here, by default, MySQL runs on the local machine. If MySQL runs in the container and ZABBIX runs on the local machine, some exceptions may occur (I encountered them but failed to solve them).

Import the initial schema and data.

$ zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix

4. Configuration database

Configure the database for ZABBIX server,

# vim /etc/zabbix/zabbix_server.conf

DBPassword=password

5. Configure Web

# vim /etc/zabbix/nginx.conf

#Remove the previous comment and replace it with your own port or domain name.
# listen 80;
# server_name example.com;

6. Configure time zone

# vim /etc/zabbix/php-fpm.conf

php_value[date.timezone] = Asia/Shanghai

7. Start the service

Start ZABBIX server and agent processes, and set them to start automatically

$ systemctl restart zabbix-server zabbix-agent nginx php7.2-fpm
$ systemctl enable zabbix-server zabbix-agent nginx php7.2-fpm

When you’re ready, you can visit:http://server_ip_or_nameIf the above configuration is not port 80, remember to add the corresponding port. If you can’t access it properly, it may be because the firewall doesn’t allow the port.

For the first time, you need to configure the relevant parameters. After confirming that there is no error, click next step.

ZABBIX quick start deployment

The default user name and password for ZABBIX isAdminzabbixAfter logging in to the background successfully, remember to change the default login password.

Configure Chinese language pack

If you need to set up the Chinese version of the environment, you need to do some additional configuration.

$ vim /usr/share/zabbix/include/locales.inc.php

Will_ Change the parameter after CN to true.

If you still can’t select a language when you select it, you will be prompted:

You are not able to choose some of the languages, because locales for them are not installed on the web server.

This is because there is no Chinese environment in your system. Check all the current system language environments

$ locale -a 

ZABBIX quick start deployment

1. Install Chinese package/

apt-get install language-pack-zh-hant language-pack-zh-hans

2. Configure environment variables

Add language and encoding settings:

# vim /etc/environment

LANG="zh_CN.UTF-8"
LANGUAGE="zh_CN:zh:en_US:en"

3. Replace ZABBIX language pack

$ cd cd /usr/share/zabbix/locale/zh_CN/LC_MESSAGES
$ wget https://github.com/echohn/zabbix-zh_CN/archive/v0.1.0.zip
$ unzip master.zip
$ rm frontend.mo
$ cp zabbix-zh_CN-master/frontend.mo frontend.mo

4. Solve the problem of garbled code

$ wget https://github.com/chenqing/ng-mini/blob/master/font/msyh.ttf
$ vim /usr/share/zabbix/include/defines.inc.php

#Find define ('zbx_ GRAPH_ FONT_ NAME', 'graphfont');
#Replace graphifont with msyh

5. Update MIBs database

$ apt-get install snmp-mibs-downloader

6. Restart the service

$ systemctl restart zabbix-server zabbix-agent php7.2-fpm

At this point, the complete deployment process of ZABBIX is introduced.

Reference link

Recommended Today

Application of Linux page cache tuning in Kafka

This article starts with WeChat official account of vivo Internet technology.Link:https://mp.weixin.qq.com/s/MaeXn-kmgLUah78brglFkg Author: Yang Yijun This paper mainly describes the background of Linux page cache optimization, the basic concept of page cache, lists some solutions for the IO performance bottleneck of Kafka, how to adjust the relevant parameters of page cache, and the effect comparison before […]