How to connect to Java instances running on EC2 using JMX

后端 未结 5 1404
孤独总比滥情好
孤独总比滥情好 2020-12-07 14:30

We are having problem connecting to our Java applications running in Amazon\'s EC2 cluster. We definitely have allowed both the \"JMX port\" (which is usually the RMI regist

5条回答
  •  死守一世寂寞
    2020-12-07 15:20

    A bit different approach by using ssh tunnels

    1. (On the Remote machine) Pass the following flags to the JVM

      -Dcom.sun.management.jmxremote.port=1099
      -Djava.net.preferIPv4Stack=true
      -Dcom.sun.management.jmxremote.ssl=false
      -Dcom.sun.management.jmxremote.authenticate=false
      -Djava.rmi.server.hostname=127.0.0.1
      
    2. (On the Remote machine) Check which ports java started to use

      $ netstat -tulpn | grep java
      tcp      0      0 0.0.0.0:37484         0.0.0.0:*               LISTEN      2904/java
      tcp      0      0 0.0.0.0:1099          0.0.0.0:*               LISTEN      2904/java
      tcp      0      0 0.0.0.0:45828         0.0.0.0:*               LISTEN      2904/java
      
    3. (On the local machine) Make ssh tunnels for all the ports

      ssh -N -L 1099:127.0.0.1:1099 ubuntu@
      ssh -N -L 37484:127.0.0.1:37484 ubuntu@
      ssh -N -L 45828:127.0.0.1:45828 ubuntu@`
      
    4. (On the local machine) Connect by Java Mission Control to localhost:1099

提交回复
热议问题