java监测工具之jconsole (tomcat内存监控)

本文介绍了如何配置 Apache Tomcat 的 JMX 监控功能,并解决了启动时出现的端口冲突问题。通过调整配置文件中的 CATALINA_OPTS 参数,实现了 jconsole 对 Tomcat 的有效监控。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

java监测工具之jconsole  (tomcat内存监控)

 

Port already in use error when trying to shutdown Apache Tomcat with JMX monitoring enabled

 

So you tried to use JMX to monitor your Tomcat instance. You might have done so with the following lines in catalina.sh:

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

Everything started up nicely, and you were able to monitor. YAY!

But when you ran the shutdown script:

user@host:/apache-tomcat-6.0.26$ bin/shutdown.sh
Using CATALINA_BASE: /apache-tomcat-6.0.26
Using CATALINA_HOME: /apache-tomcat-6.0.26
Using CATALINA_TMPDIR: /apache-tomcat-6.0.26/temp
Using JRE_HOME: /usr/lib/jvm/java-6-sun
Using CLASSPATH: /apache-tomcat-6.0.26/bin/bootstrap.jar
Error: Exception thrown by the agent : java.rmi.server.ExportException: Port already in use: 8085; nested exception is:
java.net.BindException: Address already in use

Only a kill -9 would bring down tomcat. Uh oh!

 

解决方法:
不能在JAVA_OPTS中配置监控端口,二者区别
#   JAVA_OPTS       (Optional) Java runtime options used when any command
#                   is executed.
#                   Include here and not in CATALINA_OPTS all options, that
#                   should be used by Tomcat and also by the stop process,
#                   the version command etc.
#                   Most options should go into CATALINA_OPTS.
#   CATALINA_OPTS   (Optional) Java runtime options used when the "start",
#                   "run" or "debug" command is executed.
#                   Include here and not in JAVA_OPTS all options, that should
#                   only be used by Tomcat itself, not by the stop process,
#                   the version command etc.
#                   Examples are heap size, GC logging, JMX ports etc.



CATALINA_OPTS="$CATALINA_OPTS -Djava.rmi.server.hostname=127.0.0.1 -Dcom.sun.management.jmxremote.port=1090 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"

 

如果要连接远程服务器,那么参数 -Djava.rmi.server.hostname项必须设置,设置为服务器的真实ip地址。

因此可以打开jconsole,然后远程连接127.0.0.1:1090

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值