码迷,mamicode.com
首页 > 其他好文 > 详细

tomcat Enabling JMX Remote

时间:2016-12-02 16:37:40      阅读:198      评论:0      收藏:0      [点我收藏+]

标签:tomcat java jmx

wiki 利用JMX做存活监控

cat /opt/wiki/work/bin/setenv.sh | grep jmxremote
CATALINA_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8410 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Duser.timezone=Asia/Shanghai ${CATALINA_OPTS}"

 

关于如何Enabling JMX Remote,参考如下:

http://tomcat.apache.org/tomcat-5.5-doc/monitoring.html#Enabling_JMX_Remote

 

The Sun website includes the list of options and how to configure JMX Remote on Java 5:http://java.sun.com/j2se/1.5.0/docs/guide/management/agent.html.

For quick installation you find here a short installation guide:

Add the following parameters to your Tomcat startup script:

    set 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

 

 

  1. When you think authorization is a good, add and change this :

        -Dcom.sun.management.jmxremote.authenticate=true     -Dcom.sun.management.jmxremote.password.file=../conf/jmxremote.password     -Dcom.sun.management.jmxremote.access.file=../conf/jmxremote.access \
  2. edit the access allow file $CATALINA_BASE/conf/jmxremote.access :

    monitorRole readonly
    controlRole readwrite
  3. edit the password file $CATALINA_BASE/conf/jmxremote.password :

    monitorRole tomcat
    controlRole tomcat

    Tip: Password File must be readonly and not accessible from every other user! Remove all other users under windows to access this file.

Note:The JSR 160 JMX-Adaptor opens a second data protocol port. That is a problem when you have installed a local firewall. However, there is at least one possible workaround: using a custom JMXConnectorServer.

 

Start a JMX Adaptor with fix data port is supported with Tomcat 5.5.25 src release:

<Server ...>
...
<Listener className="org.apache.catalina.mbeans.JMXAdaptorLifecycleListener"
          namingPort="8083" port="8084" host="myhost" />  
...
</Server>

You can use all JMX system properties (com.sun.management.jmxremote.xxx) to configure the adaptor :-) 
At your remote jconsole call the jmx adaptor with following command 
jconsole service:jmx:rmi://myhost:8084/jndi/rmi://myhost:8083/server

 

Activate JMX MX4J Http Adaptor with Java 1.4:

  1. Install the tomcat compat package

  2. Install the mx4j-tools.jar at common/lib. Please, use the same MX4j version as your Tomcat release

  3. Configure a MX4J JMX HTTP Adaptor at your AJP Connector

     

          <Connector port="${AJP.PORT}" 
                handler.list="mx" 
                mx.enabled="true" 
                mx.httpHost="${JMX.HOST}"
                mx.httpPort="${JMX.PORT}"
                protocol="AJP/1.3" />

     

    Tip: With ${AJP.PORT}=0 no ajp connection where started.

    Note: MX4J JSR 160 RMI Adaptor to support JDK 1.4 currently not integrated.

  4. Start your Tomcat and look with a browser at http://${JMX.HOST}:${JMX.PORT}

  5. With the mx connector parameter mx.authMode="basic" mx.authUser="tomcat" mx.authPassword="strange" you can control the access!

  6. A complete list of all Tomcat core MBeans can you find at http://tomcat.apache.org/tomcat-5.5-doc/catalina/funcspecs/mbean-names.html.


tomcat Enabling JMX Remote

标签:tomcat java jmx

原文地址:http://tenderrain.blog.51cto.com/9202912/1878805

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!