Zabbix-agent2 安装部署

zabbix-agent2是zabbix的客户端,go语言开发。

默认使用10050端口,

环境准备

准备两台虚拟机,关闭防火墙,设置主机名

IP

主机名

10.30.59.241

zabbix-agent2

10.30.59.243

zabbix-agent2

[[email protected] ~]# systemctl stop firewalld [[email protected] ~]# systemctl disable firewalld Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service. Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service. [[email protected] ~]# vi /etc/selinux/config [[email protected] ~]# setenforce 0 [[email protected] ~]# getenforce Permissive [[email protected] ~]# hostnamectl set-hostname zabbix-agent2 [[email protected] ~]# bash [[email protected] ~]#

配置时间同步

[[email protected] ~]# yum install -y ntpdate [[email protected] ~]# ntpdate -u ntp.aliyun.com 8 Jul 18:16:17 ntpdate[3228]: step time server 203.107.6.88 offset 1447561.766187 sec [[email protected] ~]# date Thu Jul 8 18:16:22 CST 2021 [[email protected] ~]#

安装zabbix-agent2

# 配置yum源 、安装 # 如果不想配置yum源,可以在server节点下载一个agent rpm包,使用ansible批量部署 # 两个节点同样的操作 [[email protected] ~]# rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm Retrieving https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm warning: /var/tmp/rpm-tmp.r5pknB: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY Preparing... ################################# [100%] Updating / installing... 1:zabbix-release-5.0-1.el7 ################################# [100%] # 修改yum源地址 [[email protected] ~]# sed -i 's#http://repo.zabbix.com#https://mirrors.aliyun.com/zabbix#' /etc/yum.repos.d/zabbix.repo [[email protected] ~]# yum clean all Loaded plugins: fastestmirror Cleaning repos: base extras updates zabbix : zabbix-non-supported Cleaning up everything # 安装agent [[email protected] ~]# yum install -y zabbix-agent2 # 启动客户端 [[email protected] ~]# systemctl enable zabbix-agent2 Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent2.service to /usr/lib/systemd/system/zabbix-agent2.service. [[email protected] ~]# systemctl start zabbix-agent2 [[email protected] ~]# netstat -ntlp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1400/sshd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2499/master tcp6 0 0 :::22 :::* LISTEN 1400/sshd tcp6 0 0 ::1:25 :::* LISTEN 2499/master tcp6 0 0 :::10050 :::* LISTEN 10254/zabbix_agent2

修改配置文件

## 默认配置文件为这样 [[email protected] ~]# grep -Ev '^#|^#39; /etc/zabbix/zabbix_agent2.conf PidFile=/var/run/zabbix/zabbix_agent2.pid LogFile=/var/log/zabbix/zabbix_agent2.log LogFileSize=0 Server=127.0.0.1 ServerActive=127.0.0.1 Hostname=Zabbix server Include=/etc/zabbix/zabbix_agent2.d/*.conf ControlSocket=/tmp/agent.sock # 修改为 [[email protected] ~]# grep -Ev '^#|^#39; /etc/zabbix/zabbix_agent2.conf PidFile=/var/run/zabbix/zabbix_agent2.pid LogFile=/var/log/zabbix/zabbix_agent2.log LogFileSize=0 Server=10.30.59.242 # zabbix_server 地址 ServerActive=10.30.59.242 Hostname=Zabbix_agent241 # agent节点名字,最好配置不一样的做区分 Include=/etc/zabbix/zabbix_agent2.d/*.conf ControlSocket=/tmp/agent.sock # 需要修改主机名、server serveractive # 重启 [[email protected] ~]# systemctl restart zabbix-agent2

验证

在server端安装zabbix-get ,使用命令验证。

[[email protected] ~]# yum install -y zabbix-get [[email protected] ~]# zabbix_get -s '10.30.59.241' -p 10050 -k 'agent.ping' 1 # 获取agent节点的主机名 [[email protected] ~]# zabbix_get -s '10.30.59.241' -p 10050 -k 'system.hostname' zabbix-agent2 [[email protected] ~]# zabbix_get -s '10.30.59.243' -p 10050 -k 'system.hostname' zabbix-agent243

这样就代表agent安装没有问题了,就可以使用web界面添加单个agent了 , 后面实现自动发现及自动注册就不需要一个一个的添加了。

发表回复

您的邮箱地址不会被公开。必填项已用 * 标注