JMX远程监控配置
无密码配置
# 设置如下选项作为启动参数: 开启jmxremote,关闭ssl,关闭认证,设置IPv4及主机IP地址和端口
JMX="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Djava.net.preferlPv4Stack=true -Djava.rmi.server.hostname=101.132.97.183 -Dcom.sun.management.jmxremote.port=9000 "
nohup java -jar -Xms4096M -Xmx4096M $JMX $jarName >> /dev/null 2>&1 &
简单密码配置
# 设置如下选项作为启动参数: 开启jmxremote,关闭ssl,开启认证,设置IPv4及主机IP地址和端口
# 开启认证后, 默认的密码文件为: JAVA_HOME/conf/management/jmxremote.password, 默认访问权限文件为: JAVA_HOME/conf/management/ jmxremote.access
# 注意: 密码文件 chmod 600 jmxremote.password (仅自己可以读写, 其他人都不允许 - 说明文件中写是为了安全考虑)
JMX="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=true -Djava.net.preferlPv4Stack=true -Djava.rmi.server.hostname=101.132.97.183 -Dcom.sun.management.jmxremote.port=9000 "
nohup java -jar -Xms4096M -Xmx4096M $JMX $jarName >> /dev/null 2>&1 &
jstatd简易配置
# vim $JAVA_HOME/bin/jstatd.all.policy
# jdk8及以前
grant codebase "file:${java.home}/../lib/tools.jar" {
permission java.security.AllPermission;
};
# jdk9及以后
grant codebase "jrt:/jdk.jstatd" {
permission java.security.AllPermission;
};
grant codebase "jrt:/jdk.internal.jvmstat" {
permission java.security.AllPermission;
};
nohup jstatd -J-Djava.security.policy=jstatd.all.policy -J-Djava.rmi.server.hostname=101.132.97.183 -p 10000 >> /dev/null 2>&1 &
参考:
https://docs.oracle.com/en/java/javase/18/management/monitoring-and-management-using-jmx-technology.html#GUID-2C1922AD-4BA0-4397-A3FE-7823F42A94A3
https://blog.csdn.net/BushQiang/article/details/114709682