linux tomcat8 配置 jmx监控

版权声明:转载请附链接 https://blog.csdn.net/qq_23536449/article/details/89878945

1.编辑tomcat/bin/catalina.sh

找到如下文字

# Uncomment the following line to make the umask available when using the

# org.apache.catalina.security.SecurityListener

#JAVA_OPTS="$JAVA_OPTS -Dorg.apache.catalina.security.SecurityListener.UMASK=`umask`"

# ----- Execute The Requested Command -----------------------------------------

# Bugzilla 37848: only output this if we have a TTY

在Execute The Requested Command前加入如下代码:

CATALINA_OPTS="$CATALINA_OPTS -Djava.rmi.server.hostname=10.12.116.135 -Dcom.sun.management.jmxremote

-Dcom.sun.management.jmxremote.port=8088

-Dcom.sun.management.jmxremote.ssl=falseDcom.sun.management.jmxremote.authenticate=true"

其中的 hostname换成你本机的ip, port 默认为8088。

2.编辑jmxremote.access和jmxremote.password

进入默认按照的 jdk 目录:

cd /usr/java/jdk1.8.0_45/jre/lib/management

cp jmxremote.password.template jmxremote.password

编辑最后的账户密码,去掉注释,密码改下别用默认的。

# Following are two commented-out entries.  The "measureRole" role has

# password "QED".  The "controlRole" role has password "R&D".

monitorRole  QEDworld

controlRole   R&Dhello

把文件改为运行 tomcat 的用户,如果已经是,则不需要修改

chown admin jmxremote.password jmxremote.access

chgrp admin jmxremote.password jmxremote.access

修改文件权限600,这是 java 的规范,防止别的用户看到你密码

chmod 600 jmxremote.access jmxremote.password

3. 重新启动 tomcat

重新启动 tomcat,

sh bin/shutdown.sh

sh bin/startup.sh

看 logs日志,能看到刚刚catalina.sh配置的jmx配置信息,确认 tomcat 启动正常,无报错。

4.用jvisualvm验证是否可用

使用jvisualvm连接时报错

Error: Password file read access must be restricted: /etc/cassandra/jmxremote.password

解决方案:

在配置JMX远程访问的时候,设置jmxremote.password文件权限,修改该文件时添加写权限,chmod +w jmxremote.password ,放开角色信息那俩行的注释,保存,再使用chmod 0400 jmxremote.password这样就是它正确的权限设置

猜你喜欢

转载自blog.csdn.net/qq_23536449/article/details/89878945