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

CentOS 7.8 to build Zabbix proxy server

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

Share

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

Zabbix proxy server

One: an overview of agency

Zabbix proxy can collect performance and availability data instead of zabbix server, then report the data to zabbix server, and share the pressure of zabbix server to some extent.

In addition, when all agents and proxies are reported to a Zabbix server and all data is collected centrally, after proxy collects the data, it first caches the data locally and then passes it to zabbix server after a certain amount of time, so that the data is not lost due to any temporary communication problems on the server. Using proxy is the easiest way to achieve centralized and distributed monitoring.

Zabbix proxy usage scenarios:

Monitor remote area equipment

Monitor unstable areas of the local network

When zabbix monitors thousands of devices, use it to relieve pressure on server

Simplify the maintenance of distributed monitoring

Zabbix proxy only needs a tcp to connect to the zabbix server, and only a rule needs to be added to the external network connection firewall.

Second, install the proxy server Proxy

Installation environment:

1. System environment: CentOS Linux release 7.5.1804 (Core)

2. Zabbix version: zabbix-release-3.4-2.el7.noarch

3. In the test environment, the firewall is turned off (it is not recommended to turn it off in the production environment, set the firewall according to the requirements)

[root@centos78 ~] # systemctl stop firewlld.service turn off the firewall

[root@centos78 ~] # systemctl disable firewalld.service boot disable firewall startup

4. Close Selinux

[root@centos78 ~] # sed-I's etc/selinux/config'/ etc/selinux/config

[root@centos78 ~] # setenforce 0

Install the database

1. Specify that the download version of the database should be the same as that of zabbix-server, and edit the installation package download path:

[root@centos78 ~] # vim / etc/yum.repos.d/base.repo (no base.repo can be created by yourself)

[mariadb]

Name = MariaDB

Baseurl = http://yum.mariadb.org/10.2/centos7-amd64

Gpgkey = https://yum.mariadb.org/RPM-GPG-KEY-MariaDB

Gpgcheck = 1

2. Install mariadb 10.2

Yum install mariadb-server

3. Set mariadb

[root@centos78 ~] # systemctl start mariadb start

[root@centos78 ~] # systemctl enable mariadb setting boot

[root@centos78 ~] # systemctl status mariadb to view startup status

Install and set up the Proxy server

1. Download and install Zabbix

[root@centos78 ~] # rpm-ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm (download the latest version of Zabbix)

[root@centos78 ~] # yum install zabbix-proxy-mysql-y

2. Create and import data

[root@centos78 ~] # mysql

Welcome to the MariaDB monitor. Commands end with; or\ g.

Your MariaDB connection id is 8

Server version: 10.2.17-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.

MariaDB [(none)] > create database zabbix_proxy character set utf8 collate utf8_bin; create database zabbix_proxy

Query OK, 1 row affected (0.00 sec)

MariaDB [(none)] > grant all privileges on zabbix_proxy.* to zabbix@localhost identified by 'zabbix'; sets zabbix_proxy permissions and password

Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)] > exit exit

Bye

Import database

[root@centos78 ~] # zcat / usr/share/doc/zabbix-proxy-mysql-3.4.14/schema.sql.gz | mysql- uzabbix-pzabbix zabbix_proxy

Configure database users and passwords

[root@centos78 ~] # vim / etc/zabbix/zabbix_proxy.conf modify configuration file and set password

DBPassword=zabbix

[root@centos78 ~] # grep-n'^'[a Murz] / etc/zabbix/zabbix_proxy.conf to view key configuration information

24:Server=192.168.1.1, this is the ip address of the Zabbix server.

42:Hostname=centos78, this is the hostname of the proxy itself.

84:LogFile=/var/log/zabbix/zabbix_proxy.log

95:LogFileSize=0

136:PidFile=/var/run/zabbix/zabbix_proxy.pid

146:SocketDir=/var/run/zabbix

166:DBName=zabbix_proxy

181:DBUser=zabbix

190:DBPassword=zabbix

390:SNMPTrapperFile=/var/log/snmptrap/snmptrap.log

466:Timeout=4

508:ExternalScripts=/usr/lib/zabbix/externalscripts

544:LogSlowQueries=3000

Start zabbix and set boot up

[root@centos78 ~] # systemctl start zabbix-proxy

[root@centos78 ~] # systemctl enable zabbix-proxy

3. Configure the zabbix_proxy.conf file

