Linux monitoring platform - build zabbix monitoring platform

Chapter 19 Construction of Linux Monitoring Platform

19.1 Introduction to Linux Monitoring Platform

Common open source monitoring software

cacti, nagios, zabbix, smokeping, open-falcon, and more.
cacti and smokeping tend to be basic monitoring, and the graphics are beautiful.
The cacti, nagios, and zabbix server monitoring centers need php environment support. Both zabbix and cacti need mysql as data storage, nagios does not need to store historical data, and focuses on the status of services or monitoring items; zabbix will obtain the data of services or monitoring items so as to It can be graphed, zabbix records data in the database, supports historical data query, and zabbix can customize monitoring items very conveniently.
open-falcon was developed by Xiaomi. After open source, it is sought after by many large companies and operation and maintenance engineers. It is suitable for large enterprises. Big companies such as Didi, 360, Sina Weibo, JD.com use this monitoring software, and it is worth studying.
This section learns to take zabbix as an example.

19.2 Introduction to zabbix monitoring

Based on C++ development, zabbix is ​​a C/S (client/server) architecture, which is divided into client and server. A single server node can support tens of thousands of clients, and the monitoring center supports web UI (web interface) configuration and management.
Check out the official zabbix documentation: https://www.zabbix.com/manuals is the best way to learn zabbix.

zabbix components

There are the following 5 main roles in the whole architecture of zabbix:

zabbix-server
zabbix-server is the core component of the entire monitoring system. It is responsible for receiving report information sent by the client. All configuration, statistical data and operational data are organized by it.
Data storage (eg: mysql)
All information collected during monitoring is stored here.
web interface
web interface, or GUI. This is one of the reasons why zabbix monitoring is simple and easy to use, because we can configure and manage each client in the web interface. A PHP environment is required to run the web interface.
zabbix-proxy
zabbix-proxy is an optional component used to monitor a distributed environment with many nodes. It can proxy the functions of zabbix-server and reduce the pressure on zabbix-server.
zabbix-agent
zabbix-agent is a component deployed on each client, used to collect data of each monitoring project, and transmit the collected data to zabbix-proxy or zabbix-server.
monitoring process

mark

19.3-19.4 Install zabbix

Ready to work

