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://www.cnblogs.com/architectforest/p/12912560.html

 

說明:劉宏締的架構森林是一個專注架構的博客,地址:https://www.cnblogs.com/architectforest

         對應的源碼可以訪問這里獲取: https://github.com/liuhongdi/

說明:作者:劉宏締 郵箱: 371125307@qq.com

 

二,受控端上(運行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

 

三,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.

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM