zoukankan      html  css  js  c++  java
  • 监控Tomcat状态及配置AIO(APR)模式

    方法一:开发java监控页面

    mkdir /usr/local/tomcat8/webapps/memtest/

    vim /usr/local/tomcat8/webapps/memtest/meminfo.jsp

    <%
    Runtime rtm = Runtime.getRuntime();
    long mm = rtm.maxMemory()/1024/1024;
    long tm = rtm.totalMemory()/1024/1024;
    long tm = rtm.freeMemory()/1024/1024;


    out.println("JVM memory detail info:<br>");
    out.println("MAX memory:"+mm+"MB"+"<br>");
    out.println("Total memory:"+tm+"MB"+"<br>");
    out.println("Free memory:"+fm+"MB"+"<br>");
    out.println("Avaliable memory can be userd is:"+(mm+fm-tm+"MB"+"<br>");
    %>

    [root@localhost ~]# /usr/local/tomcat8/bin/shutdown.sh

    [root@localhost ~]# /usr/local/tomcat8/bin/startup.sh

    方法二:使用ins命令进行监控

    需要安装jdk (java)

    jps  -lvm   (不常用)

    方法三Tomcat远程监控功能(常用)

    vim /usr/local/tomcat8/bin/catalina.sh

    #!/bin/sh
    CATALINA_OPTS="-Djava.library.path=/usr/local/apr/lib"
    CATALINA_OPTS="$CATALINA_OPTS
    -Dcom.sun.management.jmxremote
    -Dcom.sun.management.jmxremote.port=12345     #远程端口号12345
    -Dcom.sun.management.jmxremote.authenticate=false
    -Dcom.sun.management.jmxremote.ssl=false
    -Djava.rmi.server.hostname=192.168.200.112"   #本机IP

    添加上面这几行代码

    /usr/local/tomcat8/bin/shutdown.sh

    /usr/local/tomcat8/bin/startup.sh

    在物理机java/bin里上打开

     

     

     二。修改成APR模式

    rpm -e apr --nodeps    #软件版本不一样

    yum -y install apr apr-devel

    [root@localhost ~]# cp /usr/local/tomcat8/bin/tomcat-native.tar.gz ./

    [root@localhost ~]# tar xf tomcat-native.tar.gz

    cd tomcat-native-1.2.21-src/native/

    ./configure --with-apr=/usr/bin/apr-1-config --with-java-home=/usr/local/java && make &&make install

    vim /usr/local/tomcat8/bin/catalina.sh

    CATALINA_OPTS="-Djava.library.path=/usr/local/apr/lib"
    CATALINA_OPTS="$CATALINA_OPTS
    -Dcom.sun.management.jmxremote
    -Dcom.sun.management.jmxremote.port=12345
    -Dcom.sun.management.jmxremote.authenticate=false
    -Dcom.sun.management.jmxremote.ssl=false
    -Djava.rmi.server.hostname=192.168.200.112"  

    vim /etc/profile

    添加:

    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/apr/lib

     source /etc/profile

    vim /usr/local/tomcat8/conf/server.xml

    在    69行 protocol后添加以下内容

     protocol="org.apache.coyote.http11.Http11AprProtocol"

    /usr/local/tomcat8/bin/shutdown.sh 

    /usr/local/tomcat8/bin/startup.sh 

    [root@localhost ~]# tail /usr/local/tomcat8/logs/catalina.out

     成功

    解决重启tomcat服务后,8005端口延迟启动的问题

    117      securerandom.source=file:/dev/urandom

    把random  改成urandom

  • 相关阅读:
    php基本语法与安装
    面向对象编程 es5和es6的构造函数
    利用正则搜索替换
    正则特殊符号
    正则边界符 限定符
    面试官给我挖坑:rm删除文件之后,空间就被释放了吗?
    为什么 IPv6 难以取代 IPv4
    Docker系列教程04-Docker构建镜像的三种方式
    Docker系列教程03-Docker私有仓库搭建(registry)
    Linux-I/O模型详解
  • 原文地址:https://www.cnblogs.com/maoyanqing/p/11570705.html
Copyright © 2011-2022 走看看