• CentOS7 二进制安装 zabbix_agent 5.0


    CentOS7 二进制安装 zabbix_agent 5.0

    环境准备

    关闭防火墙和selinux

    #关闭selinux
    [root@centos7 ~]#sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
    
    #关闭防火墙
    [root@centos7 ~]#systemctl disable --now firewalld
    
    #重启生效
    [root@centos7 ~]#reboot
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9

    1. 安装zabbix rpm源

    [root@centos7 ~]#rpm -Uvh https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
    [root@centos7 ~]#sed -i 's#http://repo.zabbix.com#https://mirrors.aliyun.com/zabbix#' /etc/yum.repos.d/zabbix.repo
    [root@centos7 ~]#yum clean all
    
    
    • 1
    • 2
    • 3
    • 4

    2. 安装zabbix agent

    [root@centos7 ~]#yum install -y zabbix-agent
    
    #编辑配置文件 /etc/yum.repos.d/zabbix.repo
    [root@centos7 ~]#vim /etc/yum.repos.d/zabbix.repo
    [zabbix-frontend]
    ...
    enabled=1
    ...
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9

    3. 修改zabbix agent配置文件

    [root@centos7 ~]#vim /etc/zabbix/zabbix_agentd.conf
    Server=10.0.0.17  #指向当前zabbix server
    ListenPort=10050  #监听端口
    ListenIP=0.0.0.0  #监听IP
    StartAgents=5  #被动状态时,默认启动的实例(进程数),0为不监听任何端口
    Hostname=10.0.0.7  #区分大小写且在zabbix server唯一的值
    
    [root@centos7 ~]#grep "^[a-Z]" /etc/zabbix/zabbix_agentd.conf
    PidFile=/var/run/zabbix/zabbix_agentd.pid
    LogFile=/var/log/zabbix/zabbix_agentd.log
    LogFileSize=0
    Server=10.0.0.17
    ListenPort=10050
    ListenIP=0.0.0.0
    StartAgents=5
    ServerActive=127.0.0.1
    Hostname=10.0.0.7
    Include=/etc/zabbix/zabbix_agentd.d/*.conf
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19

    4 启动Zabbix agent进程

    #启动Zabbix agent进程,并设置开机自启
    [root@centos7 ~]#systemctl restart zabbix-agent.service
    [root@centos7 ~]#systemctl enable zabbix-agent.service
    [root@centos7 ~]#systemctl status zabbix-agent.service
    ● zabbix-agent.service - Zabbix Agent
       Loaded: loaded (/usr/lib/systemd/system/zabbix-agent.service; enabled; vendor preset: disabled)
       Active: active (running) since Mon 2022-06-27 17:03:16 CST; 19min ago
     Main PID: 2306 (zabbix_agentd)
       CGroup: /system.slice/zabbix-agent.service
               ├─2306 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
               ├─2307 /usr/sbin/zabbix_agentd: collector [idle 1 sec]
               ├─2308 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection]
               ├─2309 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection]
               ├─2310 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection]
               ├─2311 /usr/sbin/zabbix_agentd: listener #4 [waiting for connection]
               ├─2312 /usr/sbin/zabbix_agentd: listener #5 [waiting for connection]
               └─2313 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]
    
    Jun 27 17:03:16 centos7 systemd[1]: Starting Zabbix Agent...
    Jun 27 17:03:16 centos7 systemd[1]: Started Zabbix Agent.
    
    #验证Zabbix agent进程是否存在
    [root@centos7 ~]#ss -ntlp
    State      Recv-Q Send-Q              Local Address:Port                             Peer Address:Port
    LISTEN     0      128                             *:10050                                       *:*users:(("zabbix_agentd",pid=2313,fd=4),("zabbix_agentd",pid=2312,fd=4),("zabbix_agentd",pid=2311,fd=4),("zabbix_agentd",pid=2310,fd=4),("zabbix_agentd",pid=2309,fd=4),("zabbix_agentd",pid=2308,fd=4),("zabbix_agentd",pid=2307,fd=4),("zabbix_agentd",pid=2306,fd=4))
    LISTEN     0      128                             *:22                                          *:*users:(("sshd",pid=1302,fd=3))
    LISTEN     0      100                     127.0.0.1:25                                          *:*users:(("master",pid=1395,fd=13))
    LISTEN     0      128                          [::]:22                                       [::]:*users:(("sshd",pid=1302,fd=4))
    LISTEN     0      100                         [::1]:25                                       [::]:*users:(("master",pid=1395,fd=14))
    
    [root@centos7 ~]#ps -ef | grep zabbix_agentd
    root       1798   1566  0 15:57 pts/0    00:00:02 vim /etc/zabbix/zabbix_agentd.conf
    zabbix     2306      1  0 17:03 ?        00:00:00 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
    zabbix     2307   2306  0 17:03 ?        00:00:00 /usr/sbin/zabbix_agentd: collector [idle 1 sec]
    zabbix     2308   2306  0 17:03 ?        00:00:00 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection]
    zabbix     2309   2306  0 17:03 ?        00:00:00 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection]
    zabbix     2310   2306  0 17:03 ?        00:00:00 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection]
    zabbix     2311   2306  0 17:03 ?        00:00:00 /usr/sbin/zabbix_agentd: listener #4 [waiting for connection]
    zabbix     2312   2306  0 17:03 ?        00:00:00 /usr/sbin/zabbix_agentd: listener #5 [waiting for connection]
    zabbix     2313   2306  0 17:03 ?        00:00:00 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]
    root       2401   2179  0 17:25 pts/1    00:00:00 grep --color=auto zabbix_agentd
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42

    5. zabbix web界面添加被监控主机

    点击【配置-主机-创建主机】

    在这里插入图片描述

    在这里插入图片描述

    在这里插入图片描述

    在这里插入图片描述

    #【ZBX】绿色,表示主机可用,监控指标检查已成功,zabbix server对zabbix agent有权限进行数据采集并且当前通信正常

    在这里插入图片描述

    经过一段时间的数据采集后,就可以看到数据了

    6. 在zabbix server主机上安装Zabbix get命令行工具

    #Zabbix get是一个命令行应用,它可以用于与Zabbix agent进行通信,并从Zabbix agent那里获取所需的信息。
    该应用通常被用于Zabbix agent故障排错。
    
    [root@centos7 ~]#yum list all |grep zabbix-get
    zabbix-get.x86_64                          5.0.24-1.el7           zabbix
    
    [root@centos7 ~]#yum -y install zabbix-get.x86_64
    
    [root@centos7 ~]#/bin/zabbix_get -s 10.0.0.7 -p 10050 -k "agent.ping"
    1
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
  • 相关阅读:
    字符串相似度算法
    两岁的娃,要不要上托班?看完你不用再纠结
    2023年05月 Python(六级)真题解析#中国电子学会#全国青少年软件编程等级考试
    Llama2开源大模型的新篇章以及在阿里云的实践
    Unity-timeline(时间线)
    【Vue 开发实战】实战篇 # 45:如何构建可交互的组件文档让代码高亮的显示在页面
    重建与发展:数字资产借贷行业朝着可持续发展迈进!
    【毕业设计】基于Arduino的智能灌溉系统 - 嵌入式 单片机 物联网
    lapply apply详解sapply mapply 列表变成数据框 数据框变成列表 list和dataframe
    持续集成jenkins+gitee
  • 原文地址:https://blog.csdn.net/weixin_51867896/article/details/125490968