• CentOS安装、配置APR和tomcat-native


    APRApache Portable Run-time libraries,Apache可移植执行库
    在早期的Apache版本号中。应用程序本身必须可以处理各种详细操作系统平台的细节,并针对不同的平台调用不同的处理函数。

    随着Apache的进一步开发。Apache组织决定将这些通用的函数独立出来并发展成为一个新的项目。这样。APR的开发就从Apache中独立出来,Apache不过使用APR而已。


    Tomcat Native:这个项目能够让 Tomcat 使用 Apache 的 apr 包来处理包含文件和网络IO操作,以提升性能。
    官网介绍:
    The Apache Tomcat Native Library is an optional component for use with Apache Tomcat that allows Tomcat to use certain native resources for performance, compatibility, etc.
    (大概意思是Tomcat能够利用一些native资源来提高性能和兼容性。


    Specifically, the Apache Tomcat Native Library gives Tomcat access to the Apache Portable Runtime (APR) library's network connection (socket) implementation and random-number generator. 
    (详细来说是利用了APR库中的网络连接实现和随机数生成器。)

    Features of the APR connector:

    • Non-blocking I/O for Keep-Alive requests (between requests)
    • Uses OpenSSL for TLS/SSL capabilities (if supported by linked APR library)
    • FIPS 140-2 support for TLS/SSL (if supported by linked OpenSSL library)

    Linux下,Tomcat启用APR须要三个组件:
    • apr
    • apr-util
    • tomcat-native.tar.gz(Tomcat自带,在bin文件夹下)

    1、查看是否已经安装了apr和apr-util
    # rpm -qa apr
    apr-1.4.8-3.el7.x86_64

    # rpm -qa apr-util
    apr-util-1.5.2-6.el7.x86_64

    2、查看是否有最新版的apr和apr-util
    # yum list | grep apr
    apr.x86_64                              1.4.8-3.el7                    @anaconda
    apr-util.x86_64                         1.5.2-6.el7                    @anaconda

    3、假设还没安装,用yum安装:
    # yum install apr-devel apr apr-util

    4、安装tomcat-native:
    搜索tomcat-native安装包:
    # yum list | grep tomcat-native

    假设已经存在,直接安装:
    # yum install tomcat-native
    ……
      正在安装    : tomcat-native-1.1.30-1.el7.x86_64        1/1
      验证中      : tomcat-native-1.1.30-1.el7.x86_64         1/1

    已安装:
      tomcat-native.x86_64 0:1.1.30-1.el7                                                                                                                                                        
    完成!

    查看是否成功安装:
    # rpm -qa tomcat-native
    tomcat-native-1.1.30-1.el7.x86_64

    配置相关的全局变量:
    # vi /etc/profile
    加入:export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/apr/lib
    # source /etc/profile

    5、重新启动Tomcat。看看能否够成功使用APR
    假设一切正常:
    APR启动:
    [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-apr-18080"]
    [main] org.apache.catalina.startup.Catalina.start Server startup in 13617 ms
    相比NIO模式的启动,速度快了一些(~15%):
    NIO启动:
    [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-18080"]
    [main] org.apache.catalina.startup.Catalina.start Server startup in 15671 ms

    假设发现异常log,比方:
    06-Aug-2015 14:46:04.949 SEVERE [main] org.apache.catalina.core.AprLifecycleListener.init An incompatible version 1.1.30 of the APR based Apache Tomcat Native library is installed, while Tomcat requires version 1.1.32

    说明系统自带的tomcat-native版本号太低。
    删除:
    # yum erase tomcat-native

    用yum检查有没有最新版:
    # yum update tomcat-native
    假设yum找不到最新版。则下载或从Tomcat/bin中解压安装。

    从Tomcat/bin文件夹中,解压tomcat-native.tar.gz文件:
    # tar -zxvf tomcat-native.tar.gz
    得到目录:tomcat-native-1.1.33-src
    # cd tomcat-native-1.1.33-src/jni/native/
    # ./configure --with-apr=/usr/local/apr    (官网中样例的其它參数不须要,会自己主动找到
    # make && make install

    參考:
    官网的安装指导:http://tomcat.apache.org/native-doc/
    Tomcat Connector三种执行模式(BIO, NIO, APR)的比較和优化:http://blog.csdn.net/clementad/article/details/47045673

    (原创文章,转载请注明转自Clement-Xu的博客)

  • 相关阅读:
    第九届蓝桥杯省赛c/c++真题明码题解答案,另类excel解法思路
    Windows下将Python源代码.py文件封装成exe可执行文件方法
    windows下python自带的pip安装速度过慢解决方案
    解决:Errors were encountered while processing
    ubuntu 安装 caffe 解决://home/xiaojie/anaconda/lib/libpng16.so.16:对‘inflateValidate@ZLIB_1.2.9’未定义的引用
    ubuntu安装caffe 解决:build_release/tools/caffe: error while loading shared libraries: libcudart.so.8.0: cannot open shar
    ubuntu 禁止内核更新
    ubutun 中notebook出现 Permission denied: Untitled.ipynb
    ubuntu下anaconda使用jupyter notebook加载tensorflow、pytorch
    ubuntu下用anaconda快速安装 pytorch
  • 原文地址:https://www.cnblogs.com/blfbuaa/p/6893817.html
Copyright © 2020-2023  润新知