参考:Java_jvisualvm使用JMX连接远程机器(实践)1.启动参数java-server-Xms256M-Xmx256M-Xss256K-XX:MetaspaceSize=256M-XX:MaxMetaspaceSize=256M-Dfile.encoding=UTF-8-Dsun.jun.encoding=UTF-8-Djava.security.egd=file:/dev/./urandom-Dio.netty.leakDetectionLevel=advanced-Dcom.sun.management.jmxremote=true-Dcom.sun.management.jmxremote.rmi。端口=1919-Dcom.sun.management.jmxremote.port=1919-Dcom.sun.management.jmxremote.ssl=false-Dcom.sun.management.jmxremote.authenticate=true-Dcom.sun.management.jmxremote.local。只有=假-Dcom.sun.management.jmxremote.access.file=/etc/jmx/jmxremote.access-Dcom.sun.management.jmxremote.password.file=/etc/jmx/jmxremote.password-Djava.rmi.服务器。hostname=serverpublicnetworkip-jarfoo.jar2.authenticate文件配置jmxremote.accessguestreadonlyadminreadwritejmxremote.passwordguestguestpwdadminadminpwd注意:文件内容(jmxremote.access,jmxremote.password)不能有注释文件授权chmod600jmxremote。访问chmod600jmxremote.passwordchownroot:rootjmxremote.accesschownroot:rootjmxremote.password注意不要随便改,chmod777是不行的,否则启动会报错Error:Passwordfilereadaccessmustberestricted:/etc/jmx/jmxremote.passwordsun.management.AgentConfigurationError在sun.management.jmxremote.ConnectorBootstrap.checkPasswordFile(ConnectorBootstrap.java:577)在sun.management.jmxremote.ConnectorBootstrap.startRemoteConnectorServer(ConnectorBootstrap.java:426)在sun.management.Agent.startAgent(Agent.java:262)在sun.management。Agent.startAgent(Agent.java:452)jvisualvm连接
