Remote JMX connection

前端 未结 12 923
后悔当初
后悔当初 2020-11-29 15:54

I\'m trying to open a JMX connection to java application running on a remote machine.

The application JVM is configured with the following options:

  • com
相关标签:
12条回答
  • 2020-11-29 16:18

    To enable JMX remote, pass below VM parameters along with JAVA Command.

        -Dcom.sun.management.jmxremote 
        -Dcom.sun.management.jmxremote.port=453
        -Dcom.sun.management.jmxremote.authenticate=false                               
        -Dcom.sun.management.jmxremote.ssl=false 
        -Djava.rmi.server.hostname=myDomain.in
    
    0 讨论(0)
  • 2020-11-29 16:21

    the thing that work for me was to set /etc/hosts to point the hostname to the ip and not to the loopback interface and than restart my application.

    cat /etc/hosts

    127.0.0.1      localhost.localdomain localhost
    192.168.0.1    myservername
    

    This is my configuration:

    -Dcom.sun.management.jmxremote.port=1617 
    -Dcom.sun.management.jmxremote.ssl=false 
    -Dcom.sun.management.jmxremote.authenticate=false
    
    0 讨论(0)
  • 2020-11-29 16:21

    Try this, I tested to access JMX inside docker container

    -Dcom.sun.management.jmxremote=true -Djava.rmi.server.hostname=localhost -Dcom.sun.management.jmxremote.port=16000 -Dcom.sun.management.jmxremote.rmi.port=16000 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false

    Then

    $ jconsole localhost:16000

    0 讨论(0)
  • 2020-11-29 16:23

    Thanks a lot, it works like this:

    java -Djava.rmi.server.hostname=xxx.xxx.xxx.xxx -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.port=25000 -jar myjar.jar

    0 讨论(0)
  • 2020-11-29 16:24

    Had it been on Linux the problem would be that localhost is the loopback interface, you need to application to bind to your network interface.

    You can use the netstat to confirm that it is not bound to the expected network interface.

    You can make this work by invoking the program with the system parameter java.rmi.server.hostname="YOUR_IP", either as an environment variable or using

    java -Djava.rmi.server.hostname=YOUR_IP YOUR_APP
    
    0 讨论(0)
  • 2020-11-29 16:25

    I've spend more than a day trying to make JMX to work from outside localhost. It seems that SUN/Oracle failed to provide a good documentation on this.

    Be sure that the following command returns you a real IP or HOSTNAME. If it does return something like 127.0.0.1, 127.0.1.1 or localhost it will not work and you will have to update /etc/hosts file.

    hostname -i
    

    Here is the command needed to enable JMX even from outside

    -Dcom.sun.management.jmxremote 
    -Dcom.sun.management.jmxremote.authenticate=false 
    -Dcom.sun.management.jmxremote.ssl=false 
    -Dcom.sun.management.jmxremote.port=1100
    -Djava.rmi.server.hostname=myserver.example.com
    

    Where as you assumed, myserver.example.com must match what hostname -i returns.

    Obviously, you need to be sure that the firewall does not block you, but I'm almost sure that this is not your problem, the problem being the last parameter that is not documented.

    0 讨论(0)
提交回复
热议问题