如何在Visual VM中远程连接Spring Boot应用程序?

huangapple go评论55阅读模式
英文:

How to connect Spring Boot application remotely in Visual VM?

问题

我是新手使用Visual VM,如何在Visual VM中远程连接Spring Boot应用程序?

多个实例正在以java -jar app.jar的方式运行,具有随机端口。如何从Visual VM连接,我具有远程系统的root访问权限。我是否需要启用任何安全配置?

在本地系统中,应用程序会自动显示,但当我输入远程系统的IP地址时,它会提示添加JMX连接添加jstatd连接

英文:

I am new to Visual VM, how to connect to Spring Boot application remotely in Visual VM?

Multiple instances are running as a java -jar app.jar with random ports. How to connect from Visual VM, I have root access to the remote system. Do I need to enable any security configuration?

In the local system, applications shows up automatically but when I entered remote system IP address it's prompting Add JMX connection and Add jstatd connection.

如何在Visual VM中远程连接Spring Boot应用程序?

答案1

得分: 2

需要在运行JAR文件时指定远程IP地址和公开的监听端口

语法:

java 
-Dcom.sun.management.jmxremote=true 
-Dcom.sun.management.jmxremote.port=<PORT> 
-Dcom.sun.management.jmxremote.authenticate=false 
-Dcom.sun.management.jmxremote.ssl=false 
-Djava.rmi.server.hostname=<IP地址>
-Dcom.sun.management.jmxremote.rmi.port=<PORT> 
-jar app-1.0.0-SNAPSHOT.jar 

示例:监听端口为6001,可用于远程IP地址192.168.0.23

java -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.port=6001 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=192.168.0.23 -Dcom.sun.management.jmxremote.rmi.port=6001 -jar app-1.0.0-SNAPSHOT.jar 

有关设置Visual VM的更多详细信息,请访问https://github.com/M-Thirumal/installation_guide/blob/master/visualVm/visualvm_remote_set_up.md。

英文:

We need to specify the remote IP ADDRESS and expose the listening PORT while running the jar.

Syntax:

java 
-Dcom.sun.management.jmxremote=true 
-Dcom.sun.management.jmxremote.port=&lt;PORT&gt; 
-Dcom.sun.management.jmxremote.authenticate=false 
-Dcom.sun.management.jmxremote.ssl=false 
-Djava.rmi.server.hostname=&lt;IP_ADDRESS&gt;
-Dcom.sun.management.jmxremote.rmi.port=&lt;PORT&gt; 
-jar app-1.0.0-SNAPSHOT.jar 

Example: Listening port is 6001 and available for remote ip address 192.168.0.23

java -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.port=6001 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=192.168.0.23 -Dcom.sun.management.jmxremote.rmi.port=6001 -jar app-1.0.0-SNAPSHOT.jar 

For More details about set up Visual VM https://github.com/M-Thirumal/installation_guide/blob/master/visualVm/visualvm_remote_set_up.md

答案2

得分: 1

我在使用Spring Boot时也遇到了这个困境。但是我没有使用一个jar文件。我将JMX参数传递给Maven,以便在不必首先构建jar文件的情况下对应用程序进行分析。

mvn spring-boot:run -Dspring-boot.run.jvmArguments=&quot;-Xdebug -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9010 -Dcom.sun.management.jmxremote.rmi.port=9010 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=localhost&quot;

有关更多详细信息,我在这里记录了我的步骤(链接):https://blog.phillipninan.com/profile-spring-boot-with-visual-vm

英文:

I encountered this dilemma with Spring Boot as well. But I was not using a jar. I passed the jmx arguments to maven to profile the application without having to build a jar first.

mvn spring-boot:run -Dspring-boot.run.jvmArguments=&quot;-Xdebug -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9010 -Dcom.sun.management.jmxremote.rmi.port=9010 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=localhost&quot;

For more details, I documented my steps here.

huangapple
  • 本文由 发表于 2020年7月22日 20:48:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/63034581.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定