Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Detailed explanation of building zabbix monitoring system

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

If you want to understand the running status of the server in real time and solve problems in time, the use of monitoring software is a good choice, and zabbix monitoring system stands out among many monitoring software.

Zabbix is an enterprise-level open source monitoring software based on web interface. Zabbix server needs LAMP environment or LNMP environment to provide distributed system monitoring and network monitoring functions. With host performance monitoring, network equipment performance monitoring, database performance monitoring, a variety of alarm methods, detailed reports, chart drawing and other functions. The monitoring objects can be Linux or Windows servers, routers, switches and other network devices. The monitoring and data collection functions of remote network servers are provided by means of SNMP, zabbix Agent, PING, port monitoring and so on.

1. Zabbix monitoring architecture:

In a production environment, zabbix is divided into three architectures according to external factors such as network environment and monitoring scale: server-client (direct connection), master-node-client (Node architecture) and server-proxy-client (proxy architecture), as shown in the following figure:

1. Server-client architecture:

Server-client architecture is the simplest architecture of zabbix. Without any agent, the monitoring machine and the monitored computer can exchange data directly between zabbix server (monitoring server) and zabbix agent (agent: deployed on the monitored side to collect data). It is suitable for the monitoring environment where the network is simple and there are few devices.

2. Master-node-client architecture:

Master-node-client architecture is the most complex monitoring architecture of zabbix, which is suitable for large-scale environments with more devices and across networks and computer rooms. Each node is also a server, which can be connected to proxy or client directly under node. Node has its own configuration file and database, and all it needs to do is synchronize configuration information and monitoring data to master. When master goes down, node can guarantee the integrity of the architecture.

3. Server-proxy-client architecture:

Proxy is a bridge between server and client. Proxy itself does not have a front end, and it does not store data itself. It only temporarily stores the data sent by agentd, and then submits it to server. This architecture is often compared with the master-node-client architecture, and is generally suitable for the monitoring of medium-sized network architecture across computer rooms and networks.

2. Set up a Zabbix monitoring server:

There are two ways to configure the server-client architecture:

1. Configure the local yum repository for installation (the server does not need to connect to the Internet)

2. Directly use the Internet as a yum repository, and then install it. This is the way the official documents of zabbix adopt.

Zabbix4.2 related configuration document: https://www.zabbix.com/documentation/4.2/manual/it_services

Method 1 to install zabbix server: use local yum to build Zabbix3.4

Preparatory work:

1. Download the YumSource required for zabbix:

Https://pan.baidu.com/s/1O5hJ0O2OcKpeBOlzDfcGQQ

Extraction code: buqc

Zabbix client package, client programs including Windows and Linux, as well as fonts required for web pages

Https://pan.baidu.com/s/1UC9lrc0QDUdGEO5NVa1kQQ

Extraction code: vprm

2. Configure the firewall to release traffic. For convenience, it is turned off directly.

The environment is as follows: (sorry here, ha, because of special circumstances, the experimental environment is different, of course, only the IP has changed, if you want to do it, you can pay attention to it.)

Start building the zabbix server:

[root@zabbix /] # vim / etc/yum.repos.d/a.repo # write yum local warehouse [zabbix] baseurl= file:///mediagpgcheck=0[root@zabbix /] # mount / dev/sr0 / media/ # Mount the zabbix yum source to the native [root@zabbix /] # yum-y install mariadb-server mariadb # since zabbix requires LAMP or LNMP ring, install a MySQL, also known as mariadb I'm sure you all know what it means. [root@zabbix /] # yum-y install zabbix-server-mysql zabbix-web-mysql zabbix-agent # when installing zabbix, there are many dependent packages, including httpd and php related packages, so you can install zabbix directly. No need to install httpd and php [root @ zabbix /] # mysql-u root-pEnter password: # enter the password MariaDB [(none)] > create database zabbix character set utf8 collate utf8_bin # create a database for zabbix, specified as utf-8Query OK, 1 row affected (0.00 sec) MariaDB [(none)] > grant all privileges on zabbix.* to zabbix@localhost identified by '123123' # create a zabbix user And give ownership to Query OK 0 rows affected (0.00 sec) MariaDB [(none)] > exitBye [root@zabbix /] # zcat / usr/share/doc/zabbix-server-mysql-3.4.1/create.sql.gz | mysql- uzabbix-p zabbix Enter password: # enter the password of the zabbix user # Import database SQL script to zabbix database [root@zabbix /] # cp / etc/zabbix/zabbix_server.conf / etc/zabbix/zabbix_server.conf.bak # back up a copy of the main configuration file To avoid error correction [root@zabbix /] # vim / etc/zabbix/zabbix_server.conf # modify the following items. / / omit part of the content DBHost=localhostDBName=zabbixDBUser=zabbixDBPassword=123123

To edit the configuration file for zabbix agent, you must specify the IP address of zabbix server, which must be configured on each host on which agent is installed. Here, you want to specify the IP address of the zabbix server, which is now on the same server, so you can leave it unmodified:

[root@zabbix /] # cp / etc/zabbix/zabbix_agentd.conf / etc/zabbix/zabbix_ agentd.conf.bak [root @ zabbix/] # vim / etc/zabbix/zabbix_agentd.confServer=127.0.0.1 / / client passively waits for specified server to query data ServerActive=127.0.0.1 / / client actively submits data to specified server Hostname=linux-server001 / / modifies host name, configuration specification

Configure the zabbix web interface:

[root@zabbix /] # vim / etc/httpd/conf.d/zabbix.conf # sets the time zone consistent with the current system time zone. / / omit part of php_value date.timezone Asia/Shanghai [root@zabbix /] # systemctl start zabbix-server # Startup Service [root@zabbix /] # systemctl enable zabbix-server # Boot [root@zabbix /] # systemctl start zabbix-agent [root@zabbix /] # systemctl enable zabbix-agent [root@zabbix /] # systemctl start httpd # start related services to make the configuration effective

After installing zabbix, when the display language is Chinese, there may be Chinese garbled, mainly caused by the font. If you want to solve the problem, you need to download the appropriate font and upload it to the zabbix server.

[root@zabbix media] # cp simkai.ttf / usr/share/zabbix/fonts/ # copy the font file to zabbix font library [root@zabbix media] # ls / usr/share/zabbix/fonts/graphfont.ttf simkai.ttf [root@zabbix media] # vim / usr/share/zabbix/include/defines.inc.php # modify the font file specified by the PHP interface. / / omit part of the content define ('ZBX_GRAPH_FONT_NAME',' simkai'); / / font file name

Use the browser to configure zabbix:

As shown below, it is the home page of zabbix. By default, it is in English:

You can change it to Chinese by doing the following:

After the modification, refresh the interface and change it to Chinese.

Zabbix add monitored devices:

Configure the switch:

R1#conf tsw1 (config) # int vlan 1sw1 (config-if) # ip address 192.168.1.40 255.255.255.0sw1 (config-if) # no shutdown sw1 (config-if) # exitsw1 (config) # no ip routingsw1 (config) # snmp-server community centos RO / / set read-only Community sw1 (config) # snmp-server enable traps / / which is polled by the server to allow trap messages to be sent% Cannot enable both sham-link state-change interface traps.% New sham link interface trap not enabled.sw1 (config) # snmp-server host 192.168.1.20 centos / / sets the community that sends trap messages

The configuration of the router is similar to that of the switch, except that the router configuration IP needs to be configured on the interface.

Linux server configuration:

[root@localhost media] # rpm-ivh zabbix-agent-3.2.6-1.el7.x86_64.rpm [root@localhost /] # cp / etc/zabbix/zabbix_agentd.conf / etc/zabbix/zabbix_agentd.conf.bak # back up the file to avoid the error [root@localhost /] # vim / etc/zabbix/zabbix_agentd.conf # edit the configuration file. .. Server=192.168.1.20 ServerActive=192.168.1.20Hostname=linux-server002 [root@localhost /] # systemctl start zabbix-agent.service # Startup Service [root@localhost /] # systemctl enable zabbix-agent.service [root@localhost /] # netstat-anpt | grep agent # confirm that the port has started tcp 00 0.0.0.0 systemctl start zabbix-agent.service 10050 0.0.0 .0: * LISTEN 4114/zabbix_agentd tcp6 00: 10050:: * LISTEN 4114/zabbix_agentd

Windows server configuration:

After unzipping the downloaded agent agent package, you will see the following two files, in which there are two subdirectories in the "bin" directory, "win32" and "win64", which correspond to different system versions to see what you need according to the version of your system:

Copy out the files shown in the following figure, and modify the zabbix_agentd.win.conf file:

