免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3414 | 回复: 0
打印 上一主题 下一主题

基于Tomcat Native加速Tomcat性能 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-12-22 16:27 |只看该作者 |倒序浏览
跟tomcat相关的project,除了connector外,还有另外一个叫tomcat native,地址是:
http://tomcat.apache.org/native-doc/
,tomcat native在具体的运行平台上,提供了一种优化技术,它本身是基于ARP(Apache Portable Runtime)技术,在tomcat的document当中提到:

应用了tomcat native技术之后,tomcat在跟操作系统级别的交互方面可以做得更好,并且它更像apache一个,可以更好地作为一台web server。
如果是win32/wind64的操作系统,可以下载tcnative-1-ipv4.dll或tcnative-1-ipv6.dll,并把这些文件放在%TOMCAT_HOME%/bin目录下就可以了,这样tomcat会有更好的performance。
目前,Tomcat Native的最新版本是1.1.14,其下载地址是:
http://tomcat.heanet.ie/native/1.1.14/
需要选择相应的操作系统,对于windows操作系统比较方便,直接下载dll文件,然后丢到tomcat的bin即可,而对于linux,还需要按照document进行配置跟编辑才能使用。
没有使用tomcat native技术进行启动,系统启动需要3秒多。而将tomcat native放到bin目录之后,启动飞快,一秒种搞定!

linux 的操作系统
1: 安装apr,apr-util
位置:/usr/local/
当前版本:apr-1.2.11.tar.gz,apr-util-1.2.10
分别在解压的目录中执行:
./configure && make && make isntall
最开始的情况是:
启动 tomcat
# /usr/local/etc/rc.d/tomcat6 start
默认情况下按照好了 Tomcat 6,启动时会在 /usr/local/apache-tomcat6.0/logs/stdout.log 里出现下面的
日志

INFO: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the
java
.library.path: /usr/local/diablo-jdk1.5.0/jre/lib/i386/client:/usr/local/diablo-jdk1.5.0/jre/lib/i386:/usr/local/diablo-jdk1.5.0/jre/../lib/i386:/usr/lib:/usr/local/lib
2:下面就来安装 tomcat-native,
# cd /usr/local/apache-tomcat6.0/bin
# tar xvf tomcat-native.tar.gz
# cd ./tomcat-native-1.1.10-src/jni/native/
# set env JAVA_HOME /usr/local/diablo-jdk1.5.0/
# ./configure --with-apr=/usr/local
# make
# make install
安装好了之后会有个提示:
----------------------------------------------------------------------
Libraries have been installed in:
/usr/local/apr/lib
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
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(

manual pages.
----------------------------------------------------------------------
安装后多出一个目录 /usr/local/apr
然后安装上面的提示操作一下就好了,我这里用的 link 的方式:
# ln -s /usr/local/apr/lib/libtcnative-1.so /usr/local/diablo-jdk1.5.0/jre/lib/i386/libtcnative-1.so
再重启 tomcat,
# /usr/local/etc/rc.d/tomcat6 restart
再看 tomcat 的日志:
# cat /usr/local/apache-tomcat6.0/logs/stdout.log
Aug 6, 2007 11:40:01 PM org.apache.catalina.core.AprLifecycleListener init
INFO: Loaded Apache Tomcat Native library 1.1.10.
Aug 6, 2007 11:40:01 PM org.apache.catalina.core.AprLifecycleListener init
……
嗯,看起来安装成功了。
更多信息和其它的配置还是去看
http://tomcat.apache.org/tomcat-6.0-doc/apr.html
吧。
遇到的问题:
add LIBDIR to the `LD_LIBRARY_PATH' environment variable
during execution
因为没有做这一步,运行TOMCAT的时候,总是报出找不到JDK路径的错。
设置:
export LD_LIBRARY_PATH = /usr/local/apr/lib





本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/1676/showart_2128172.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP