windows下Tomcat添加jmx监控

以tomcat7为例:

1.以windows服务形式启动的tomcat,双击tomcat安装目录下tomcat7w.exe,在Java-Java Options下,添加配置参数:

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

启动tomcat服务,此时可以使用JDK/bin目录下的jconsole.exe或jvisualvm.exe添加JMX连接9000端口,观察tomcat运行状态信息。

注意:以上几行参数后面不要有空格,之前因为9000后面有空格,启动tomcat时会提示:“错误: com.sun.management.jmxremote.port 编号无效: 9000”

2.以startup.bat脚本启动的tomcat,可以直接在catalina.bat文件中配置

set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9000 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false

其它,同服务启动方式。

3.将tomcat安装为windows服务的时候,可以通过修改service.bat中的参数,使服务安装成功后已经设置了默认参数,而不必通过tomcat7w.exe再次修改。

修改位置位于service.bat文件末尾的位置,如:

rem Set extra parameters
"%EXECUTABLE%" //US//%SERVICE_NAME% --JvmOptions "-Dcatalina.base=%CATALINA_BASE%;-Dcatalina.home=%CATALINA_HOME%;-Djava.endorsed.dirs=%CATALINA_HOME%\endorsed" --StartMode jvm --StopMode jvm
rem More extra parameters
set "PR_LOGPATH=%CATALINA_BASE%\logs"
set PR_STDOUTPUT=auto
set PR_STDERROR=auto
"%EXECUTABLE%" //US//%SERVICE_NAME% ++JvmOptions "-Djava.io.tmpdir=%CATALINA_BASE%\temp;-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager;-Djava.util.logging.config.file=%CATALINA_BASE%\conf\logging.properties;-XX:PermSize=256m;-XX:MaxPermSize=512m;-Dcom.sun.management.jmxremote;-Dcom.sun.management.jmxremote.port=9000;-Dcom.sun.management.jmxremote.ssl=false;-Dcom.sun.management.jmxremote.authenticate=false" --JvmMs 1024 --JvmMx 1024
echo The service '%SERVICE_NAME%' has been installed.

 

posted on 2016-11-16 10:58  张三的歌  阅读(858)  评论(0编辑  收藏  举报