小编典典

Tomcat 6,JMX和动态端口问题

tomcat

在阅读并尝试了很多之后,我不得不问是否有人可以解决我的问题。

我正在尝试在防火墙后面设置一些Tomcat(V6)。没什么大不了的-但我想通过JMX监视它们。

我阅读了TC文档,并遇到了JMXRemoteLifecycleListener。我的测试TC安装完全按照上述链接中的说明进行设置。因此,我无法从网络中的一台主机连接到另一台主机。另外,每次启动TC时,都会打开第三个随机端口。

在我的server.xml中,侦听器已激活

<Listener className="org.apache.catalina.mbeans.JmxRemoteLifecycleListener"
rmiRegistryPortPlatform="8050" rmiServerPortPlatform="8060" />

catalina.out表示一切正常。

2011-06-14 16:46:48,819 [main] INFO org.apache.catalina.mbeans.JmxRemoteLifecycleListener-
The JMX Remote Listener has configured the registry on port 8050 and the server on port 8060 for the Platform server

端口是开放的,我可以从任何其他主机通过telnet连接到它们。我可以使用(service:jmx:rmi://<hostname>:8xxx/jndi/rmi://<hostname>:8xxxx/jmxrmi)连接到本地虚拟机

Netstats的输出如下:

tcp6       0      0 :::8080                 :::*                    LISTEN      11291/java
tcp6       0      0 :::8050                 :::*                    LISTEN      11291/java
tcp6       0      0 :::8060                 :::*                    LISTEN      11291/java
tcp6       0      0 127.0.0.1:8005          :::*                    LISTEN      11291/java
tcp6       0      0 :::60901                :::*                    LISTEN      11291/java
tcp6       0      0 127.0.0.1:8009          :::*                    LISTEN      11291/java

Tomcat甚至以所有足够的VM选项启动

CATALINA_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=TRUE 
-Dcom.sun.management.jmxremote.password.file=$CATALINA_HOME/conf/jmxremote.password
-Dcom.sun.management.jmxremote.access.file=$CATALINA_HOME/conf/jmxremote.access"

有没有人暗示我为什么被困在这里?提前致谢!


阅读 311

收藏
2020-06-16

共1个答案

小编典典

答案是-Djava.rmi.server.hostname=xxx.xxx.xxx.xxx使用常规的JMX选项。

自动设置主机名的示例:

IP=`ifconfig eth0  | grep 'inet '| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'``;

CATALINA_OPTS="-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=TRUE
-Dcom.sun.management.jmxremote.password.file=$CATALINA_HOME/conf/jmxremote.password
-Dcom.sun.management.jmxremote.access.file=$CATALINA_HOME/conf/jmxremote.access
-Djava.rmi.server.hostname=$IP"
2020-06-16