`
stephen830
  • 浏览: 2968708 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

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

    博客分类:
  • java
 
阅读更多

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

 

 

  • 大小: 44.7 KB
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics