在boot2docker中的docker中运行kafka时使用JMX进行kafka监控 [英] kafka monitoring using JMX when running kafka in docker in boot2docker

查看:47
本文介绍了在boot2docker中的docker中运行kafka时使用JMX进行kafka监控的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 JMX 监控来监控测试 kafka 实例.

I am trying to get JMX monitoring working to monitor a test kafka instance.

我通过 boot2docker 在 docker 中运行了 kafka (ches/kafka),但我无法正确配置 JMX 监控.我已经做了一堆故障排除,我知道 kafka 实例运行正常(消费者和生产者工作).当我尝试简单的 JMX 工具(jconsole 和 jvisualvm)但都无法连接(不安全连接错误,连接失败)时出现问题.

I have kafka (ches/kafka) running in docker via boot2docker but I can not get JMX monitoring configured properly. I have done a bunch of troubleshooting and I know the kafka instance is running properly (consumers and producers work). The issue arises when I try simple JMX tools (jconsole and jvisualvm) and both can not connect (insecure connection error, connection failed).

配置注意事项:我连接到192.168.59.103(运行'boot2docker ip'时找到的virtualbox ip),ches/kafka docker/kafka实例使用7203端口作为JMX_PORT(在kafka启动日志中确认).使用 jconsole,我连接到 192.168.59.103:7203,这就是发生错误的时候.

Configuration items of note: I connect to 192.168.59.103 (virtualbox ip found when running 'boot2docker ip') and the ches/kafka docker/kafka instance uses the port 7203 as the JMX_PORT (confirmed in the kafka startup logs). Using jconsole, I connect to 192.168.59.103:7203 and that is when the errors occur.

感谢任何帮助.

推荐答案

为了完整起见,以下是有效的解决方案:

For completeness, here is the solution that works:

我按如下方式运行 ches/kafka docker 镜像 -- 请注意,JMX_PORT (7203) 现在已正确发布:

I ran ches/kafka docker image as follows -- note that the JMX_PORT (7203) is now published appropriately:

$ docker run --hostname localhost --name kafka --publish 9092:9092 --publish 7203:7203 --env EXPOSED_HOST=192.168.59.103 --env ZOOKEEPER_IP=192.168.59.103 ches/kafka

另外,在kafka-run-class.sh(windows为.bat)中设置如下环境

Also, the following environment is set in the kafka-run-class.sh (.bat for windows)

-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false

但我需要添加一个额外的项目(感谢一位评论者指出这一点):

But I needed to add one additional item (thanks to one of the commenters for pointing this out):

-Dcom.sun.management.jmxremote.rmi.port=7203

现在,要在 boot2docker 中运行 ches/docker 映像,您只需要设置一个可识别的环境变量(KAFKA_JMX_OPTS 或 KAKFA_OPTS)来添加附加项,它现在可以工作了.

Now, to run the ches/docker image in boot2docker you just need to set one of the recognized environment variables (KAFKA_JMX_OPTS or KAKFA_OPTS) to add the additional item and it now works.

感谢您的帮助!

这篇关于在boot2docker中的docker中运行kafka时使用JMX进行kafka监控的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