• 监控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

  • 相关阅读:
    Spring Boot 2.0 + zipkin 分布式跟踪系统快速入门
    在线yaml转Properties
    Spring Boot 配置优先级顺序
    集群服务器下使用SpringBoot @Scheduled注解定时任务
    spring-boot项目在eclipse中指定配置文件启动
    org.hibernate.TransientObjectException异常
    Servlet、ServletConfig、ServletContext深入学习
    Spring中构造器、init-method、@PostConstruct、afterPropertiesSet孰先孰后,自动注入发生时间以及单例多例的区别、SSH线程安全问题
    nested exception is com.svorx.core.dao.PersistenceException
    yui压缩JS和CSS文件
  • 原文地址:https://www.cnblogs.com/maoyanqing/p/11570705.html
Copyright © 2020-2023  润新知