为什么 JMX 连接到 Amazon EC2 失败? [英] Why does JMX connection to Amazon EC2 fail?

查看:20
本文介绍了为什么 JMX 连接到 Amazon EC2 失败?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Amazon EC2 实例上运行的其中一项服务上设置了 JMX,但它无法正常工作.我正在使用 VisualVM 进行连接,经过短暂的挂起后,它因超时而失败.看起来它因为缺少响应数据或滞后而失败.我检查了安全组中是否启用了 JMX 端口,并尝试使用未启用 JMX 的不同端口以及安全组设置中未启用的端口,但两者都立即失败,因此看起来不同.我的 EC2 实例和桌面都安装了 Ubuntu 12.04 和 JDK 7.

I set up JMX on one of services running on Amazon EC2 instance but it doesn't work properly. I'm using VisualVM to connect and after short period of pending it fails with timeout. Looks like it fails because of missing response data or lags. I checked that JMX port is enabled in security group and also tried with different port with no JMX enabled and also with port not enabled in security group settings and both fails immediately, so it looks different. My EC2 instance and desktop both have Ubuntu 12.04 and JDK 7 installed.

事实证明端口没有意义,因为连接是 SSL 保护的.我有一个私钥,但不知道如何在 JConsole 或 VisualVM 中使用它.

It turns out ports don't make sense since connection is SSL secured. I have a private key and have no idea how to use it with JConsole or VisualVM.

推荐答案

这对我有用.在您的服务器上设置 JMX 选项:

This works for me. Set the JMX options on your server:

-Dcom.sun.management.jmxremote 
-Dcom.sun.management.jmxremote.port=<some port>
-Dcom.sun.management.jmxremote.ssl=false 
-Dcom.sun.management.jmxremote.authenticate=false 
-Djava.rmi.server.hostname=localhost

打开一个 SSH 隧道:

Open up an SSH tunnel:

ssh -i /path/to/key -D <some port> username@public_dns_address

启动 VisualVM:

Start VisualVM:

jvisualvm -J-Dnetbeans.system_socks_proxy=localhost:<some port> -J-Djava.net.useSystemProxies=true

添加到服务器的远程连接.使用您为 JMX 指定的端口添加 JMX 连接.

Add a remote connection to the server. Add a JMX connection using the port you've specified for JMX.

需要明确的是,在上述所有三种情况下,应该是同一个端口.

To be clear, in all three cases above, should be the same port.

这篇关于为什么 JMX 连接到 Amazon EC2 失败?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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