CentOS下Zabbix Proxy部署记录
Zabbix Proxy
zabbix是一个分布式的监控系统,其支持通过代理服务器zabbix proxy 来收集zabbix agent的数据,然后zabbix proxy再把收集保存在本地数据库的数据送往zabbix server进行统一存储和展示。单一的zabbix server+ zabbix agent的环境,因受限于zabbix server性能瓶颈的缘故,其能管控的zabbix agent是有限的。而zabbix proxy则把zabbix server从收集数据这一功能中抽离出来,使得zabbix server专注于对数据进行存储和展示,提升了zabbix server所能管控的zabbix agent数据及提高了部署的灵活性。
新增zabbix proxy服务器,修改之前部署配置的zabbix server和agent来调用zabbix proxy服务器,从而让zabbix server 从zabbix proxy上获取其收集到的zabbix agent数据。
创建Zabbix用户
groupadd zabbix
useradd -g zabbix -M -s /sbin/nologin zabbix
安装依赖
# yum install fping unixODBC OpenIPMI-libs
# rpm -ivh mysql-community-common-8.0.17-1.el7.x86_64.rpm
# rpm -ivh mysql-community-libs-8.0.17-1.el7.x86_64.rpm
warning: mysql-community-libs-8.0.17-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
mariadb-libs is obsoleted by mysql-community-libs-8.0.17-1.el7.x86_64
# rpm -qa | grep mariadb
mariadb-libs-5.5.56-2.el7.x86_64
# rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64
# rpm -ivh mysql-community-libs-8.0.17-1.el7.x86_64.rpm
# rpm -ivh mysql-community-devel-8.0.17-1.el7.x86_64.rpm
# rpm -ivh mysql-community-client-8.0.17-1.el7.x86_64.rpm
# mysql -V
mysql Ver 8.0.17 for Linux on x86_64 (MySQL Community Server - GPL)
编译安装
# tar -zxf zabbix-4.2.5.tar.gz
# cd zabbix-4.2.5/
# ./configure --prefix=/usr/local/zabbix --enable-proxy --enable-agent --with-mysql --with-net-snmp=/usr/local/net-snmp/bin/net-snmp-config --with-libcurl=/usr/local/curl/bin/curl-config --with-libxml2=/usr/local/libxml2/bin/xml2-config --with-libevent=/usr/local/libevent/ --enable-java
# make & make install
添加库搜索路径
# vim /etc/ld.so.conf.d/local.conf
# ldconfig
/usr/local/net-snmp/lib
/usr/local/libevent/lib
/usr/local/libmcrypt/lib
# /usr/local/zabbix/sbin/zabbix_proxy -V
zabbix_proxy (Zabbix) 4.2.5
Revision 2c0e4d1d39 29 July 2019, compilation time: Aug 1 2019 21:22:21
Copyright (C) 2019 Zabbix SIA
License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it according to
the license. There is NO WARRANTY, to the extent permitted by law.
创建数据库
> create user 'zabbix_proxy'@'192.168.%.%' identified by 'zabbix@2019';
> create database zabbix_proxy character set utf8 collate utf8_bin;
> grant all privileges on `zabbix_proxy`.* to 'zabbix_proxy'@'192.168.%.%';
> flush privileges;
导入数据库
# mysql -uzabbix_proxy -pzabbix@2019 -h192.168.165.239 zabbix_proxy < ./database/mysql/schema.sql
编辑配置zabbix proxy的配置文件
# vim /usr/local/zabbix/etc/zabbix_proxy.conf
ProxyMode=0 #指定代理那种模式的agent,0为主动模式,1位被动模式
Server=192.168.16.30 #zabbix server服务器的地址或主机名
Hostname=HZ_Proxy #代理服务器的名称
LogFile=/tmp/zabbix_proxy.log
DBHost=192.168.16.25 #数据库服务器地址
DBName=zabbix_proxy
DBUser=zabbix_proxy
DBPassword=zabbix@2019
ProxyLocalBuffer=3
ProxyOfflineBuffer=24
HeartbeatFrequency=60 #心跳间隔检测时间,默认为60秒,范围为0-3600秒,被动模式不使用
ConfigFrequency=5 #间隔多久从zabbix server获取监控信息
DataSenderFrequency=5 #数据发送时间间隔,默认为1秒,被动模式不使用
StartPollers=10 #启动的线程数据,建议与客户端的数量保持一致
Timeout=30
LogSlowQueries=3000
启动zabbix proxy 服务
# /usr/local/zabbix/sbin/zabbix_proxy -c /usr/local/zabbix/etc/zabbix_proxy.conf
# ps -ef | grep zabbix_proxy | awk '{print $2}' | xargs kill -9
在zabbix server上添加代理服务器
(1)添加proxy服务器:Administration
-> Proxies
-> Create proxy
(右上角) -> Proxy name
填写配置的HZ_Proxy
(2)修改监控主机的使用代理监控:Configuration
-> Hosts
-> 点击编辑Host -> Host
选项卡下Monitored by proxy
从(no proxy)
改为HZ_Proxy
(3)修改此前为被动模式监控的监控模板:Templates
选项卡下Select
模板Template OS Linux
-> Add
-> Update
修改zabbxi agent的配置
在192.168.16.31上修改其对应的agent配置:
# vim /usr/local/zabbix/etc/zabbix_agentd.conf
#修改其server和serveractive的配置均指向代理服务器
Server=192.168.16.33
ServerActive=192.168.16.33
随后重启zabbix agent服务:
# /etc/init.d/zabbix_agentd restart
在192.168.16.32上修改其对应的agent配置:
# vim /usr/local/zabbix/etc/zabbix_agentd.conf
Server=192.168.16.33
ServerActive=192.168.16.33
随后重启zabbix agent服务:
# /etc/init.d/zabbix_agentd restart
版权声明:
作者:Joe.Ye
链接:https://www.appblog.cn/index.php/2023/03/25/zabbix-proxy-deployment-record-under-centos/
来源:APP全栈技术分享
文章版权归作者所有,未经允许请勿转载。
共有 0 条评论