| 2017.10.28 | java |
1、服务器系统centos6.5 64位、jdk1.8.0_73(64位)、tomcat-6.0.41。
2、配置tomcat/bin/catalina.sh ,在 Execute The Requested Command 上面配置一下 如下参数:
JAVA_OPTS="-server -Xms1024M -Xmx1024M -Xss512k -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.rmi.port=1099 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Djava.rmi.server.hostname=192.10.100.129"
| 3、配置jmxremote.access和jmxremote.password,(注意配置的jre路径下面的jmxremote,可以使用 ps -ef | grep java 确定一下jre的路径) |
cd /opt/jdk1.8.0_65/jre/lib/management
mv jmxremote.password.template jmxremote.password
chmod 600 jmxremote.access jmxremote.password
vi jmxremote.password
将jmxremote.password中最后两行中的注释去掉(前面为用户,后面为密码)
monitorRole 123 controlRole 123
其中monitorRole为只拥有只读权限的角色,controlRole有更高权限。
4、将两个文件复制到tomcat的conf目录下
5、在防火墙开放1099端口
/sbin/iptables -I INPUT -p tcp --dport 1099 -j ACCEPT
/etc/rc.d/init.d/iptables save
service iptables restart
6、连接centos的jconsole服务器端,输入IP地址 port
其中,我本机还需要修改/etc/hosts,
将
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
其中的127地址改为本机的地址
7、Java VisualVM插件安装方法:
到https://visualvm.github.io/pluginscenters.html中点击相应版本的链接,然后下载相应的插件,再在VisualVM中安装即可
8、可以在抽样器页签里面开始监控,它的底部有类名过滤器进行过滤
9、使用JConsole监控并保存日志到文件中,只需要编写一个日志配置,启动时指定它即可
logging.properties file that looks something like this:
handlers = java.util.logging.ConsoleHandler
.level = INFO
java.util.logging.ConsoleHandler.level = FINEST
java.util.logging.ConsoleHandler.formatter = \
java.util.logging.SimpleFormatter
// Use FINER or FINEST for javax.management.remote.level - FINEST is
// very verbose...
javax.management.level = FINEST
javax.management.remote.level = FINER
启动:
jconsole -J-Djava.util.logging.config.file=logging.properties
10.运行tomcat的# ./shutdown.sh后报异常
Error: JMX connector server communication error: service:jmx:rmi://hostname:1099
更新列表:
*
参考文章: