如何限制ActiveMQ的JMX API只能访问本地主机/内网?

发布于 2024-08-05 17:23:17 字数 108 浏览 1 评论 0原文

我刚刚开始使用JMX来监控activemq,我已经启用了远程监控。现在的问题是,如何只允许 localhost 访问 JMX API?或者有没有一种方法可以在不启用远程监控的情况下使用 JMX API。

I have just started using JMX to monitor activemq,i have enabled remote monitoring. Now the question is,How do i allow only localhost have access to JMX API? Or is there a way i can use JMX API without enabling remote monitoring..

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

橘味果▽酱 2024-08-12 17:23:17

在花了几个小时谷歌搜索解决方案后,我发现了这篇文章 https://wiki.internet2.edu/confluence/display/CPD/Monitoring+Tomcat+with+JMX 展示了如何为 tomcat 配置 JMX 以及如何通过 rmi 公开 JMX。
选项“-Djava.rmi.server.hostname=test-idc.internet2.edu”表示运行tomcat的主机的名称。如果您不指定主机名,则尝试从远程计算机连接将返回“连接失败”。

您需要做的就是在您的 activemq 启动脚本中设置属性 -Djava.rmi.server.hostname=localhost

if [ -z "$SUNJMX" ] ; then
  #SUNJMX="-Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false"
  SUNJMX="-Dcom.sun.management.jmxremote -Djava.rmi.server.hostname=localhost"
fi

就是这样...重新启动 activemq 并且您只能从本地计算机访问 jmx。

After spending hours of my time googling for a solution, i came across this article https://wiki.internet2.edu/confluence/display/CPD/Monitoring+Tomcat+with+JMX which shows how to configure JMX for tomcat and how to expose JMX over rmi.
The option "-Djava.rmi.server.hostname=test-idc.internet2.edu" indicates the name of the host on which tomcat is running. If you donot specify the hostname then trying to connect from a remote machine returns 'Connection failed'.

All you need to do is to set the property -Djava.rmi.server.hostname=localhost in your activemq startup script

if [ -z "$SUNJMX" ] ; then
  #SUNJMX="-Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false"
  SUNJMX="-Dcom.sun.management.jmxremote -Djava.rmi.server.hostname=localhost"
fi

Thats it... restart activemq and you have jmx accessible only from your local machine.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文