从tomcat5.0后,可以用 Apache Portable Runtime 来通过jni来使用native接口,提升Tomcat及Jboss的性能,同时可以提升Web静态页面的处理能力,从理论上可以不再需要专门的Web Server来处理静态页面了。当然考虑到负载均衡、rewrite、虚拟主机等支持的考虑,还会采用lighttpd来作为前端的Web Server。
在对eSales系统部署时候,采用Jboss 4.2.2.GA,简单描述一下Jboss-Tomcat 使用APR的方法,关于Tomcat支持APR的参看相关文档。
1、下载boss-4.2.2.GA,最新稳定版本为4.2.2
wget http://jaist.dl.sourceforge.net/sourceforge/jboss/jboss-4.2.2.GA.zip
2、下载APR,由于Jboss对APR有一些特别的改动,因此需要从Jboss网站下载:
3、解压jboss,假设安装路径为/opt
unzip jboss-4.2.2.GA.zip
mv jboss-4.2.2.GA /opt
4、启动jboss,测试一下Jboss安装情况
cd jboss-4.2.0.GA/bin
./run.sh
注意console输出中类似如下信息:
21:51:56,325 INFO [AprLifecycleListener] The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /opt/jdk/jre/lib/i386/server:/opt/jdk/jre/lib/i386:/opt/jdk/jre/../lib/i386:/usr/java/packages/lib/i386:/lib:/usr/lib
退出Jboss
5、解压jboss-native-2.0.4-linux2-x86-ssl.tar.gz
mkdir jboss-native
mv jboss-native-2.0.4-linux2-x86-ssl.tar.gz jboss-native/
cd jboss-native/
tar zxvf jboss-native-2.0.4-linux2-x86-ssl.tar.gz
mv bin/META-INF/bin/linux2/x86/* /opt/jboss-4.2.2.GA/bin/
mkdir /opt/jboss-4.2.2.GA/bin/native
cp –r bin/META-INF/lib/linux2/x86/* /opt/jboss-4.2.2.GA/bin/native
6、再次启动jboss
/opt//jboss-4.2.2.GA/bin/run.sh &
注意console输出的如下信息:
21:57:36,150 INFO [AprLifecycleListener] Loaded Apache Tomcat Native library 1.1.13.
21:57:36,156 INFO [AprLifecycleListener] APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
21:57:44,286 INFO [Http11AprProtocol] Initializing Coyote HTTP/1.1 on http-127.0.0.1-8080
21:57:44,288 INFO [AjpAprProtocol] Initializing Coyote AJP/1.3 on ajp-127.0.0.1-8009
说明apr已经正常启用
参考文档:
http://wiki.jboss.org/wiki/HowToAddAprToJBoss