当通过docker上的远程jmx连接到kafka时,zabbix java gateway zbx\u tcp\u read()超时

goqiplq2  于 2021-06-04  发布在  Kafka
关注(0)|答案(0)|浏览(386)

我正在尝试通过jmx将zabbixjava网关连接到我的kafka服务器。我收到连接超时:

zabbix-java-gateway_1     | 2020-12-21 21:02:20.181 [pool-1-thread-4] WARN  com.zabbix.gateway.SocketProcessor - error processing request, item "jmx.discovery[beans,"kafka.server:type=BrokerTopicMetrics,name=BytesOutPerSec,topic=*"]" failed: Connection timed out: service:jmx:rmi:///jndi/rmi://192.168.99.100:12345/jmxrmi

gui中的错误:

Kafka构型

对于Kafka,我使用的是沃尔斯特·多克的形象。docker-compose.yml中的kafka服务如下所示:

kafka:
    build:
      context: . 
      dockerfile: _docker/kafka/Dockerfile
    container_name: kafka
    env_file:
      - kafka/kafka.env
    environment:
      JMX_PORT: 12345
      KAFKA_JMX_OPTS: -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=127.0.0.1 -Dcom.sun.management.jmxremote.rmi.port=12345
    ports:
      - "9092:9092"
      - "12345:12345"
    depends_on:
      - zookeeper
    volumes:
      - ./kafka/volumes/data:/kafka
    networks:
      - streaming

zabbix配置

我已经使用官方的zabbix docker映像为ubuntu和mysql和nginx安装了zabbix。我复制了这个docker文件。
我在.env\u srv中取消了以下环境变量的注解:

ZBX_JAVAGATEWAY_ENABLE=true
ZBX_JAVAGATEWAY=zabbix-java-gateway
ZBX_JAVAGATEWAYPORT=10052
ZBX_STARTJAVAPOLLERS=5

这就是我的.env\u java文件的样子(我已经将超时时间增加到30):

ZBX_START_POLLERS=5
ZBX_TIMEOUT=30

# Possible values: trace, debug, info, want, error, all, off

ZBX_DEBUGLEVEL=debug

我就是这样在zabbix gui中设置jmx接口的。我使用的是apachekafka by jmx模板。

扎比克斯原木

zabbix-java-gateway_1     | 2020-12-21 20:46:05.055 [pool-1-thread-4] DEBUG com.zabbix.gateway.SocketProcessor - starting to process incoming connection
zabbix-java-gateway_1     | 2020-12-21 20:46:05.056 [pool-1-thread-4] DEBUG c.z.gateway.BinaryProtocolSpeaker - reading Zabbix protocol header
zabbix-java-gateway_1     | 2020-12-21 20:46:05.056 [pool-1-thread-4] DEBUG c.z.gateway.BinaryProtocolSpeaker - reading 8 bytes of data length
zabbix-java-gateway_1     | 2020-12-21 20:46:05.056 [pool-1-thread-4] DEBUG c.z.gateway.BinaryProtocolSpeaker - reading 247 bytes of request data
zabbix-java-gateway_1     | 2020-12-21 20:46:05.056 [pool-1-thread-4] DEBUG c.z.gateway.BinaryProtocolSpeaker - received the following data in request: {"request":"java gateway jmx","username":"zabbix","password":"zabbix","jmx_endpoint":"service:jmx:rmi:///jndi/rmi://192.168.99.100:12345/jmxrmi","keys":["jmx[\"kafka.network:type=RequestMetrics,name=TemporaryMemoryBytes,request=Fetch\",\"Max\"]"]}
zabbix-java-gateway_1     | 2020-12-21 20:46:05.056 [pool-1-thread-4] DEBUG com.zabbix.gateway.SocketProcessor - dispatched request to class com.zabbix.gateway.JMXItemChecker
zabbix-java-gateway_1     | 2020-12-21 20:46:05.056 [pool-1-thread-4] DEBUG c.z.g.ZabbixJMXConnectorFactory - connecting to JMX agent at 'service:jmx:rmi:///jndi/rmi://192.168.99.100:12345/jmxrmi'
zabbix-web-nginx-mysql_1  | 172.31.0.1 - - [21/Dec/2020:21:46:10 +0100] "POST /zabbix.php?action=notifications.get&sid=fa4abac3a2f8629e&output=ajax HTTP/1.1" 200 436 "http://localhost:8081/hosts.php" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36" "-"
zabbix-web-nginx-mysql_1  | 172.31.0.1 - - [21/Dec/2020:21:46:11 +0100] "POST /jsrpc.php?output=json-rpc HTTP/1.1" 200 74 "http://localhost:8081/hosts.php" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36" "-"
zabbix-web-nginx-mysql_1  | 127.0.0.1 - - [21/Dec/2020:21:46:12 +0100] "GET / HTTP/1.1" 200 3624 "-" "curl/7.68.0" "-"
zabbix-web-nginx-mysql_1  | 127.0.0.1 - - [21/Dec/2020:21:46:22 +0100] "GET / HTTP/1.1" 200 3624 "-" "curl/7.68.0" "-"
zabbix-web-nginx-mysql_1  | 172.31.0.1 - - [21/Dec/2020:21:46:22 +0100] "POST /jsrpc.php?output=json-rpc HTTP/1.1" 200 74 "http://localhost:8081/hosts.php" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36" "-"
zabbix-web-nginx-mysql_1  | 127.0.0.1 - - [21/Dec/2020:21:46:32 +0100] "GET / HTTP/1.1" 200 3624 "-" "curl/7.68.0" "-"
zabbix-web-nginx-mysql_1  | 172.31.0.1 - - [21/Dec/2020:21:46:33 +0100] "POST /jsrpc.php?output=json-rpc HTTP/1.1" 200 74 "http://localhost:8081/hosts.php" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36" "-"
zabbix-java-gateway_1     | 2020-12-21 20:46:35.056 [pool-1-thread-4] WARN  com.zabbix.gateway.SocketProcessor - error processing request, item "jmx["kafka.network:type=RequestMetrics,name=TemporaryMemoryBytes,request=Fetch","Max"]" failed: Connection timed out: service:jmx:rmi:///jndi/rmi://192.168.99.100:12345/jmxrmi
zabbix-java-gateway_1     | 2020-12-21 20:46:35.057 [pool-1-thread-4] DEBUG com.zabbix.gateway.SocketProcessor - error caused by
zabbix-java-gateway_1     | com.zabbix.gateway.ZabbixException: Connection timed out: service:jmx:rmi:///jndi/rmi://192.168.99.100:12345/jmxrmi
zabbix-java-gateway_1     |     at com.zabbix.gateway.JMXItemChecker.getValues(JMXItemChecker.java:132) ~[zabbix-java-gateway-5.2.2.jar:na]
zabbix-java-gateway_1     |     at com.zabbix.gateway.SocketProcessor.run(SocketProcessor.java:79) ~[zabbix-java-gateway-5.2.2.jar:na]
zabbix-java-gateway_1     |     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_275]
zabbix-java-gateway_1     |     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_275]
zabbix-java-gateway_1     |     at java.lang.Thread.run(Thread.java:748) [na:1.8.0_275]
zabbix-java-gateway_1     | 2020-12-21 20:46:35.057 [pool-1-thread-4] DEBUG c.z.gateway.BinaryProtocolSpeaker - sending the following data in response: {"response":"failed","error":"Connection timed out: service:jmx:rmi:\/\/\/jndi\/rmi:\/\/192.168.99.100:12345\/jmxrmi"}
zabbix-java-gateway_1     | 2020-12-21 20:46:35.057 [pool-1-thread-4] DEBUG com.zabbix.gateway.SocketProcessor - finished processing incoming connection

Kafka原木

这是Kafka容器的日志。我不明白为什么12345端口似乎在使用中。

zabbix-java-gateway_1     |     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_275]
kafka            | Error: JMX connector server communication error: service:jmx:rmi://952116a91006:12345
kafka            | sun.management.AgentConfigurationError: java.rmi.server.ExportException: Port already in use: 12345; nested exception is:
kafka            |      java.net.BindException: Address in use (Bind failed)
kafka            |      at sun.management.jmxremote.ConnectorBootstrap.exportMBeanServer(ConnectorBootstrap.java:800)
kafka            |      at sun.management.jmxremote.ConnectorBootstrap.startRemoteConnectorServer(ConnectorBootstrap.java:468)
kafka            |      at sun.management.Agent.startAgent(Agent.java:262)
kafka            |      at sun.management.Agent.startAgent(Agent.java:452)
kafka            | Caused by: java.rmi.server.ExportException: Port already in use: 12345; nested exception is:
kafka            |      java.net.BindException: Address in use (Bind failed)
kafka            |      at sun.rmi.transport.tcp.TCPTransport.listen(TCPTransport.java:346)
kafka            |      at sun.rmi.transport.tcp.TCPTransport.exportObject(TCPTransport.java:254)
kafka            |      at sun.rmi.transport.tcp.TCPEndpoint.exportObject(TCPEndpoint.java:411)
kafka            |      at sun.rmi.transport.LiveRef.exportObject(LiveRef.java:147)
kafka            |      at sun.rmi.server.UnicastServerRef.exportObject(UnicastServerRef.java:237)
kafka            |      at sun.management.jmxremote.ConnectorBootstrap$PermanentExporter.exportObject(ConnectorBootstrap.java:199)
kafka            |      at javax.management.remote.rmi.RMIJRMPServerImpl.export(RMIJRMPServerImpl.java:146)
kafka            |      at javax.management.remote.rmi.RMIJRMPServerImpl.export(RMIJRMPServerImpl.java:122)
kafka            |      at javax.management.remote.rmi.RMIConnectorServer.start(RMIConnectorServer.java:404)
kafka            |      at sun.management.jmxremote.ConnectorBootstrap.exportMBeanServer(ConnectorBootstrap.java:796)
kafka            |      ... 3 more
kafka            | Caused by: java.net.BindException: Address in use (Bind failed)
kafka            |      at java.net.PlainSocketImpl.socketBind(Native Method)
kafka            |      at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:387)
kafka            |      at java.net.ServerSocket.bind(ServerSocket.java:375)
kafka            |      at java.net.ServerSocket.<init>(ServerSocket.java:237)
kafka            |      at java.net.ServerSocket.<init>(ServerSocket.java:128)
kafka            |      at sun.rmi.transport.proxy.RMIDirectSocketFactory.createServerSocket(RMIDirectSocketFactory.java:45)
kafka            |      at sun.rmi.transport.proxy.RMIMasterSocketFactory.createServerSocket(RMIMasterSocketFactory.java:345)
kafka            |      at sun.rmi.transport.tcp.TCPEndpoint.newServerSocket(TCPEndpoint.java:666)
kafka            |      at sun.rmi.transport.tcp.TCPTransport.listen(TCPTransport.java:335)
kafka            |      ... 12 more

jmx似乎运行良好

在kafka方面,jmx似乎工作正常,因为我可以通过 jconsole 127.0.0.1:12345 . 下图显示了Kafkambeans。

是什么原因导致这次出局?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题