为编程爱好者分享易语言教程源码的资源网
好用的代理IP,游戏必备 ____广告位招租____ 服务器99/年 ____广告位招租____ ____广告位招租____ 挂机,建站服务器
好用的代理IP,游戏必备 ____广告位招租____ 服务器低至38/年 ____广告位招租____ ____广告位招租____ 挂机,建站服务器

网站首页 > 脚本专栏 > golang 正文

Zabbix-agent2 安装部署

三叶资源网 2022-07-18 13:23:15 golang 427 ℃ 0 评论

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

默认使用10050端口,

环境准备

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

IP

主机名

10.30.59.241

zabbix-agent2

10.30.59.243

zabbix-agent2

[root@localhost ~]# systemctl stop firewalld

[root@localhost ~]# systemctl disable firewalld

Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.

[root@localhost ~]# vi /etc/selinux/config

[root@localhost ~]# setenforce 0

[root@localhost ~]# getenforce

Permissive

[root@localhost ~]# hostnamectl set-hostname zabbix-agent2

[root@localhost ~]# bash

[root@zabbix-agent2 ~]#


配置时间同步

[root@zabbix-agent2 ~]# yum install -y ntpdate

[root@zabbix-agent2 ~]# ntpdate -u ntp.aliyun.com

8 Jul 18:16:17 ntpdate[3228]: step time server 203.107.6.88 offset 1447561.766187 sec

[root@zabbix-agent2 ~]# date

Thu Jul 8 18:16:22 CST 2021

[root@zabbix-agent2 ~]#


安装zabbix-agent2

# 配置yum源 、安装 
# 如果不想配置yum源,可以在server节点下载一个agent  rpm包,使用ansible批量部署

# 两个节点同样的操作

[root@zabbix-agent2 ~]# 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源地址

[root@zabbix-agent2 ~]# sed -i 's#http://repo.zabbix.com#https://mirrors.aliyun.com/zabbix#' /etc/yum.repos.d/zabbix.repo

[root@zabbix-agent2 ~]# yum clean all

Loaded plugins: fastestmirror

Cleaning repos: base extras updates zabbix

: zabbix-non-supported

Cleaning up everything

# 安装agent

[root@zabbix-agent2 ~]# yum install -y zabbix-agent2

# 启动客户端

[root@zabbix-agent2 ~]# 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.

[root@zabbix-agent2 ~]# systemctl start zabbix-agent2

[root@zabbix-agent2 ~]# 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


修改配置文件

## 默认配置文件为这样

[root@zabbix-agent2 ~]# 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

# 修改为

[root@zabbix-agent2 ~]# 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
# 重启
[root@zabbix-agent2 ~]# systemctl restart zabbix-agent2



验证

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

[root@zabbix-server ~]# yum install -y zabbix-get

[root@zabbix-server ~]# zabbix_get -s '10.30.59.241' -p 10050 -k 'agent.ping'

1

# 获取agent节点的主机名

[root@zabbix-server ~]# zabbix_get -s '10.30.59.241' -p 10050 -k 'system.hostname'

zabbix-agent2

[root@zabbix-server ~]# zabbix_get -s '10.30.59.243' -p 10050 -k 'system.hostname'

zabbix-agent243

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

来源:三叶资源网,欢迎分享,公众号:iisanye,(三叶资源网⑤群:21414575

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

百度站内搜索
关注微信公众号
三叶资源网⑤群:三叶资源网⑤群

网站分类
随机tag
识图按键助手百度贴吧验证码前端验证码图片自动打铃贪玩蓝月腾讯关键词检测保护壳多线程特训班窗口阴影淘口令解析次世代易语言多开中控源码xm-sign算法ITrayNotify图片拼接改名斗鱼TCP协议QQ注册群控模拟器
最新评论