解決:The APR based Apache Tomcat Native library which allows optimal performance in production...

tomcat日誌apr報錯引起的基於Tomcat Native加速Tomcat性能java

tomact服務啓動報錯日誌以下:
息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /home/ss/jdk1.6.0_13/jre/lib/amd64/server:/home/ss/jdk1.6.0_13/jre/lib/amd64:/home/ss/jdk1.6.0_13/jre/../lib/amd64:/usr/java/packages/lib/amd64:/lib:/usr/lib
2013-6-8 10:19:00 org.apache.coyote.http11.Http11Protocol initweb

缺乏apr的支持: 
Tomcat Native 是利用 APR 來提高Tomcat性能的本地API
Tomcat Native 這個項目可讓 Tomcat 使用 Apache 的 apr 包來處理包括文件和網絡IO操做,以提高性能。
如下是tomcat官網搜索說明:
Tomcat can use the Apache Portable Runtime to provide superior scalability, performance, and better integration with native server technologies. The Apache Portable Runtime is a highly portable library that is at the heart of Apache HTTP Server 2.x. APR has many uses, including access to advanced IO functionality (such as sendfile, epoll and OpenSSL), OS level functionality (random number generation, system status, etc), and native process handling (shared memory, NT pipes and Unix sockets).apache

網上搜索解釋:
tomcat native在具體的運行平臺上,提供了一種優化技術,它自己是基於APR(Apache Portable Runtime)技術
也就是說,咱們應用了tomcat native技術以後,tomcat在跟操做系統級別的交互方面能夠作得更好,而且它更像apache一個,能夠更好地做爲一臺web server。tomcat

目前,Tomcat Native的最新版本是1.1.27 若是tomcat包裏沒有自帶native的話
其下載地址:http://archive.apache.org/dist/tomcat/tomcat-connectors/native/1.1.24/source/tomcat-native-1.1.24-src.tar.gz
測試時發現個人tomcat1.5版本不支持tomcat-nativer的1.1.27最新版本,1.1.24版可使用.網絡


1. 安裝方法參見:http://tomcat.apache.org/native-doc/
#yum install apr-devel
#cd ~/apache-tomcat-6.0.36/bin
#tar zxf tomcat-native.tar.gz
#cd ~/apache-tomcat-6.0.36/bin/tomcat-native-1.1.23-src/jni/native
#./configure --with-apr=/usr/bin/apr-1-config --with-java-home=/home/ss/jdk1.6.0_13 --prefi
x=/home/ss/apache-tomcat-6.0.36
make && make install
安裝成功以下提示:
----------------------------------------------------------------------
Libraries have been installed in:
   /usr/local/apr/libapp

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'dom

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
2. 添加環境變量:
官網說明:Edit $CATALINA_HOME/bin/setenv.sh (creating the file if necessary) and add the path to the tc-native libraries to LD_LIBRARY_PATHsocket

tomcat安裝目錄bin下建立setenv.sh文件:
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CATALINA_HOME/lib
    export LD_LIBRARY_PATHide

3. tomcat啓動後查看日誌 apr已加載上
2013-6-8 14:31:05 org.apache.catalina.core.AprLifecycleListener init
信息: Loaded APR based Apache Tomcat Native library 1.1.23 using APR version 1.3.9.
2013-6-8 14:31:05 org.apache.catalina.core.AprLifecycleListener init
信息: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].性能

 

 若是仍是報錯路徑下找不到庫:

息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /home/saas/jdk1.6.0_13/jre/lib/amd64/server:/home/saas/jdk1.6.0_13/jre/lib/amd64:/home/saas/jdk1.6.0_13/jre/../lib/amd64:/usr/java/packages/lib/amd64:/lib:/usr/lib解決,將安裝好的libtcnative庫拷貝到上面提示的任一地址下便可:# ll  ~/jdk1.6.0_13/jre/lib/amd64/server/-rw-r--r-- 1 saas saas 1604882 6月  18 16:43 libtcnative-1.a-rwxr-xr-x 1 saas saas    1042 6月  18 16:43 libtcnative-1.la-rwxr-xr-x 1 saas saas  902937 6月  18 16:42 libtcnative-1.so-rwxr-xr-x 1 saas saas  902937 6月  18 16:43 libtcnative-1.so.0-rwxr-xr-x 1 saas saas  902937 6月  18 16:43 libtcnative-1.so.0.1.24

相關文章
相關標籤/搜索