tomcat 开启jmx进行远程监控

#catalina.sh
export CATALINA_OPTS='-Dcom.sun.management.jmxremote -Djava.rmi.server.hostname=192.168.1.120 -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.authenticate=true -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.access.file=$CATALINA_HOME/conf/jmxremote.access -Dcom.sun.management.jmxremote.password.file=$CATALINA_HOME/conf/jmxremote.password -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp/heapdump'

由于jmxremote.password中的密码都是明文保存的,所以jmxremote.password、jmxremote.access文件的权限要注意,应该设置为只有owner才可读,当然这个用户也必须是启动tomcat的用户。



准备2个文件
cp $JAVA_HOME/jre/lib/management/jmxremote.password.template $CATALINA_HOME/conf/jmxremote.password


末尾添加:
dev  dev123456 【管理】
tomcat   123456 【只读】

cp $JAVA_HOME/jre/lib/management/jmxremote.access $CATALINA_HOME/conf/jmxremote.access


末尾添加:
tomcat   readonly
dev      readwrite
修改权限:
chmod 700 jmxremote.password
#or
chmod 600 jmxremote.password
chmod 400 jmxremote.access

猜你喜欢

转载自keren.iteye.com/blog/2252750