1、tomcat各类链接器比较java
Java Blocking Connector Java Non Blocking Connector APR/native Connector BIO NIO APR Classname Http11Protocol Http11NioProtocol Http11AprProtocol Tomcat Version 3.x onwards 6.x onwards 5.5.x onwards Support Polling NO YES YES Polling Size N/A maxConnections maxConnections Read Request Headers Blocking Non Blocking Blocking Read Request Body Blocking Blocking Blocking Write Response Blocking Blocking Blocking Wait for next Request Blocking Non Blocking Non Blocking SSL Support Java SSL Java SSL OpenSSL SSL Handshake Blocking Non blocking Blocking Max Connections maxConnections maxConnections maxConnection
二 、编译打包apr tc nativeweb
一、须要的lib
APR library
OpenSSL libraries
Java SE Development Kit (JDK)apache
安装各类libubuntu
apt-get install libapr1.0-dev libssl-dev #debian 或 yum install apr-devel openssl-devel #rhel
二、下载 tcnativecentos
wget http://mirrors.noc.im/apache/tomcat/tomcat-connectors/native/1.2.7/source/tomcat-native-1.2.7-src.tar.gz
rhel安装要注意 1.2.7 目前支持的openssl版本最高为 OpenSSL version to 1.0.2h , 若有须要用到ssl,请先自行升级openssl,不过目前rhel官方库并无这个版本。tomcat
若是是centos 那就本身随意搞了,呵呵。
若是是debian/ubuntu 就无视了bash
三、安装编译服务器
下面是官方作法:app
./configure --help ./configure --with-apr=$HOME/APR \ --with-java-home=$JAVA_HOME \ --with-ssl=$HOME/OPENSSL \ --prefix=$CATALINA_HOME $HOME/APR is something like /usr/bin/apr-1-config or the path where apr is installed. $JAVA_HOME is something /home/jfclere/JAVA/jdk1.5.0_09 path to a JDK installation. Any JDK should work but it is advisable to use the same JVM version the JVM you use with Tomcat. $HOME/OPENSSL is the path where OpenSSL is installed. $CATALINA_HOME is the path where the produced libraries will be installed. Something like $HOME/apache-tomcat-6.0.16/ 按照官方文档说明,可指定各个组件的位置, 其实不写明也能本身找到。 如: ./configure --with-apr=/usr/bin/apr-1-config \ --with-java-home=/home/jfclere/JAVA/jdk1.5.0_09/ \ --with-ssl=yes \ --prefix=$CATALINA_HOME make && make install
最后就会安装到 $CATALINA_HOME/lib中。code
=======================================================================
下面是个人作法:
我这里配置环境不太同样,因为前方有设备统一卸载SSL负载,因此这里也不须要SSL, 所以不编译SSL。 步骤以下:
如下是步骤
tar -xvf tomcat-native-1.2.7-src.tar.gz cd tomcat-native-1.2.7-src/native/ ./configure --disable-openssl --prefix=/tmp/tcnative make make install cd /tmp/tcnative tar -czvf tcnative1.2.7_nossl.tgz lib/lib*
四、 推到内网下载服务器,编译打包就完成了
省略
3、 客户端配置
1\
从内网软件库下下来
cd /home/tomcat wget http://web01/tomcat/tcnative1.2.7_nossl.tgz tar -xvf tcnative1.2.7_nossl.tgz && rm -f tcnative1.2.7_nossl.tgz
2\
在setenv.sh 加入
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/tomcat/lib
export LD_LIBRARY_PATH
3\
在 conf/server.xml 找到
这里的SSLEngine改成off 由于不须要 <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="off" /> 增长链接设置 <Service name="Catalina"> <Connector port="28080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="28443" /> <Connector port="28443" protocol="org.apache.coyote.http11.Http11Protocol" maxThreads="200" SSLEnabled="false" />
4\
启动tomcat
startup.sh
检查tcnative是否ok
grep APR catalina.out 发现 INFO: Loaded APR based Apache Tomcat Native library 1.2.7 using APR version 1.4.8.
lsof 看一下
lsof -p PID
发现:
java 28799 app02 mem REG 253,4 763798 50359083 /home/tomcat/lib/libtcnative-1.so.0.2.7
好了配置完毕
若是须要SSL 请查阅tomcat官方文档配置, 同时tcnative编译时按照官方文档作法编译便可。这里不BB了。