用预编译包安装zabbix-agent

Posted ld1977

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了用预编译包安装zabbix-agent相关的知识,希望对你有一定的参考价值。

如果主机无法上网,安装rpm又缺少依赖时,可以通过预编译包进行安装zabbix-agent,下载地址

 https://www.zabbix.com/download

下载后,执行如下命令:

wget https://assets.zabbix.com/downloads/3.2.7/zabbix_agents_3.2.7.linux2_6.amd64.tar.gz
# 无法上网手动下载,上传至服务器
sudo groupadd zabbix
sudo useradd -g zabbix zabbix -s /sbin/nologin
sudo useradd zabbix tar -zxvf zabbix_agents_3.2.7.linux2_6.amd64.tar.gz sudo cp bin/* /usr/bin/ sudo cp sbin/* /usr/sbin sudo chmod +x /usr/bin/zabbix_* sudo chmod +x /usr/sbin/zabbix_* sudo mkdir -p /opt/zabbix/ sudo cp conf/zabbix_agentd.conf /opt/zabbix/ sudo vi /opt/zabbix/zabbix_agentd.conf sed -i "s/Server=127.0.0.1/Server=10.231.67.220,10.231.64.31/g" /opt/zabbix/zabbix_agentd.conf sed -i "s/ServerActive=127.0.0.1/ServerActive=10.231.67.220/g" /opt/zabbix/zabbix_agentd.conf sed -i "s/Hostname=Zabbix server/# Hostname=Zabbix server/g" /opt/zabbix/zabbix/zabbix_agentd.conf sed -i "s/# HostnameItem=system.hostname/HostnameItem=system.hostname/g" /opt/zabbix/zabbix/zabbix_agentd.conf #Hostname=Zabbix server HostnameItem=system.hostname 结束进程: killall zabbix_agentd 启动服务: zabbix_agentd -c /opt/zabbix/zabbix_agentd.conf 查看服务启动 netstat -tunlp | grep 10050 sudo ps -ef | grep zabbix_agentd

Killall命令需要安装如下:

yum install psmisc

添加自动启动

[root@mysql-m ~]# vi /usr/lib/systemd/system/zabbix-agentd.service 

内容如下:

[Unit]
Description=Zabbix Agent
After=syslog.target
After=network.target

[Service]
Environment="CONFFILE=/etc/zabbix/zabbix_agentd.conf"
Type=forking
PIDFile=/tmp/zabbix_agentd.pid
Restart=on-failure
KillMode=control-group
ExecStart=/usr/sbin/zabbix_agentd -c $CONFFILE
ExecStop=/bin/kill -SIGTERM $MAINPID
RestartSec=10s

[Install]
WantedBy=multi-user.target

systemctl start zabbix-agentd.service
systemctl enable zabbix-agentd.service

6.x 编辑/etc/rc.local

[xiamen@vmxmfora1 ~]$ sudo cat /etc/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don\'t
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
/sbin/service ntpd restart
ntpdate -q pyro.apc.com
echo "search apc.com" >> /etc/resolv.conf
sudo /usr/sbin/zabbix_agentd -c /opt/zabbix/zabbix_agentd.conf

编辑/etc/sudoers,使用该用户不用输入密码:

## Allows people in group wheel to run all commands
# %wheel        ALL=(ALL)       ALL
 %admin         ALL=(ALL)       ALL
 %devs          ALL=(ALL)       /bin/su - itacmes
xiamen          ALL=(ALL)       NOPASSWD: ALL

 

 

 

参考:

https://www.centos.bz/2017/09/centos-7-zabbix-agent-%E5%AE%A2%E6%88%B7%E7%AB%AF%E6%BA%90%E7%A0%81%E7%BC%96%E8%AF%91%E5%AE%89%E8%A3%85%E9%85%8D%E7%BD%AE/

https://www.cnblogs.com/gaoyuechen/p/8991091.html
页面增加该服务器。

 

以上是关于用预编译包安装zabbix-agent的主要内容,如果未能解决你的问题,请参考以下文章

zabbix-agent安装

Zabbix之十----批量安装zabbix-agent及web监控

Windows安装zabbix-agent4.0

solaris 10安装zabbix-agent

zabbix-agent一直更新失败及解决方法

Ubuntu16.04.7LTS 安装zabbix-agent5.0