【Java】开启JMX远程监控
参考:
- 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.port=1919 -Dcom.sun.management.jmxremote.port=1919 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=true -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.access.file=/etc/jmx/jmxremote.access -Dcom.sun.management.jmxremote.password.file=/etc/jmx/jmxremote.password -Djava.rmi.server.hostname=服务器公网ip -jar foo.jar
2. authenticate文件配置
jmxremote.access
guest readonly admin readwrite
jmxremote.password
guest guestpwd admin adminpwd
文件授权
chmod 600 jmxremote.accesschmod 600 jmxremote.password
chown root:root jmxremote.access
chown root:root jmxremote.password
Error: Password file read access must be restricted: /etc/jmx/jmxremote.password sun.management.AgentConfigurationError at sun.management.jmxremote.ConnectorBootstrap.checkPasswordFile(ConnectorBootstrap.java:577) at sun.management.jmxremote.ConnectorBootstrap.startRemoteConnectorServer(ConnectorBootstrap.java:426) at sun.management.Agent.startAgent(Agent.java:262) at sun.management.Agent.startAgent(Agent.java:452)
jvisualvm连接
以上是 【Java】开启JMX远程监控 的全部内容, 来源链接: utcz.com/a/93943.html