How to connect to Java instances running on EC2 using JMX

后端 未结 5 1398
孤独总比滥情好
孤独总比滥情好 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:28

    Per the second answer Why does JMX connection to Amazon EC2 fail?, the difficulty here is that by default the RMI port is selected at random, and clients need access to both the JMX and RMI ports. If you're running jdk7u4 or later, the RMI port can be specified via an app property. Starting my server with the following JMX settings worked for me:

    Without authentication:

    -Dcom.sun.management.jmxremote 
    -Dcom.sun.management.jmxremote.port=9999 
    -Dcom.sun.management.jmxremote.rmi.port=9998 
    -Dcom.sun.management.jmxremote.ssl=false 
    -Dcom.sun.management.jmxremote.authenticate=false 
    -Djava.rmi.server.hostname=
    

    With authentication:

    -Dcom.sun.management.jmxremote 
    -Dcom.sun.management.jmxremote.port=9999 
    -Dcom.sun.management.jmxremote.rmi.port=9998 
    -Dcom.sun.management.jmxremote.ssl=false 
    -Dcom.sun.management.jmxremote.authenticate=true 
    -Dcom.sun.management.jmxremote.password.file=/path/to/jmxremote.password
    -Djava.rmi.server.hostname=
    

    I also opened ports 9998-9999 in the EC2 security group for my instance.

提交回复
热议问题