简体   繁体   English

无法连接到远程JMX主机

[英]Can't connect to remote JMX host

Using VisualVM, there are two types I can see to connect remote host. 使用VisualVM,我可以看到两种类型的远程主机连接。

  1. jstatd jstatd

  2. JMX JMX

So I am trying to use JMX , I followed numerous tutorials but no luck so far. 因此,我尝试使用JMX ,我遵循了许多教程,但到目前为止还没有运气。

Currently, there's my desktop and one linux box with java server application running. 当前,有我的桌面和一个运行Java服务器应用程序的Linux机器。 I am trying to setup VisualVM client on desktop to see java application running on the linux box. 我正在尝试在桌面上安装VisualVM客户端,以查看在Linux框中运行的Java应用程序。

I added following JAVA_OPTS script on start.sh script for the java application on linux. 我在start.sh脚本上为Linux上的Java应用程序添加了以下JAVA_OPTS脚本。

JMX_PORT="-Dcom.sun.management.jmxremote.port=33333"  <-- allowed on firewall
JMX_SSL="-Dcom.sun.management.jmxremote.ssl=false"
JMX_AUTH="-Dcom.sun.management.jmxremote.authenticate=false"
JMX_IP="-Djava.rmi.server.hostname=xx.xx.xx.xx"   <-- where linux box NAT ip.

Java application on linux was successfully started with jmx options added start.sh, I assume since there's no error or warning. 我假设在Linux上的Java应用程序已成功启动,并添加了start.sh的jmx选项,因为没有错误或警告,我认为。

When I tried to add JMX connection, it says it can't connect to it. 当我尝试添加JMX连接时,它说它无法连接。

I checked if 33333 is blocked, it's not, I was able to connect to that ip with port using telnet from my desktop. 我检查了33333是否被阻止,不是,我可以使用台式机上的telnet通过端口连接到该IP。

Is there any other port that I should open for VisualVM? 我应该为VisualVM打开任何其他端口吗?

To use JMX, is there any other setup that I have to do such as RMI Registry server or jstatd policy file creation and start jstat daemon?? 要使用JMX,还需要执行其他任何设置,例如RMI Registry Server或创建jstatd策略文件并启动jstat守护程序吗? I thought it was for jstatd connection only so I didn't pursue that tutorial. 我以为它仅用于jstatd连接,所以我没有继续该教程。

The easiest way is to use an openvpn tunnel between server and desktop than you get rid of the firewall an NAT things. 最简单的方法是在服务器和桌面之间使用openvpn隧道,而不是摆脱防火墙和NAT之类的东西。 I do it this way and it works like a charm. 我这样做,它就像一种魅力。

I had no other clue how I can fix this so ended up using ssh tunnel. 我没有其他线索可以解决此问题,所以最终使用了ssh隧道。

  1. I added jmx run option into my java application start script on remote host. 我在远程主机上的Java应用程序启动脚本中添加了jmx run选项。 (jmxremote.port=33300, ssl to false, authenticate to false, hostname.) (jmxremote.port = 33300,ssl为false,身份验证为false,主机名。)
  2. ssh -D 33300 on desktop to remote host. ssh -D 33300在桌面上到远程主机。
  3. start jvisualvm using system_socks_proxy=localhost:33300 -J-Djava.net.useSystemProxies=true 使用system_socks_proxy = localhost:33300 -J-Djava.net.useSystemProxies = true启动jvisualvm

Now remote host is successfully added using add new jmx connection on VisualVm. 现在,使用VisualVm上的添加新的jmx连接成功添加了远程主机。

ref. REF。 VisualVM over ssh 通过ssh的VisualVM

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM