故障现象:
服务端 操作系统:centos 7.0
zabbix server 3.0.4
客户端:
centos6.5 x86_64
1.查看日志
/var/log/zabbix/zabbix-agent.log日志:
7508:20160816:091347.005 Starting Zabbix Agent [zabbixclient01]. Zabbix 3.0.4 (revision 61185).
7508:20160816:091347.005 **** Enabled features ****
7508:20160816:091347.005 IPv6 support: YES
7508:20160816:091347.005 TLS support: YES
7508:20160816:091347.005 **************************
7508:20160816:091347.005 using configuration file: /etc/zabbix/zabbix_agentd.conf
7508:20160816:091347.008 listener failed: zbx_tcp_listen() fatal error: unable to serve on any address [[-]:20050]
8953:20160816:103912.835 Starting Zabbix Agent [zabbixclient01]. Zabbix 3.0.4 (revision 61185).
8953:20160816:103912.835 **** Enabled features ****
8953:20160816:103912.835 IPv6 support: YES
8953:20160816:103912.835 TLS support: YES
8953:20160816:103912.835 **************************
8953:20160816:103912.835 using configuration file: /etc/zabbix/zabbix_agentd.conf
8953:20160816:103912.838 listener failed: zbx_tcp_listen() fatal error: unable to serve on any address [[-]:20050]
8979:20160816:103915.126 Starting Zabbix Agent [zabbixclient01]. Zabbix 3.0.4 (revision 61185).
8979:20160816:103915.126 **** Enabled features ****
8979:20160816:103915.126 IPv6 support: YES
8979:20160816:103915.126 TLS support: YES
2.在客户端连接远程zabbix-server :telnet zabbix_server_ip 10051服务端口正常,说明和主机通信没有问题
3.在服务端telnet客户端10050无法连接(客户端无法启动10050监听端口,这个肯定连接不上)
4.服务端执行远程调试命令,都失败
正常的情况:
zabbix_get -p20050 -s 218.244.135.216 -k 'system.uptime'
31462956
zabbix_get -p20050 -s 218.244.138.248 -k 'system.hostname'
zabbix_get [29738]: Get value error: cannot connect to [[10.1.1.1]:10050]: [111] Connection refused
zabbix_get -p20050 -s 218.244.138.248 -k 'system.hostname'
zabbixclient01
zabbix_get -p20050 -s 10.1.1.1 -k 'agent.ping'
1
将监听的0.0.0.0更换成客户端的外网IP即可(大家可以根据自己的实际情况修改,如果你是局域网,可以直接改成内网IP即可)
客户端报错:service zabbix-agent 启动后,端口没有被正常监听,服务端也无法正常连接
将客户端改为二进制文件安装也不能正常启动/usr/local/zabbix/sbin/zabbix_agentd -c /usr/local/zabbix/conf/zabbix_agentd.conf
百度找了很久也没人碰到这种情况,解决思路其实很简单
服务端 操作系统:centos 7.0
zabbix server 3.0.4
客户端:
centos6.5 x86_64
1.查看日志
/var/log/zabbix/zabbix-agent.log日志:
7508:20160816:091347.005 Starting Zabbix Agent [zabbixclient01]. Zabbix 3.0.4 (revision 61185).
7508:20160816:091347.005 **** Enabled features ****
7508:20160816:091347.005 IPv6 support: YES
7508:20160816:091347.005 TLS support: YES
7508:20160816:091347.005 **************************
7508:20160816:091347.005 using configuration file: /etc/zabbix/zabbix_agentd.conf
7508:20160816:091347.008 listener failed: zbx_tcp_listen() fatal error: unable to serve on any address [[-]:20050]
8953:20160816:103912.835 Starting Zabbix Agent [zabbixclient01]. Zabbix 3.0.4 (revision 61185).
8953:20160816:103912.835 **** Enabled features ****
8953:20160816:103912.835 IPv6 support: YES
8953:20160816:103912.835 TLS support: YES
8953:20160816:103912.835 **************************
8953:20160816:103912.835 using configuration file: /etc/zabbix/zabbix_agentd.conf
8953:20160816:103912.838 listener failed: zbx_tcp_listen() fatal error: unable to serve on any address [[-]:20050]
8979:20160816:103915.126 Starting Zabbix Agent [zabbixclient01]. Zabbix 3.0.4 (revision 61185).
8979:20160816:103915.126 **** Enabled features ****
8979:20160816:103915.126 IPv6 support: YES
8979:20160816:103915.126 TLS support: YES
2.在客户端连接远程zabbix-server :telnet zabbix_server_ip 10051服务端口正常,说明和主机通信没有问题
3.在服务端telnet客户端10050无法连接(客户端无法启动10050监听端口,这个肯定连接不上)
4.服务端执行远程调试命令,都失败
正常的情况:
zabbix_get -p20050 -s 218.244.135.216 -k 'system.uptime'
31462956
zabbix_get -p20050 -s 218.244.138.248 -k 'system.hostname'
zabbix_get [29738]: Get value error: cannot connect to [[10.1.1.1]:10050]: [111] Connection refused
zabbix_get -p20050 -s 218.244.138.248 -k 'system.hostname'
zabbixclient01
zabbix_get -p20050 -s 10.1.1.1 -k 'agent.ping'
1
解决办法:
修改客户端配置文件/etc/zabbix/zabbix_agentd.conf,重启服务将监听的0.0.0.0更换成客户端的外网IP即可(大家可以根据自己的实际情况修改,如果你是局域网,可以直接改成内网IP即可)
sed -i 's/# ListenIP=0.0.0.0/ListenIP=127.0.0.1/g' /etc/zabbix/zabbix_agentd.conf
或者
sed -i 's/ListenIP=0.0.0.0/ListenIP=内网IP/g' /etc/zabbix/zabbix_agentd.conf
或者
sed -i 's/ListenIP=0.0.0.0/ListenIP=外网IP/g' /etc/zabbix/zabbix_agentd.conf
重启客户端
service zabbix-agent restart
验证:
ss -tunlp|grep 10050
为什么能这样解决,大家可以参考下zabbix的源码:
http://svn.dd-wrt.com/browser/src/router/zabbix/src/libs/zbxcomms/comms.c?rev=23049