Linux安裝Zabbix客戶端


zabbix安裝完zabbix server服務端,剩下監控其他主機就需要安裝zabbix agent客戶端

zabbix agent需要部署在被監控主機上,負責將被監控主機的數據提交到zabbix server

zabbix工作模式:

agent端會將采集完的數據主動發送到server端,這種模式成為主動模式(agent端)

agent端可以不將采集完的數據發送到server端,而是等server來拉去數控,主動模式與被動模式可以一起存在,不沖突

管理員可以在agent端使用zabbix_sender工具測試是否能夠向server端發送數據

在server端使用zabbix_get工具,測試是否能夠從agent端拉去數據

本文主要安裝Zabbix agent在CentOS版本下:

 

創建zabbix用戶

[root@Mike-VM-Node1 ~]# groupadd zabbix
[root@Mike-VM-Node1 ~]# useradd -g zabbix -m zabbix

 

CentOS6安裝客戶端

[root@Mike-VM-Node1 ~]# rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/6/x86_64/zabbix-release-3.4-1.el6.noarch.rpm
Retrieving http://repo.zabbix.com/zabbix/3.4/rhel/6/x86_64/zabbix-release-3.4-1.el6.noarch.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:zabbix-release-3.4-1.el6.centos  ################################# [100%]
[root@Mike-VM-Node1 ~]# yum -y install zabbix-agent

CentOS7安裝客戶端

[root@Mike-VM-Node1 ~]# rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-1.el7.centos.noarch.rpm
Retrieving http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-1.el7.centos.noarch.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:zabbix-release-3.4-1.el7.centos  ################################# [100%]
[root@Mike-VM-Node1 ~]# yum -y install zabbix-agent

因為兩個系統版本的 rpm 源是不一樣的,所以安裝需要找到對應的源文件,我這里就標明清楚了

 

配置Zabbix agent文件

[root@Mike-VM-Node1 ~]# vim /etc/zabbix/zabbix_agentd.conf

Server=192.168.18.30

ServerActive=192.168.18.30

Hostname=192.168.18.66

[root@Mike-VM-Node1 ~]# 

配置文件說明:

允許zabbix服務器遠程zabbix_agentd執行命令:EnableRemoteCommands=1   (默認為0)

允許開啟遠程執行命令日志:LogRemoteCommands=1    (默認為0)

zabbix agent 默認PID路徑:     PidFile=/var/run/zabbix/zabbix_agentd.pid

zabbix agent默認日志路徑:    LogFile=/var/log/zabbix/zabbix_agentd.log

zabbix agent服務端IP:                            Server=192.168.18.30                (需寫自己服務端IP)

zabbi  agent服務端主動模式IP:              ServerActive=192.168.18.30       (需寫自己服務端IP)

zabbix agent客戶端IP:                            Hostname=192.168.18.66           (需寫監控自身可以通信IP)

 

啟動zabbix agent客戶端

centos6

[root@Mike-VM-Node1 ~]# chkconfig zabbix-agent on
[root@Mike-VM-Node1 ~]# service zabbix-agent start

centos7

[root@Mike-VM-Node1 ~]# systemctl start zabbix-agent.service
[root@Mike-VM-Node1 ~]# systemctl enable zabbix-agent.service
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
[root@Mike-VM-Node1 ~]# 

 

添加防火牆端口

firewalld

[root@Mike-VM-Node1 ~]# firewall-cmd --zone=public --add-port=10050/tcp --permanent
[root@Mike-VM-Node1 ~]# firewall-cmd –reload

iptables

[root@Mike-VM-Node1 ~]# iptables -A INPUT -p tcp --dport 10050 -j ACCEPT
[root@Mike-VM-Node1 ~]# service iptables save

或者關閉防火牆

[root@Mike-VM-Node1 ~]# systemctl stop firewalld
[root@Mike-VM-Node1 ~]# systemctl stop iptables

如果不能訪問,網絡排查問題檢測:

1.使用ping命令,在客戶端與server直接互相ping通,或者telnet 10050端口

2.關閉或者開放相關防火牆,linux還需關閉selinux

3.檢查server的地址是否填錯

 

一鍵shell腳本

#!/bin/bash

groupadd zabbix
useradd -g zabbix -m zabbix

server=192.168.18.55
ServerActive=192.168.18.55
hostname=192.168.18.66 rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-1.el7.centos.noarch.rpm yum -y install zabbix-agent sed -i "/^Hostname=.*/s/Hostname=.*/Hostname=${hostname}/g" /etc/zabbix/zabbix_agentd.conf sed -i "/^Server=.*/s/Server=.*/Server=${server}/g" /etc/zabbix/zabbix_agentd.conf sed -i "/^ServerActive=.*/s/ServerActive=.*/ServerActive=${server}/g" /etc/zabbix/zabbix_agentd.conf systemctl start zabbix-agent.service systemctl enable zabbix-agent.service

腳本中的 server 、hostname 地址和 rpm 源可以更換為自己的地址或者系統rpm 源

 

Zabbix服務端添加主機

打開zabbix web頁面點  配置>主機>創建主機,填寫自己剛剛在客戶端的ip

然后點模版>選擇>找到  Template OS Linux>添加

最后可以看到可用性這里已經是綠色就代表監控到客戶端主機了

如果還是紅色的話,需要檢測服務端和客戶端10050是否可以通信,可以使用  telnet 測試

或者檢測一下客戶端的ip是否寫錯了,在web頁面里面填寫的不一致導致

zabbix還是有很多功能,添加主機只是第一步,后面還有很多監控指標需要監控哦~~

 

本文分享完畢,感謝支持點贊~~


免責聲明!

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



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