添加jmx__javaagent后无法在kubernetes中列出kafka主题

时间:2018-08-14 08:42:55

标签: kubernetes apache-kafka prometheus kafka-topic

我的kubernetes集群中有一个正在运行的kafka pod。为了获得普罗米修斯格式的自定义指标,我已经配置了jmx_prometheus_javaagent并确定了端口2255。而且我能够从localhost:2255 / metrics列出指标。

问题是,在此之后,我无法列出kafka主题。出现以下错误:


bash-4.3# /opt/kafka/bin/kafka-topics.sh --list --zookeeper dz-zookeeper:2181

Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
Caused by: java.net.BindException: Address already in use
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Net.java:433)
at sun.nio.ch.Net.bind(Net.java:425)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
at sun.net.httpserver.ServerImpl.bind(ServerImpl.java:133)
at sun.net.httpserver.HttpServerImpl.bind(HttpServerImpl.java:54)
at io.prometheus.jmx.shaded.io.prometheus.client.exporter.HTTPServer.<init>(HTTPServer.java:145)
at io.prometheus.jmx.shaded.io.prometheus.jmx.JavaAgent.premain(JavaAgent.java:49)
FATAL ERROR in native method: processing of -javaagent failed

已中止(核心已弃用)


任何想法,如何解决此错误?

2 个答案:

答案 0 :(得分:0)

您已经进行了设置,以便不仅为kafka服务器而且还为所有命令行工具都加载Java代理。您应该更改配置,以便仅为服务器加载该配置。

答案 1 :(得分:0)

使用“ docker ps”获取kafka经纪人容器ID

然后以这种方式从命令行在该容器上运行kafka命令:

docker exec -it CONTAINERID / bin / bash -c“ KAFKA_OPTS = && kafka-topics --zookeeper 127.0.0.1:2181 --list”

更改CONTAINERID和Zookeeper地址以适合您的环境。