CATALINA_OPTS='-Dcom.sun.management.jmxremote-Dcom.sun.management.jmxremote.port=%my.jmx.port%-Dcom.sun.management.jmxremote.ssl=false-Dcom.sun.management.jmxremote.authenticate=false'
注意实际不分行
如果启时查看$CATALINA_HOME/
logs/catalina.out 如果报错类似jmx unknown host,在说明需要在/etc/hosts中配置hosts: real_ip hosts_name
在局域网有防火墙访问限制时,配置jmx时需要注意:
例如服务器在linux 部分端口开放,而你想在windows 用jconsole监控服务器运行状况,当你开通一个端口并通过该端口访问,有可能会无法连接
引用tomcat7官方文档:
Note: The JSR 160 JMX-Adaptor opens a second data channel on a random port. That is a problem when you have a local firewall installed. To fix it, configure a JmxRemoteLifecycleListener
, as described in listeners documentation.
意思是在JSR 160中JMX-Adaptor将会在一个随机端口开启第二个通道,因此,事实上我们需要同时有两个端口的访问权限,但是其中一个又是随机的,解决方案采用tomcat的
JMX Remote Lifecycle Listener:
1. This listener requires catalina-jmx-remote.jar
to be placed in $CATALINA_HOME/lib
.
2. configure $CATALINA_HOME/conf/server.xml:
|
3.with the following system properties set (e.g. in setenv.sh):
-Dcom.sun.management.jmxremote.password.file=$CATALINA_BASE/conf/jmxremote.password-Dcom.sun.management.jmxremote.access.file=$CATALINA_BASE/conf/jmxremote.access-Dcom.sun.management.jmxremote.ssl=false |
server.xml 中的 rmiRegistryPortPlatform
相当于com.sun.management.jmxremote.port
,因此在setenv.sh中不要重复设置该端口不然会报错!
jconsole中访问地址: 详情请见官方文档:
service:jmx:rmi://
http://tomcat.apache.org/tomcat-7.0-doc/config/listeners.html#JMX_Remote_Lifecycle_Listener_-_org.apache.catalina.mbeans.JmxRemoteLifecycleListener