我在Amazon EC2上的服务器上运行的Tomcat 7进程在CATALINA_OPTS具有这些设置,这些设置应该允许我远程连接以进行JMX监视:
-Dcom.sun.management.jmxremote.port=8086 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false
但是, 远程连接不能与jconsole或jvisualvm一起使用 。 它只是超时。
我三重检查了EC2安全组允许从我的IP(并且只能从我的IP)访问JMX远程端口。
有没有设置缺失?
指定java.rmi.server.hostname选项,以便它指向EC2服务器的公共DNS名称 :
-Djava.rmi.server.hostname=your.public.dns
这足以让它为我工作,但对于更多的提示,请尝试这个博客文章:
在Amazon EC2上进行JMX监控
这里是更完整的解释如何做到这一点,而不是搞乱组安全(又名防火墙):
将以下监听器添加到server.xml中:
<listener classname="org.apache.catalina.mbeans.JmxRemoteLifecycleListener" rmiregistryportplatform="10001" rmiserverportplatform="10002" uselocalports="true" />
在tomcat / bin / setenv.sh中添加以下设置:
CATALINA_OPTS =“ - Dcom.sun.management.jmxremote \ -Dcom.sun.management.jmxremote.ssl = false \ -Dcom.sun.management.jmxremote.authenticate =假” 导出CATALINA_OPTS
重新启动tomcat
启动ssh隧道:
ssh user @ aws-host -L10001:127.0.0.1:10001 -L10002:127.0.0.1:10002
启动JConsole并input以下远程服务URL:
服务:JMX:RMI://127.0.0.1:10002 / JNDI / RMI://127.0.0.1:10001 / jmxrmi
您已将JConsole通过SSH连接到在AWS上运行的tomcat。
如发表于: http : //www.cod.ro/2012/08/monitoring-tomcat-7-on-rhel-aws-using.html
如果您在为java.rmi.server.hostname设置正确的主机名时遇到问题,请尝试以下操作:
-Djava.rmi.server.hostname=$(/usr/bin/curl -s --connect-timeout 2 instance-data.ec2.internal/latest/meta-data/public-hostname)
这适用于实例将来去的Elastic Beanstalk环境。
我也尝试使用JmxRemoteLifecycleListener,它不适合我。
这是对我的工作:
我select1005作为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"
使用SSHredirectJMX端口和RMI
使用以下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-上亚马逊-EC2 /