我想使用jvisualvm(或jconsole)监控远程运行的Java(Spring Boot)应用程序。 当本地运行时,我可以在jvisualvm和jconsole中看到托管的bean。 在远程运行时,我无法连接。 我尝试了几个不同的Java进程(例如spring xd)。 在SO和Google上寻找答案没有帮助。
这是我在远程主机上的JAVA_OPTS:
$ echo $JAVA_OPTS
-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9010 -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate=false -Djava.rmi.server.hostname=192.168.59.99
然后我只需要按照以下方式启动程序(这是为spring xd准备的,但我在其他Java程序中遇到了同样的问题)。
$ bin/xd/xd-singlenode
服务器进程似乎会获取这些选项:$ ps -ef | grep single
vagrant 22938 19917 99 06:38 pts/2 00:00:03 /usr/lib/jvm/java-8- oracle/jre/bin/java -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9010 -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate=false -Djava.rmi.server.hostname=192.168.59.99 -Dspring.application.name=admin -Dlogging.config=file:/home/vagrant/spring-xd-1.1.0.RELEASE/xd/config///xd-singlenode-logger.properties -Dxd.home=/home/vagrant/spring-xd-1.1.0.RELEASE/xd -Dspring.config.location=file:/home/vagrant/spring-xd-1.1.0.RELEASE/xd/config// -Dxd.config.home=file:/home/vagrant/spring-xd-1.1.0.RELEASE/xd/config// -Dspring.config.name=servers,application -Dxd.module.config.location=file:/home/vagrant/spring-xd-1.1.0.RELEASE/xd/config//modules/ -Dxd.module.config.name=modules -classpath (...)
远程主机(Ubuntu Linux虚拟机)上的Java版本为:
$ java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
本地机器(Mac OS)上的Java版本略有不同:
$ java -version
java version "1.8.0_40"
Java(TM) SE Runtime Environment (build 1.8.0_40-b25)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)
在jvisualvm中,我按以下方式添加了远程连接(尝试过使用ssl连接和不使用):
jvisualvm给我的错误消息如下:
当远程进程正在运行时,我可以使用命令telnet 192.168.59.99:9010
从本地主机连接到远程主机,因此这似乎不是防火墙问题。
非常感谢您的任何帮助。