Modify the following three items:

Server=192.168.1.20ServerActive=192.168.1.20Hostname=windows-server001

Use the cmd command to install and start agent (common parameters are-c: specify configuration file;-I: install;-s: start;-x: stop;-d: uninstall):

C:\ zabbix > zabbix_agentd.exe-c zabbix_agentd.win.conf-izabbix_agentd.exe [2576]: service [Zabbix Agent] installed successfullyzabbix_agentd.exe [2576]: event source [Zabbix Agent] installed successfullyc:\ zabbix > zabbix_agentd.exe-c zabbix_agentd.win.conf-szabbix_agentd.exe [2300]: service [Zabbix Agent] started successfully

Configure the zabbix web side and add the monitored devices:

Add a switch:

Add a Linux server:

Add a Windows server:

When all monitoring hosts are connected successfully, it is shown in the following figure:

Method 2 to install zabbix server: use Internet as yum source to build zabbix version 4.2:

1. Prepare before configuration:

1. Configure zabbix server to connect to Internet

2. The files in the / etc/yum.repo/ directory that come with the system must have.

2. Start building:

[root@zabbix ~] # rpm-ivh https://repo.zabbix.com/zabbix/4.2/rhel/7/x86_64/zabbix-release-4.2-1.el7.noarch.rpm# installation repository configuration package [root@zabbix ~] # yum-config-manager-- enable rhel-7-server-optional-rpms# enables optional rpms repository [root@zabbix ~] # yum- y install mariadb-server mariadb# installs mariadb database [root@zabbix ~] # systemctl start mariadb # launch database [root@zabbix ~] # systemctl enable mariadb # set to boot [root@zabbix ~] # mysqladmin-u root password "pwd123" # set database root user password [root@zabbix ~] # yum-y install zabbix-server-mysql zabbix-web-mysql zabbix-agent# install zabbix server and agent agent To use the agent, you can also install zabbix-proxy-mysql on [root@zabbix] # mysql-u root-ppwd123 # login database MariaDB [(none)] > create database zabbix character set utf8 collate utf8_bin # create database MariaDB [(none)] > grant all privileges on zabbix.* to zabbix@localhost identified by 'pwd456';# create zabbix service users who connect to the database, and set the password. MariaDB [(none)] > exit # exit database [root@zabbix ~] # zcat / usr/share/doc/zabbix-server-mysql-4.2.4/create.sql.gz | mysql- uzabbix-p zabbix # Import database SQL script Enter password: # enter database user zabbix password [root@zabbix ~] # vim / etc/zabbix/zabbix_server.conf # Edit zabbix server configuration file # Note to delete comment symbol DBHost=localhost # remove comment symbol DBName=zabbix # database name According to the actual modification, the user name of DBUser=zabbix # database is not modified by default, and the DBPassword=pwd456 # database password is not modified by default. Modify this line # and save it after modification, and then save and exit.

Next, to edit the configuration file for zabbix agent, you must specify the IP address of zabbix server, which must be configured on each host on which agent is installed. Here, you want to specify the IP address of the zabbix server, which is now on the same server, so you can leave it unmodified:

[root@zabbix ~] # vim / etc/zabbix/zabbix_agentd.conf # Edit agentd configuration file # the purpose of editing this configuration file is to monitor the Zabbix server. Server=127.0.0.1 # client passively waits for specified server to query data ServerActive=127.0.0.1 # client actively submits data to specified server Hostname=linux-server001 # it is recommended to modify this line and configure the hostname of the specification

Configure the zabbix web interface and start the related services:

[root@zabbix ~] # vim / etc/httpd/conf.d/zabbix.conf # Edit http configuration file php_value date.timezone Asia/Shanghai # set to Shanghai time zone And delete the comment symbol [root@zabbix ~] # systemctl start httpd # start the httpd service [root@zabbix ~] # systemctl enable httpd # set boot self-boot [root@zabbix ~] # systemctl start zabbix-server # boot zabbix server [root@zabbix ~] # systemctl enable zabbix-server # set boot [root@zabbix ~] # systemctl start zabbix-agent # Start the agent agent [root@zabbix ~] # systemctl enable zabbix-agent # to set boot self-startup

If part of the Chinese garbled code appears on the web page, you can refer to the installation method one above, there is a way to solve the Chinese garbled code.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report