简体   繁体   中英

Monitor remote JVM with Java Mission Profiler

I have problems accessing a JVM on Ubuntu server (14.04.1 LTS) from Java Mission Control running on OSX 10.10.2

I have read this question: How to use Java Mission Control to monitor a JVM in a remote server? and it doesnt help me.

I try to access the server over internet, and have port forwarding enabled for TCP and UDP port 7091 on the router, pointing to the local interface of the server. This port forwarding works for other services so I'm pretty sure there's nothing wrong with this part.

Java version on server is:

java version "1.8.0_11"
Java(TM) SE Runtime Environment (build 1.8.0_11-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.11-b03, mixed mode)

I start the JVM on the server like this:

java -Xms2048M -Xmx4096M 
-XX:+UnlockCommercialFeatures
-XX:+FlightRecorder
-Dcom.sun.management.jmxremote.local.only=false 
-Dcom.sun.management.jmxremote=true 
-Dcom.sun.management.jmxremote.port=7091 
-Dcom.sun.management.jmxremote.authenticate=false 
-Dcom.sun.management.jmxremote.ssl=false 
-Dcom.sun.management.jmxremote.registry.ssl=false 
com.example.MyServer 
-arg1 XXX
-arg2 YYY
-arg3 ZZZ

(I have played around a lot with different -Dcom.sun.management... arguments and this is the latest try)

On OSX my java version is:

java version "1.8.0_11"
Java(TM) SE Runtime Environment (build 1.8.0_11-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.11-b03, mixed mode)

Mission Control is version 5.3.0

I do

File - Connect - Create a new connection
enter Host: DNS name of remote router <I know this is correct>
Port: 7091

When I do "Test Connection" it times out with an error.

( I have opened port 7091 on the server using: "sudo ufw allow 7091". Do I need to open any other ports? )

How to proceed???

It might help to set -Djava.rmi.server.hostname=

You should not need to set -Dcom.sun.management.jmxremote.rmi.port=7091 explicitly, it should default to the same as com.sun.management.jmxremote.port, but just to be sure you could set that as well...

I finally found out the correct configuration:

$javabin -Xms2048M -Xmx4096M $GCLOG \
 -XX:+UnlockCommercialFeatures   \
 -XX:+FlightRecorder  \
 -Djava.rmi.server.hostname=myhost.example.com \
 -Dcom.sun.management.jmxremote=true \
 -Dcom.sun.management.jmxremote.port=7091 \
 -Dcom.sun.management.jmxremote.rmi.port=7091 \
 -Dcom.sun.management.jmxremote.authenticate=false \
 -Dcom.sun.management.jmxremote.ssl=false \
 -Djava.net.preferIPv4Stack=true \
  com.example.MyServer -arg1 XXX -arg2 YYY -arg3 ZZZ

The important part was the java.rmi.server.hostname=myhost.example.com part, where myhost.example.com must resolve to the external interface of your router.

Also, by having

-Dcom.sun.management.jmxremote.port=7091 \
-Dcom.sun.management.jmxremote.rmi.port=7091 \

..I only have to forward that one port in the router.

I'm not sure that the preferIPv4 is important, but right now I don't care, it works!!!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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