一、搭建jconsole监控远程tomcat运行状态步骤
1.tomcat所在设备的jdk开放访问的账号和密码:
(1)在tomcat目录下新建文件夹jmx_conf。
(2)拷贝$JAVA_HOME/jre/lib/managent/目录下的文件jmxremote.access和jmxremote.password.template到文件夹jmx_conf。
(3)添加访问账号和权限:修改jmxremote.access文件,在文件末尾添加一行:hmadmin readonly。表示账号hmadmin有readonly的权限。
(4)设置访问密码:mv jmxremote.password.template jmxremote.password,在文件末尾添加一行:hmadmin 123456。表示账号户名hmadmin,密码为123456。
2.修改tomcat的catalina.sh文件:
添加以下内容:
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.access.file=../jmx_conf/jmxremote.access -Dcom.sun.management.jmxremote.password.file=../jmx_conf/jmxremote.password"
CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote.port=8099 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=true -Djava.rmi.server.hostname=192.168.10.34"
备注:JAVA_OPTS中指定账号密码等的配置文件路径,此处由于文件路径采取相对路径形式如: ../jmx_conf/jmxremote.access,所以一定要在bin目录下执行启动脚本start.sh: ./start.sh。 若是指定文件路径,则默认到$JAVA_HOME/jre/lib/managent/路径下查找jmxremote.access和jmxremote.password文件。
-Djava.rmi.server.hostname=192.168.10.34参数指定访问的ip,即tomcat所在设备的ip,必须要设置。
-Dcom.sun.management.jmxremote.port=8099 参数指定访问的端口,必须设置。
3.在另一台设备的$JAVA_HOME/bin,目录下执行jconsole.exe,选择远程进程,输入ip:port和用户名、密码既可以监控tomcat的运行情况。