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 |
||
- 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
- edit the access allow file $CATALINA_BASE/conf/jmxremote.access :
monitorRole readonly controlRole readwrite
- edit the password file $CATALINA_BASE/conf/jmxremote.password :
monitorRole tomcat controlRole tomcat
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:
- Install the tomcat compat package
- Install the mx4j-tools.jar at common/lib. Please, use the same MX4j version as your Tomcat release
- 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.
- Start your Tomcat and look with a browser at http://${JMX.HOST}:${JMX.PORT}
- With the mx connector parameter
mx.authMode="basic" mx.authUser="tomcat" mx.authPassword="strange"
you can control the access! - 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.