zabbix server 连接不上java网关
Posted
技术标签:
【中文标题】zabbix server 连接不上java网关【英文标题】:zabbix server can't connect to java gateway 【发布时间】:2015-05-24 13:53:14 【问题描述】:我已经在同一个linux服务器上安装了zabbix server和java gateway,并启动了zabbix-server和zabbix-java-gateway服务。操作系统是CentOS 6.5,java是JDK1.6.0_45,IP是192.98.12.240,zabbix server和zabbix java gateway版本是2.2.9。我已经停止了 iptables 服务。
然后在 zabbix web 控制台中,我添加了一个启用 jmx 接口的主机。我的主机 IP 是 192.98.12.198,JMX post 是 9999。在 Jconsole 中,我可以连接到这个启用了 JMX 的 java 应用程序。但是在 zabbix web 控制台中,它显示错误:
下面是我的 zabbix_server.conf
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
DebugLevel=4
PidFile=/var/run/zabbix/zabbix_server.pid
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
DBSocket=/var/lib/mysql/mysql.sock
JavaGateway=192.98.12.240
JavaGatewayPort=10052
StartJavaPollers=5
SNMPTrapperFile=/var/log/snmptt/snmptt.log
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
下面是我的 zabbix_java_gateway.conf
LISTEN_IP=192.98.12.240
LISTEN_PORT=10052
PID_FILE="/var/run/zabbix/zabbix_java.pid"
START_POLLERS=5
以下是 zabbix_server.log 的一些片段
13573:20150321:100114.503 In substitute_key_macros() data:'jmx[java.lang:type=Memory,HeapMemoryUsage.used]'
13573:20150321:100114.503 End of substitute_key_macros():SUCCEED data:'jmx[java.lang:type=Memory,HeapMemoryUsage.used]'
13573:20150321:100114.503 In substitute_simple_macros() data:'9999'
13573:20150321:100114.503 In substitute_simple_macros() data:EMPTY
13573:20150321:100114.503 In substitute_simple_macros() data:EMPTY
13573:20150321:100114.503 In get_values_java() host:'myhost' addr:'192.98.12.198' num:1
13573:20150321:100114.503 getting Java values failed: cannot connect to [[192.98.12.240]:10052]: [13] Permission denied
13573:20150321:100114.503 End of get_values_java()
13573:20150321:100114.503 In deactivate_host() hostid:10106 itemid:23899 type:16
13573:20150321:100114.503 query [txnlev:1] [begin;]
13573:20150321:100114.503 query [txnlev:1] [update hosts set jmx_disable_until=1426903334,jmx_error='cannot connect to [[192.98.12.240]:10052]: [13] Permission denied' where hostid=10106]
13573:20150321:100114.504 query [txnlev:1] [commit;]
13573:20150321:100114.526 deactivate_host() errors_from:1426901309 available:2
13573:20150321:100114.526 End of deactivate_host()
13573:20150321:100114.526 End of get_values():1
下面是我的 zabbix_java_gateway.log
2015-03-21 10:54:29.078 [main] INFO com.zabbix.gateway.JavaGateway - Zabbix Java Gateway 2.2.9 (revision 52686) has started
2015-03-21 10:54:29.086 [main] DEBUG c.z.gateway.ConfigurationManager - starting to parse configuration parameters
2015-03-21 10:54:29.086 [main] DEBUG c.z.gateway.ConfigurationManager - found pidFile configuration parameter with value '/var/run/zabbix/zabbix_java.pid'
2015-03-21 10:54:29.087 [main] DEBUG c.z.gateway.ConfigurationManager - received pidFile configuration parameter, daemonizing
2015-03-21 10:54:29.088 [main] DEBUG c.z.gateway.ConfigurationManager - found listenIP configuration parameter with value '192.98.12.240'
2015-03-21 10:54:29.089 [main] DEBUG c.z.gateway.ConfigurationManager - found listenPort configuration parameter with value '10052'
2015-03-21 10:54:29.089 [main] DEBUG c.z.gateway.ConfigurationManager - found startPollers configuration parameter with value '5'
2015-03-21 10:54:29.089 [main] DEBUG c.z.gateway.ConfigurationManager - finished parsing configuration parameters
2015-03-21 10:54:29.092 [main] INFO com.zabbix.gateway.JavaGateway - listening on /192.98.12.240:10052
2015-03-21 10:54:29.097 [main] DEBUG com.zabbix.gateway.JavaGateway - created a thread pool of 5 pollers
请帮忙,谢谢。
ps:我把zabbix_server.conf中的JavaGateway改成了localhost或者127.0.0.1,我也没用。
【问题讨论】:
从报错信息“cannot connect to [[192.98.12.240]:10052]: [13] Permission denied”来看,Zabbix server不允许连接Java gateway。您能否检查一下您是否可以手动建立该连接,以及是否没有像 SELinux 这样的东西阻止该连接? 【参考方案1】:我自己找到了解决方案。 在VM选项中添加-Djava.net.preferIPv4Stack=true即可解决问题
【讨论】:
【参考方案2】:# Modify zabbix_server.conf
JavaGateway=127.0.0.1
# Modify zabbix_java_gateway.conf
LISTEN_IP=127.0.0.1
# Restart Services
service zabbix-server restart
service zabbix-java-gateway restart
注意:确保 SELinux 或 iptables 不会阻止请求。
【讨论】:
以上是关于zabbix server 连接不上java网关的主要内容,如果未能解决你的问题,请参考以下文章
在 Direct 模式下,哪些数据通过网关连接到 CosmosDB?
如何解决zookeeper client端与server端连接不上的问题
Genymotion 模拟器连接不上(adb server version (40) doesn't match this client (39))