使用jconsole监控tomcat jvm的使用情况

一:Linux系统下,需要修改tomcat主目录usr\local\tomcat1\bin\ catalina.sh文件

# OS specific support.  $var _must_ beset to either true or falsei.

下面添加以后内容

JAVA_OPTS="$JAVA_OPTS-Djava.rmi.server.hostname=192.168.168.128"

JAVA_OPTS="$JAVA_OPTS-Dcom.sun.management.jmxremote.port=9000"

JAVA_OPTS="$JAVA_OPTS-Dcom.sun.management.jmxremote.authenticate=false"

JAVA_OPTS="$JAVA_OPTS-Dcom.sun.management.jmxremote.ssl=false"

 

 

或者写在在一行(注意写在一起必须是一行)

JAVA_OPTS="$JAVA_OPTS -Djava.rmi.server.hostname=192.168.168.128 -Dcom.sun.management.jmxremot

e -Dcom.sun.management.jmxremote.port=9000-Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"

 

 

参数含义

-Djava.rmi.server.hostname=192.168.168.128 服务器本身ip地址

-Dcom.sun.management.jmxremote.port=9000 监控的端口可以自定义注意不要端口冲突

-Dcom.sun.management.jmxremote.ssl=false

-Dcom.sun.management.jmxremote.authenticate=false

上面设置不需要用户验证就可以连接,本人为了方便没有设置密码。如果要监控线上的服务器最后把用户验证功能打开。

保存退出,重启tomcat使配置文件生效

./shutdown.sh

./startup.sh

 

二、修改 hostname, 将127.0.0.1修改为本地真实的IP,我的服务器IP是192.168.168.128

vi /etc/hosts

 使用jconsole监控tomcat jvm的使用情况

三、本地JDK安装bin目录下启动 jconsole.exe连接服务器远程,输入IP和配置的监控端口号进行连接

使用jconsole监控tomcat jvm的使用情况

使用jconsole监控tomcat jvm的使用情况