JConsole over ssh local port forwarding

后端 未结 4 661
被撕碎了的回忆
被撕碎了的回忆 2020-11-30 17:15

I\'d like to be able to remotely connect to a Java service that has JMX exposed, however it is blocked by a firewall. I have tried to use ssh local port forwarding, however

4条回答
  •  隐瞒了意图╮
    2020-11-30 18:07

    With almost all current JDK versions (7u25 or later) it's now possible to use JConsole and Visual JVM over SSH quite easily (because now you can bind JMX to single port).

    I use the following JVM parameters

    -Dcom.sun.management.jmxremote.port=8090
    -Dcom.sun.management.jmxremote.rmi.port=8090
    -Djava.rmi.server.hostname=127.0.0.1
    -Dcom.sun.management.jmxremote.authenticate=false
    -Dcom.sun.management.jmxremote.ssl=false
    

    Then I launch SSH connection

    ssh my.javaserver.domain -L 8090:127.0.0.1:8090
    

    After I can connect from JConsole

    Remote Process: -> localhost:8090

    And Java Visual VM

    Right Click on Local -> Add JMX Connection -> localhost:8090

提交回复
热议问题