Two machines: one is used as server (IP: 192.168.8.136), the other is used as client (IP: 192.168.8.138), zabbix is ​​installed on both, and the database is installed on the server (see the installation method: https://my.oschina.net /u/3497124/blog/1488479 ).

You can use yum to install zabbix, the version is 2.2, which is a bit old. Use the yum source of the corresponding version provided by zabbix to install a newer version of zabbix here.

Install zabbix on the server

Before installing zabbix, you need to install its yum source repository.

Download the yum repository of zabbix:
[root@z1 src]# wget http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm

Install yum source repository:
[root@z1 src]# rpm -ivh zabbix-release-3.2-1.el7.noarch.rpm

[root@z1 src]# ls /etc/yum.repos.d/
zabbix.repo

Install zabbix and its components:
[root@z1 src]# yum install -y zabbix-agent zabbix-get zabbix-server-mysql zabbix-web zabbix-web-mysql
#zabbix-agent: client program
#zabbix-get: service The tool to get the client detection project on the command line
#zabbix-server-mysql: zabbix-server MySQL version
#zabbix-web: web interface
#zabbix-web-mysql: web interface MySQL related
attention: this process will install PHP and http.
configure

Configure the server side:

Configure mysql:

[root@z1 src]# vim /etc/my.cnf
character_set_server = utf8 #Set
the default character set--the purpose is to assist the Chinese display of the web interface

Restart the mysql service:
[root@z1 src]# /etc/init.d/mysqld restart

Create a database:
[root@z1 ~]# mysql -uroot
mysql> create database zabbix character set utf8; #Create
a library and specify its character set

mysql> grant all on zabbix.* to 'zabbix'@'127.0.0.1' identified by '123456';
mysql> quit

Import raw data into the zabbix database:
[root@z1 ~]# cd /usr/share/doc/zabbix-server-mysql-3.2.7/ #Note
: This path is completed with the tab key

解压create.sql.gz包:
[root@z1 zabbix-server-mysql-3.2.7]# ls
AUTHORS ChangeLog COPYING create.sql.gz NEWS README
[root@z1 zabbix-server-mysql-3.2.7]# gzip -d create.sql.gz
[root@z1 zabbix-server-mysql-3.2.7]# ls
AUTHORS ChangeLog COPYING create.sql NEWS README

Import the decompressed data (create.sql) data into the zabbix library:
[root@z1 zabbix-server-mysql-3.2.7]# mysql -uroot zabbix < create.sql

启动zabbix服务:
[root@z1 zabbix-server-mysql-3.2.7]# systemctl start zabbix-server

启动http服务:
[root@z1 zabbix-server-mysql-3.2.7]# systemctl start httpd.service
[root@z1 zabbix-server-mysql-3.2.7]# netstat -lntp |grep httpd
tcp6 0 0 :::80 :::* LISTEN 2370/httpd

You can set zabbix, http and other services to start up:
[root@z1 zabbix-server-mysql-3.2.7]# systemctl enable zabbix-server.service
[root@z1 zabbix-server-mysql-3.2.7]# systemctl enable httpd.service
At this point, check the zabbix service status (ps, netstat) and find that the service is started, but there is no listening port, the status is abnormal, and the error is checked:

View the zabbix log:
[root@z1 zabbix-server-mysql-3.2.7]# less /var/log/zabbix/zabbix_server.log
2343:20170907:175923.056 database is down: reconnecting in 10 seconds
2343:20170907:175933.058 [Z3001 ] connection to database 'zabbix' failed: [2002] Can't connect to
local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
That is, cannot connect to mysql.
Solution:
Change the zabbix configuration file.

[root@z1 zabbix-server-mysql-3.2.7]# vim //etc/zabbix/zabbix_server.conf
DBHost=127.0.0.1 #Write
here the IP of the machine where zabbix is ​​located (zabbix may use the machine for a day alone in the production environment) #The
IP should be the same as the IP specified during database authorization
DBName=
zabbix DBUser=
zabbix DBPassword=123456

After the change is completed, restart the zabbix service:
[root@z1 zabbix-server-mysql-3.2.7]# systemctl restart zabbix-server.service
After the startup is complete, check its status (ps, netstat), normal (the server zabbix listens to port 10051 by default )!

Configure the web interface

Use a browser to access the IP on the server machine: 192.168.8.136/zabbix (make sure that the server has turned off the firewall before doing this) to enter the installation guide interface.

mark

Click "Next step" to enter the detection interface:

mark

Error: There is an error message here, the awareness is that "data.timezone" (timezone) is not recognized by PHP.

Workaround:
Edit the PHP configuration file, change the time zone:

[root@z1 ~]# vim /etc/php.ini
date.timezone =Asia/Shanghai

Restart the httpd service:
[root@z1 ~]# systemctl restart httpd.service
Browser refresh, problem solved! Then, continue to click "Next step" to configure the database information:

mark

Click "Next step" to set the server username (custom):

mark

Continue to click "Next step" until the prompt interface appears:

mark That is, the installation is complete!

Log in to zabbix on the server side

mark

Note: Administrator initial username and password (Admin: zabbix).

After logging in to zabbix, first change the administrator password:

mark

Click "Admin" to enter the following interface:

mark

Then click "changepassword":

mark

After the change is completed, "refresh", the interface is displayed as the set interface language: Chinese!

19.5 Forgot the server zabbix administrator password

If you forget the zabbix (web interface) administrator password, you can change the password through the database of the zabbix server!

[root@z1 ~]# mysql -uroot
switch library:
mysql> use zabbix;

Change password:
mysql> update users set passwd=md5('123456') where alias='Admin';
mysql> quit
done!
After the setting is complete, log in to zabbix with the new password in the browser, success!

19.6 zabbix client configuration

Install zabbix on the client

Before installing zabbix, you need to install its yum source repository.

Download the yum repository of zabbix:
[root@z1 src]# wget http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm

Install yum source repository:
[root@z1 src]# rpm -ivh zabbix-release-3.2-1.el7.noarch.rpm

Install zabbix:
[root@z2 ~]# yum install -y zabbix-agent
configuration

Edit the zabbix configuration file:

[root@z2 ~]# vim /etc/zabbix/zabbix_agentd.conf
Server=192.168.8.136 #Specify the server
host IP (set the client's monitoring host whitelist)
ServerActive =192.168.8.136 #This
parameter determines the active/passive monitoring Mode
#If you only change the parameter Server, you can only use passive mode (you can only wait for the server to collect information) #Active
mode: the client actively sends information to the server
Hostname=adai-02 #This
parameter is used to set the client The name of the host, which is used to add monitoring services to the server
#If the machine monitored by the server is inconsistent with its Hostname, the server will not recognize the machine
#Because zabbix is ​​monitored by IP, this parameter will not cause too much monitoring Influence
#Adding this parameter is beneficial to better identify the status of which host is monitored by the server

Start the zabbix service:
[root@z2 ~]# systemctl start zabbix-agent.service
Check the zabbix service status (ps, netstat), normal (the client zabbix listens to port 10050 by default)!

At this point, the construction of the zabbix monitoring architecture is basically over! ! !

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325244095&siteId=291194637