hueel 发表于 2013-7-8 08:52:54

tomcat native

Tomcat Native 这个项目可以让 Tomcat 使用 Apache 的 apr 包来处理包括文件和网络IO操作,以提升性能。Tomcat Native 是利用 APR 来提升Tomcat性能的本地API。
软件下载地址:http://tomcat.apache.org/download-native.cgi 或者在二进制版本包内的bin目录下软件相关的包。建议使用比较新一些的版本,有一个版本有bug,网上搜索一下就知道。
安装环境需求:Development Tools    需要安装这个组的包      apr apr-devel      openssl相关包
安装过程:
查询是否安装Development Tool
# yum grouplist
Loaded plugins: fastestmirror
Setting up Group Process
Loading mirror speeds from cached hostfile
addons                                                                                    
Installed Groups:
   Development Libraries
   Development Tools    需要安装这个组的包
   Dialup Networking Support

查看安装那些apr包
# rpm -qa|grep apr
apr-1.2.7-11.el5_6.5
apr-1.2.7-11.el5_6.5
apr-util-1.2.7-11.el5_5.2
apr-util-1.2.7-11.el5_5.2

查看安装那些openssl包
# rpm -qa|grep openssl
openssl-0.9.8e-20.el5
openssl-devel-0.9.8e-20.el5
openssl-devel-0.9.8e-20.el5
openssl-0.9.8e-20.el5

   经查看发现少了apr-devel包,直接yum安装
# yum install apr-devel
Loaded plugins: fastestmirror
Existing lock /var/run/yum.pid: another copy is running as pid 28125.
Another app is currently holding the yum lock; waiting for it to exit...
The other application is: yum
    Memory :19 M RSS (236 MB VSZ)
    Started: Thu Jun 27 00:46:45 2013 - 00:41 ago
    State: Sleeping, pid: 28125
Loading mirror speeds from cached hostfile
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package apr-devel.i386 0:1.2.7-11.el5_6.5 set to be updated
---> Package apr-devel.x86_64 0:1.2.7-11.el5_6.5 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
=====================================================================================================================
Package                  Arch                  Version                              Repository             Size
=====================================================================================================================
Installing:
apr-devel                  i386                  1.2.7-11.el5_6.5                     base                  233 k
apr-devel                  x86_64                  1.2.7-11.el5_6.5                     base                  238 k
Transaction Summary
=====================================================================================================================
Install       2 Package(s)
Upgrade       0 Package(s)
Total download size: 471 k
Is this ok : y
Downloading Packages:
(1/2): apr-devel-1.2.7-11.el5_6.5.i386.rpm                                                    | 233 kB   00:00
(2/2): apr-devel-1.2.7-11.el5_6.5.x86_64.rpm                                                | 238 kB   00:00
---------------------------------------------------------------------------------------------------------------------
Total                                                                                 12 kB/s | 471 kB   00:40
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing   : apr-devel                                                                                     1/2
Installing   : apr-devel                                                                                     2/2
Installed:
apr-devel.i386 0:1.2.7-11.el5_6.5                        apr-devel.x86_64 0:1.2.7-11.el5_6.5                  
Complete!

    安装native(我使用的是tomcat二进制包bin目录下的包)
# pwd
/usr/local/tomcat6/bin
# ls
bootstrap.jar       commons-daemon-native.tar.gzsetclasspath.shtomcat-juli.jar       version.sh
catalina.bat      cpappend.bat                  shutdown.bat   tomcat-native.tar.gz
catalina.sh         digest.bat                  shutdown.sh      tool-wrapper.bat
catalina-tasks.xmldigest.sh                     startup.bat      tool-wrapper.sh
commons-daemon.jarsetclasspath.bat            startup.sh       version.bat
# tar zxf tomcat-native.tar.gz
# ls
bootstrap.jar       commons-daemon-native.tar.gzsetclasspath.shtomcat-juli.jar         version.bat
catalina.bat      cpappend.bat                  shutdown.bat   tomcat-native-1.1.22-srcversion.sh
catalina.sh         digest.bat                  shutdown.sh      tomcat-native.tar.gz
catalina-tasks.xmldigest.sh                     startup.bat      tool-wrapper.bat
commons-daemon.jarsetclasspath.bat            startup.sh       tool-wrapper.sh
# cd tomcat-native-1.1.22-src/
CHANGELOG.txtjni/         KEYS         LICENSE      NOTICE         README.txt
# cd tomcat-native-1.1.22-src/jni/native/
# ./configure --with-apr=/usr --with-ssl
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking for working mkdir -p... yes
Tomcat Native Version: 1.1.22
checking for chosen layout... tcnative
checking for APR... yes
setting CC to "gcc"
setting CPP to "gcc -E"
checking for JDK location (please wait)... /usr/local/jdk1.6.0_43 from environment
checking Java platform... checking Java platform...
checking for sablevm... NONE
adding "-I/usr/local/jdk1.6.0_43/include" to TCNATIVE_PRIV_INCLUDES
checking os_type directory...linux
adding "-I/usr/local/jdk1.6.0_43/include/linux" to TCNATIVE_PRIV_INCLUDES
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for OpenSSL library... using openssl from /usr/lib and /usr/include
checking OpenSSL library version... ok
checking for OpenSSL DSA support... yes
setting TCNATIVE_LDFLAGS to "-lssl -lcrypto"
adding "-DHAVE_OPENSSL" to CFLAGS
setting TCNATIVE_LIBS to ""
setting TCNATIVE_LIBS to " /usr/lib64/libapr-1.la-lpthread -ldl"
configure: creating ./config.status
config.status: creating tcnative.pc
config.status: creating Makefile
config.status: executing default commands
#make && make install

      更新共享库
# echo "/usr/local/apr/lib" >> /etc/ld.so.conf
# ldconfig

      检查是否安装好
# ldconfig -v|grep native
      libtcnative-1.so.0 -> libtcnative-1.so.0.1.22
   到此,tomcat native已经安装完成

bco 发表于 2013-7-8 09:20:26

爱——不是想出来的,爱——是做出来的!!

xsmscb 发表于 2013-7-8 13:04:58

学习了,谢谢分享、、、

于一 发表于 2013-7-9 05:00:37

看帖回帖是美德!:lol

iszjw 发表于 2013-7-9 10:06:56

学习了,谢谢分享、、、

renran421 发表于 2013-7-10 02:08:46

丑,但是丑的特别,也就是特别的丑!

hncys 发表于 2013-7-10 23:42:41

我不在江湖,但江湖中有我的传说。
页: [1]
查看完整版本: tomcat native