CentOS安裝、配置APR和tomcat-native

來源:互聯網
上載者:User

標籤:centos   apr   tomcat-native   tomcat   

APR:Apache 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 aprapr-1.4.8-3.el7.x86_64
# rpm -qa apr-utilapr-util-1.5.2-6.el7.x86_64
2、查看是否有最新版的apr和apr-util# yum list | grep aprapr.x86_64                              1.4.8-3.el7                    @anacondaapr-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-nativetomcat-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的部落格)

著作權聲明:本文為原創文章,轉載請註明轉自Clement-Xu的csdn部落格。

CentOS安裝、配置APR和tomcat-native

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.