CATALINA_BASE="/data/server/tomcat_8080"
CPU_N=`cat /proc/cpuinfo| grep "processor"| wc -l`
IP_ADDR=`ip route get 8.8.8.8 | awk '{print $NF; exit}'`
JMX_OPTS="
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=8999
-Dcom.sun.management.jmxremote.rmi.port=8999
-Dcom.sun.management.jmxremote.local.only=true
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Djava.rmi.server.hostname=$IP_ADDR"
JAVA_OPTS="
-server
-Xmx3072M
-Xms3072M
-Xmn1024M
-XX:MetaspaceSize=256m
-XX:MaxMetaspaceSize=512m
-Xss512K
-XX:+ExplicitGCInvokesConcurrent
-XX:+UseConcMarkSweepGC
-XX:+UseParNewGC
-XX:ParallelGCThreads=$CPU_N
-XX:+CMSParallelRemarkEnabled
-XX:+CMSClassUnloadingEnabled
-XX:LargePageSizeInBytes=128M
-XX:+UseFastAccessorMethods
-XX:CMSInitiatingOccupancyFraction=80
-XX:SoftRefLRUPolicyMSPerMB=0
-XX:+PrintGC
-XX:+PrintGCDetails
-XX:+PrintGCTimeStamps
-XX:+PrintGCDateStamps
-XX:+PrintHeapAtGC
-XX:+PrintGCApplicationStoppedTime
-XX:+HeapDumpOnOutOfMemoryError"
JAVA_OPTS="$JAVA_OPTS $JMX_OPTS -Djava.nio.channels.spi.SelectorProvider=sun.nio.ch.EPollSelectorProvider"-Xloggc:$CATALINA_BASE/logs/`date +%Y%m%d%H%M%S`_gc.log
通常配置的是registry port:
-Dcom.sun.management.jmxremote.port=9123
jdk7之后rmi server port也可以配置了,可以配置成同一个。
-Dcom.sun.management.jmxremote.rmi.port=9123
但是还有一个随机端口没解决。。。还是这哥们执着,最后开了bug
http://stackoverflow.com/questions/20884353/why-java-opens-3-ports-when-jmx-is-configured
相关链接
https://issues.apache.org/bugzilla/show_bug.cgi?id=55931
http://stackoverflow.com/questions/20699068/tomcat7-with-enabled-jmx-opens-2-additional-random-listening-ports
http://tomcat.apache.org/tomcat-7.0-doc/config/listeners.html#JMX_Remote_Lifecycle_Listener_-_org.apache.catalina.mbeans.JmxRemoteLifecycleListener