【问题标题】:Using VisualVM on tomcat 8 running on EC2在 EC2 上运行的 tomcat 8 上使用 VisualVM
【发布时间】:2015-03-27 00:04:46
【问题描述】:

我正在尝试在我的系统中使用 VisualVM 来监控在 EC2 上运行的 Tomcat 实例。我尝试了多个博客中提供的有关如何配置它的步骤,但是当我尝试运行 tomcat 时仍然出现以下错误。

./catalina.sh: 5: /home/gvr/apache-tomcat-8.0.18/bin/setenv.sh: -Dcom.sun.management.jmxremote: not found

我在server.xml中添加了以下语句

<listener classname="org.apache.catalina.mbeans.JmxRemoteLifecycleListener"
rmiregistryportplatform="10001"
rmiserverportplatform="10002"
uselocalports="true" /> 

而我的setenv.sh如下

CATALINA_OPTS="-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
-Djava.rmi.server.hostname=ec2-xx-xxx-xx-xx.ap-southeast-1.compute.amazonaws.com"
$CATALINA_OPTS

除此之外,我在tomcat的lib目录中添加了catalina-jmx-remote.jar

谁能给我一些提示,可能出了什么问题。我尝试了所有与配置 VisualVM 相关的方法

我在 ubuntu 上运行 Tomcat 8.0.18、java 8

【问题讨论】:

    标签: java tomcat amazon-web-services amazon-ec2 visualvm


    【解决方案1】:

    我认为有两个问题

    • setenv.sh 中的格式化,需要 \ 跨行分割
    • 最后一行 $CATALINA_OPTS 尝试执行参数,因此 -Dcom.sun.management.jmxremote not found...

    建议修复

    CATALINA_OPTS="-Dcom.sun.management.jmxremote \
    -Dcom.sun.management.jmxremote.ssl=false \
    -Dcom.sun.management.jmxremote.authenticate=false \
    -Djava.rmi.server.hostname=ec2-xx-xxx-xx-xx.ap-southeast-1.compute.amazonaws.com"
    echo $CATALINA_OPTS
    

    【讨论】:

      【解决方案2】:

      我也尝试使用 JmxRemoteLifecycleListener,但它对我不起作用。

      这是我的做法: 1)我选择 1005 作为 jmx 端口,我的 setenve.sh 是这样的:

      CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=10005 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate =false -Dcom.sun.management.jmxremote.local.only=false -Djava.rmi.server.hostname=localhost"

      2) 使用 ssh 重定向 jmx 端口和 rmi

      3) 使用以下 uri 运行 visualvm:service:jmx:rmi:///jndi/rmi://localhost:10005/jmxrmi

      如果您需要更多信息,请查看此帖子: http://ignaciosuay.com/how-to-connect-a-java-profiler-like-visualvm-or-jconsole-to-a-remote-tomcat-running-on-amazon-ec2/

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-08-09
        • 1970-01-01
        • 1970-01-01
        • 2012-02-12
        • 2017-05-01
        • 1970-01-01
        • 1970-01-01
        • 2016-06-04
        相关资源
        最近更新 更多