[英]Failed to list kafka topics in kubernetes after adding jmx__javaagent
I have a running kafka pod in my kubernetes cluster.我的 kubernetes 集群中有一个正在运行的 kafka pod。 For getting custom metrics in prometheus format, I have configured a jmx_prometheus_javaagent and assagined the port 2255. And I am able to list the metrics from localhost:2255/metrics.
为了以 prometheus 格式获取自定义指标,我配置了一个 jmx_prometheus_javaagent 并设置了端口 2255。我可以从 localhost:2255/metrics 列出指标。
The issue is, after this, I am not able to list the kafka topics.问题是,在此之后,我无法列出 kafka 主题。 Getting following error:
得到以下错误:
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
Aborted (core dumped)中止(核心转储)
Any idea, how to solve this error?任何想法,如何解决这个错误?
You've set it up so that the java agent is being loaded not just for the kafka server, but also all of the command line tools.您已经对其进行了设置,以便不仅为 kafka 服务器加载 java 代理,还为所有命令行工具加载。 You should change your configuration so it is only being loaded for the server.
您应该更改配置,以便仅为服务器加载它。
Get the kafka broker container ID by using "docker ps"使用“docker ps”获取 kafka 代理容器 ID
Then run the kafka command against that container from the command line this way:然后以这种方式从命令行针对该容器运行 kafka 命令:
docker exec -it CONTAINERID /bin/bash -c "KAFKA_OPTS= && kafka-topics --zookeeper 127.0.0.1:2181 --list" docker exec -it CONTAINERID /bin/bash -c "KAFKA_OPTS= && kafka-topics --zookeeper 127.0.0.1:2181 --list"
Change the CONTAINERID and the zookeeper address to fit your enviroment.更改 CONTAINERID 和 zookeeper 地址以适合您的环境。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.