Oracle JRockit Mission Control 配置

用于分析jrockit虚拟机性能,可以实时监控性能,分析内存使用等等,现在的版本上面有很详细的帮助,还TMD中文的,感谢甲骨文。
服务器端配置简单,就是配置JMX
1.准备访问控制的.access和.password文件

mkdir -p /etc/jre_accesscp $JAVA_HOME/jre/lib/management/jmxremote.password.template /etc/jre_access/jmxremote.passwordcp $JAVA_HOME/jre/lib/management/jmxremote.access /etc/jre_access/jmxremote.accessvi /etc/jre_access/jmxremote.password# ...# monitorRole  QED# controlRole   R&Dusername   userpasswd
 vi /etc/jre_access/jmxremote.access##monitorRole   readonly#controlRole   readwrite \#              create javax.management.monitor.*,javax.management.timer.* \#              unregisterusername  readwrite
 chmod 600 /etc/jre_access/jmxremote.passwordchmod 644 /etc/jre_access/jmxremote.access

2.添加 启动jmx类

#jport=开启的监控端口#SERVERIP=服务所在服务器IP$JAVA_HOME/bin/java -Dcom.sun.management.jmxremote.port=$jport -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=true -Dcom.sun.management.jmxremote.access.file=/etc/jre_access/jmxremote.access -Dcom.sun.management.jmxremote.password.file=/etc/jre_access/jmxremote.password -Djava.rmi.server.hostname=$SERVERIP ...#接JAVA项目参数

3.tomcat添加JMX监控
和java项目差不多,采用的是yum安装的Tomcat/7.0.39
直接贴到tomcat7.conf里的JAVA_OPTS里面能够启动,但关闭蛋疼不能用,去掉参数就可以关闭
无奈把tomcat7.conf换成两份tomcat7_start.conf,tomcat7_stop.conf,并修改/etc/init.d/tomcat7

#---------#贴代码#---------cp /etc/tomcat7/tomcat7.conf /etc/tomcat7/tomcat7_start.confcp /etc/tomcat7/tomcat7.conf /etc/tomcat7/tomcat7_stop.conf
 vi /etc/tomcat7/tomcat7_start.conf# 添加如下内容..JAVA_OPTS="$JAVA_OPTS -verbosegc -Dcom.sun.management.jmxremote.port=7091 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=true -Dcom.sun.management.jmxremote.access.file=/etc/jre_access/jmxremote.access -Dcom.sun.management.jmxremote.password.file=/etc/jre_access/jmxremote.password  -Djava.rmi.server.hostname=218.58.x.x " vi /etc/init.d/tomcat7# 修改TOMCAT_CFG部分# Get the tomcat config (use this for environment specific settings)TOMCAT_CFG_start="/etc/tomcat7/tomcat7_start.conf"if [ -r "$TOMCAT_CFG_start" ]; then
    . $TOMCAT_CFG_startfi TOMCAT_CFG_stop="/etc/tomcat7/tomcat7_stop.conf"if [ -r "$TOMCAT_CFG_stop" ]; then
    . $TOMCAT_CFG_stopfi # 修改function parseOptions()function parseOptions_start() {
    options=""
    options="$options $(
                 awk '!/^#/ && !/^$/ { ORS=" "; print "export ", $0, ";" }' \                 $TOMCAT_CFG_start
             )"
    if [ -r "/etc/sysconfig/${NAME}" ]; then
        options="$options $(
                     awk '!/^#/ && !/^$/ { ORS=" ";
                                           print "export ", $0, ";" }' \                     /etc/sysconfig/${NAME}
                 )"
    fi
    TOMCAT_SCRIPT="$options ${TOMCAT_SCRIPT}"} function parseOptions_stop() {
    options=""
    options="$options $(
                 awk '!/^#/ && !/^$/ { ORS=" "; print "export ", $0, ";" }' \                 $TOMCAT_CFG_stop
             )"
    if [ -r "/etc/sysconfig/${NAME}" ]; then
        options="$options $(
                     awk '!/^#/ && !/^$/ { ORS=" ";
                                           print "export ", $0, ";" }' \                     /etc/sysconfig/${NAME}
                 )"
    fi
    TOMCAT_SCRIPT="$options ${TOMCAT_SCRIPT}"} #修改function start和stop内调用的parseOptionsfunction start() {...
    parseOptions_start
...} function stop() {...
    parseOptions_stop
...} #修改stop参数,执行两次
    stop)
        stop >> /dev/null 2>&1
        stop        ;;

这样客户端就可以通过Oracle JRockit Mission Control 连接监控JVM项目
本回完


你可能感兴趣的:(jvm,监控)