Sed-i.ori '190a DBPassword=zabbix' / etc/zabbix/zabbix_proxy.conf Line 190 insert DBPassword

Sed-I is the IP address (or hostname) of Zabbix server, not the ip of Zabbix proxy.

Sed-I 's#Hostname=Zabbix proxy#Hostname=centos78#' / etc/zabbix/zabbix_proxy.conf this Zabbix proxy hostname, unique, case-sensitive, make sure the server side knows its name! Allowed symbols: alphanumeric,'.,','_ 'and' -'. Maximum length: 64, which often goes wrong here.

Restart the service after modification:

[root@centos78 ~] # systemctl restart zabbix-proxy.service

Check the startup:

[root@centos78 ~] # netstat-lntup | grep zabbix

Tcp 00 0.0.0.0 10050 0.0.0.015 * LISTEN 2190/zabbix_agentd

Tcp 00 0.0.0.0 10051 0.0.0.015 * LISTEN 12789/zabbix_proxy

Tcp6 00: 10050: * LISTEN 2190/zabbix_agentd

Tcp6 00: 10051: * LISTEN 12789/zabbix_proxy

3. The client host configuration file points to proxy

[root@centos78 ~] # vim / etc/zabbix/zabbix_agentd.conf

Server=192.168.1.78 here points to the proxy server IP, which collects information through the agent.

ServerActive=192.168.1.78

Hostname=centos78

4. Server web interface: add agent agent

The proxy server was detected a few minutes later:

Create another auto-discovery rule:

Through automatic discovery, it can be automatically added to the custom grouping through the agent's client, as shown in the following tutorial:

Zabbix auto-discovery and auto-registration

For more and more monitoring servers, if one is added separately, the efficiency is too low, so it is necessary to add monitoring servers in batches. Zabbix provides two ways of batch automatic monitoring:

Automatic discovery: initiated by the server, Zabbix Server starts the discovery process and regularly scans IP servers and devices in the local area network.

Auto-registration: initiated by the client, the client must install and start Agentd, otherwise it cannot be added to the host list by auto-registration. Auto-discovery is about to be used for those who use SNMP.

I. client configuration specifies the server

Specify the Zabbix server configuration information in zabbix_agentd.conf, which needs to be modified in bulk when the client is installed in the previous batch.

Server=192.168.101.78 ServerActive=192.168.101.78 HostMetadataItem=system.uname

HostMetadataItem host metadata

When the agent program sends an auto-registration request to the server, it sends its hostname. In some cases, the hostname of the Zabbix server is not sufficient to distinguish between discovered hosts. Host metadata can send additional information from the agent to the server.

Host metadata is configured in zabbix_agentd.conf. There are two ways to specify host metadata in the configuration file: (both cannot be used at the same time)

HostMetadataItem:HostMetadataItem=system.unamesystem.uname is used to get information such as "Linux" or "Windows", depending on the host running agent. Examples of host metadata are as follows: Linux: Linux server3 3.2.0-4-686-pae # 1 SMP Debian 3.2.41-2 i686 GNU/LinuxWindows: Windows WIN-0PXGGSTYNHO 6.0.6001 Windows Server 2008 Service Pack 1 Intel IA-32HostMetadata: optional parameters are used to define host metadata, which is used only when the host is automatically registered. If it is not defined, the value is obtained through HostMetadataItem. Set up different templates for grouping according to requirements: HostMetadata=Linux or HostMetadata=Windows or HostMetadata=Router or HostMetadata=SMNP

Second, automatic discovery

1. Add auto-discovery rules

Update interval: 120s-300s. If the server performance is not good, you can set it for a longer time.

System.uname: this is used to match the client.

2. Create an automatic discovery action

A. add linux host auto-discovery rules

Operation: add hosts, Linux server groups, templates, and other settings.

B. Add Windows auto-discovery rules:

Action: add Windows server grouping

3. View the client diary information: active has been connected

View server information: has been automatically added to Windows server and Linux server groups

3. Automatic registration:

Initiated by the client, the client must install and start Agentd, otherwise it cannot be automatically registered and added to the host list.

1. The active Zabbix agent can be automatically registered with the server for monitoring. This approach eliminates the need to manually configure them on the server.

2. If you use SNMP or other means of monitoring, you cannot use auto-registration, you can only use auto-discovery.

3. Configure-Action-automatically register-create an action

Name: Auto Linux server

Condition: host metadata is similar to Linux

Action: add host

Action: add to host group: Linux server

Action: link to template: Template OS Linux

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