关于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

留神: 文件(jmxremote.access, jmxremote.password)内容不能有正文

文件受权

chmod 600 jmxremote.access 
chmod 600 jmxremote.password 
chown root:root jmxremote.access 
chown root:root jmxremote.password

留神不能轻易改, chmod 777都不行 否则启动会报错

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连贯

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理