zabbix:以主动模式添加一台受监控主机 (zabbix5.0) 

一,zabbix被动模式和主动模式的区别?

       zabbix-agent默认的模式是被动模式,

        zabbix agent被动地接受zabbix server发来的指令,

       获取数据后再返回给zabbix server

       zabbix server会周期性地向agent索取数据

  主动模式:

       zabbix agent 主动采集数据并返回给zabbix server,

       不需要zabbix server 的另行干预

两者的性能比较:

被动模式的缺点:

会增加zabbix server的工作量,在有大量的服务器需要监控时,

zabbix server不能及时获取到最新的数据

主动模式能一定程度上减轻zabbix server的压力

说明:zabbix5.0在linux服务器上安装,参见:

https://blog.imgtouch.com/index.php/2023/05/22/centos8linuxlnmp-huan-jing-bian-yi-an-zhuang-zabbix50/

二,受控端上(运行zabbix-agent)的配置:

说明:

受控端(zabbix-agent)服务器ip: 121.122.123.87

控制端(zabbix-server)服务器ip: 121.122.123.47         

1,受控端上查看os版本

[root@web2 ~]# cat /etc/redhat-release
CentOS release 6.5 (Final)

2,把主控机器的ip添加到被监控机器的防火墙,

   至少要允许主控机器访问10050端口

 [root@web2 ~]# vi /etc/sysconfig/iptables

   添加一行:例如:

-I INPUT -p tcp -s 121.122.123.47 --dport 10050 -j ACCEPT

   然后重新加载iptables

[root@web2 ~]# service iptables reload
iptables: Trying to reload firewall rules:                 [  OK  ]

3,下载zabbix-agent

我们从清华的镜像站上下载,

地址:

https://mirrors.tuna.tsinghua.edu.cn/zabbix/

注意和server端保持版本一致

说明:因为不需要lnmp环境,我们选择下载rpm包后安装

创建安装包的保存目录

[root@web2 ~]# mkdir -p /usr/local/source/zabbix
[root@web2 ~]# cd /usr/local/source/zabbix

下载:

[root@web2 zabbix]# wget https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/5.0/rhel/6/x86_64/zabbix-agent-5.0.0-1.el6.x86_64.rpm

4,安装zabbix-agent

[root@web2 zabbix]# rpm -ivh zabbix-agent-5.0.0-1.el6.x86_64.rpm
warning: zabbix-agent-5.0.0-1.el6.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
Preparing...                ########################################### [100%]
   1:zabbix-agent           ########################################### [100%]

5,配置:

编辑配置文件

[root@web2 zabbix]# vi /etc/zabbix/zabbix_agentd.conf  

配置的内容:

Server=121.122.123.47
ListenPort=10050
StartAgents=0 
ServerActive=121.122.123.47
Hostname=web2

说明:

Server: 被动模式访问的zabbix-server的ip

ServerActive: 主动模式访问的zabbix-server的ip

StartAgents :zabbix_agentd用来处理被动检查的实例数量,

如果设置为0,则禁用被动模式检查而且agent不再监听任何tcp端口

附原说明:

### Option: StartAgents
#       Number of pre-forked instances of zabbix_agentd that process passive checks.
#       If set to 0, disables passive checks and the agent will not listen on any TCP port.

6,配置完成后,启动服务:

[root@web2 ~]# service zabbix-agent start
Starting Zabbix agent:                                     [  OK  ]

7,查看zabbix-agent的版本:

[root@web2 zabbix]# /usr/sbin/zabbix_agentd --version
zabbix_agentd (daemon) (Zabbix) 5.0.0
Revision 9665d62db0 11 May 2020, compilation time: May 11 2020 07:27:56

Copyright (C) 2020 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.

This product includes software developed by the OpenSSL Project
for use in the OpenSSL Toolkit (http://www.openssl.org/).

Compiled with OpenSSL 1.0.1e-fips 11 Feb 2013
Running with OpenSSL 1.0.1e-fips 11 Feb 2013

说明:刘宏缔的架构森林—专注it技术的博客,
网址:https://imgtouch.com
本文: https://blog.imgtouch.com/index.php/2023/05/22/zabbix-yi-zhu-dong-mo-shi-tian-jia-yi-tai-shou-jian-kong-zhu-ji-zabbix50/
代码: https://github.com/liuhongdi/https://gitee.com/liuhongdi
说明:作者:刘宏缔 邮箱: 371125307@qq.com

三,zabbix-server端的配置:

1,添加到防火墙:

说明:服务端所在的机器的os版本是centos8,使用firewalld,

不再是使用iptables

下面命令的作用:把受控端ip和要访问的主控端的端口加入到防火墙

[root@blog ~]# firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="121.122.123.87" port protocol="tcp" port="10051" accept'
success 
[root@blog ~]# firewall-cmd --reload
success

2,添加主机:

左侧菜单->配置->主机->创建主机

见截图:

主机页面:

主机名:web2

客户端:121.122.123.87

端口: 10050

模板页面:

选择:

template os linux by zabbix agent active

说明:注意要选择带active的模板

完成后点 添加 按钮

五,查看服务端的zabbix-server版本

[root@blog zabbix-5.0.0]# /usr/local/soft/zabbx-5.0.0/sbin/zabbix_server --version
zabbix_server (Zabbix) 5.0.0
Revision 9665d62db0 11 May 2020, compilation time: May 17 2020 09:37:03

Copyright (C) 2020 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.
QR:zabbix:以主动模式添加一台受监控主机 (zabbix5.0) 

发表回复