问题

tail -f /var/log/zabbix/zabbix_agentd.log 查看报错信息
failed to accept an incoming connection: connection from “172.16.238.2” rejected, allowed hosts: “127.0.0.1”

解决办法

修改Agent配置文件 /etc/zabbix/zabbix_agentd.conf

Server参数处添加172.16.238.2 地址即可,或者改为0.0.0.0

##### Passive checks related

### Option: Server
#       List of comma delimited IP addresses, optionally in CIDR notation, or DNS names of Zabbix servers and Zabbix proxies.
#       Incoming connections will be accepted only from the hosts listed here.
#       If IPv6 support is enabled then '127.0.0.1', '::127.0.0.1', '::ffff:127.0.0.1' are treated equally
#       and '::/0' will allow any IPv4 or IPv6 address.
#       '0.0.0.0/0' can be used to allow any IPv4 address.
#       Example: Server=127.0.0.1,192.168.1.0/24,::1,2001:db8::/32,zabbix.example.com
#
# Mandatory: yes, if StartAgents is not explicitly set to 0
# Default:
# Server=

Server=127.0.0.1,172.16.238.2

重启agent服务

systemctl restart zabbix-agent

172.16.238.2 这个地址是什么? 其实是我容器内的zabbix-serve的地址

zabbix-server地址验证

 docker-compose exec zabbix-server /bin/bash
WARNING: The following deploy sub-keys are not supported and have been ignored: resources.reservations.cpus
WARNING: The following deploy sub-keys are not supported and have been ignored: resources.reservations.cpus
WARNING: The following deploy sub-keys are not supported and have been ignored: resources.reservations.cpus
WARNING: The following deploy sub-keys are not supported and have been ignored: resources.reservations.cpus
WARNING: The following deploy sub-keys are not supported and have been ignored: resources.reservations.cpus
WARNING: The following deploy sub-keys are not supported and have been ignored: resources.reservations.cpus
WARNING: The following deploy sub-keys are not supported and have been ignored: resources.reservations.cpus
WARNING: The following deploy sub-keys are not supported and have been ignored: resources.reservations.cpus
WARNING: The following deploy sub-keys are not supported and have been ignored: resources.reservations.cpus
zabbix@64f19224617c:/var/lib/zabbix$ cat /etc/hosts
127.0.0.1	localhost
::1	localhost ip6-localhost ip6-loopback
fe00::0	ip6-localnet
ff00::0	ip6-mcastprefix
ff02::1	ip6-allnodes
ff02::2	ip6-allrouters
172.16.238.2	64f19224617c
172.16.239.3	64f19224617c

所以我建议把172.16.239.3这个地址也添加到上述解决办法中。

Logo

技术共进,成长同行——讯飞AI开发者社区

更多推荐