一 添加阿里云key

点击查看代码

curl -o - "https://mirrors.aliyun.com/zabbix/zabbix-official-repo.key" | apt-key add -
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 2938 100 2938 0 0 33386 0 --:--:-- --:--:-- --:--:-- 33386
OK

二 添加阿里源

echo "deb https://mirrors.aliyun.com/zabbix/zabbix/5.4/ubuntu $(lsb_release -cs) main" >> /etc/apt/sources.list
apt update

三 安装zabbix-agent2

apt -y install zabbix-agent2

四 修改配置文件

sed -i 's@Server=127.0.0.1@Server=172.16.3.213@g'  /etc/zabbix/zabbix_agent2.conf
sed -i 's@ServerActive=127.0.0.1@ServerActive=172.16.3.213@g' /etc/zabbix/zabbix_agent2.conf
sed -i 's@Hostname=Zabbix server@#Hostname=Zabbix server@g' /etc/zabbix/zabbix_agent2.conf
sed -i 's@# HostnameItem=system.hostname@ HostnameItem=system.hostname@g' /etc/zabbix/zabbix_agent2.conf
sed -i 's@# HostMetadata=@HostMetadata=prod_mysql@g' /etc/zabbix/zabbix_agent2.conf

五 启动服务

systemctl enable zabbix-agent2
systemctl restart zabbix-agent2

六 参考文档

​https://www.zabbix.com/download​

​https://www.zabbix.com/documentation/current/en/manual​