日期:2014-05-16  浏览次数:20758 次

linux、win下用jmx监控tomcat运行情况


for windows:
1、add below line to catalina.bat
set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote.port=1090 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.util.logging.config.file="%CATALINA_BASE%conflogging.properties"
and restart tomcat。
2、start jconsole and input
ip:port
and print inter key.



for linux:
1、vi catalina.sh
?在其中“
# ----- Execute The Requested Command -----------------------------------------”
之前插入新的一行(中间没有换行),内容如下:
CATALINA_OPTS="$CATALINA_OPTS -Djava.rmi.server.hostname=aaa.bbb.com -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=111111 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=true"
注意hostname为域名或者ip。
2、
cd /usr/java/jdk1.6.0_18/jre/lib/management
mv jmxremote.password.template jmxremote.password
chmod 600 jmxremote.access jmxremote.password
vi jmxremote.password

jmxremote.access 一般保持原始内容不变即可。
对于jmxremote.password,将 其中的:
# monitorRole? mzxwswj
# controlRole? mzxwswj
井号注释取消掉。其中monitorRole为只拥有只读权限的角色,controlRole有更高权限:读写等等。
3、
?vi /etc/sysconfig/iptables
编辑iptables,加入新一行内容:-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 111111 -j ACCEPT
4、
可以使用netstat -an | grep 111111 命令查看端口是否正常启动。
5、启动jconsole,
选择远程,输入
aaa.bbb.com:port,用户名以及密码即可。