Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2814023
  • 博文数量: 587
  • 博客积分: 6356
  • 博客等级: 准将
  • 技术积分: 6410
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-23 10:54
个人简介

器量大者,福泽必厚

文章分类

全部博文(587)

文章存档

2019年(3)

2018年(1)

2017年(29)

2016年(39)

2015年(66)

2014年(117)

2013年(136)

2012年(58)

2011年(34)

2010年(50)

2009年(38)

2008年(16)

分类: LINUX

2010-06-11 10:54:11

摘之书上的一句:

Keep in mind, however, that Apache httpd may not be more efficient at serving your content than Tomcat standalone is. Tomcat’s web server is highly optimized, and today’s Java runtimes are very good at natively compiling Tomcat so that the resulting binary it is running is also highly optimizedfor your operating system andarchitecture.Configuring Tomcat so that all of its requests must first travel through Apache httpd may actually slow down Tomcat’s response times, and it is usually the  performance of the dynamic content that web server administrators need to improve.

1:下载native, 它编译时需要apr、openssl、jdk

 如下:

Build tc-native requires three components to be installed:

APR library
OpenSSL libraries
Java SE Development Kit (JDK)

2:我下定apr为apr-1.3.8.tar.bz2

安装如下:

[root@localhost apr-1.3.8]# ./configure --prefix=/opt/apr

[root@localhost apr-1.3.8]# make &&  make install

3:openssl一般系统默认都已经安装,自己就不需要安装了。

是否已经安装可以用下面的命令来取证:

[root@localhost bin]# which openssl  #测试是否安装了openssl

/usr/bin/openssl  

4:安装jdk, 一般下载二进制版本,直接运行即可。我把jdk安装在/usr/local/jdk目录下,并进行java路径配置。

我的配置如下:

[root@localhost logs]# cd
[root@localhost ~]# cat .bashrc
# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

#红色字体为添加部分

export JAVA_HOME=/usr/local/jdk
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export CATALINA_HOME=/opt/tomcat5.5  ##我打算把tomat安装在/opt目录下

5:安装tomcat, 我下载的为apache-tomcat-5.5.26.tar.gz
直接:

[root@localhost software]#tar zxvf apache-tomcat-5.5.26.tar.gz -C /opt

[root@localhost software]#cd /opt

[root@localhost software]#ln -s apache-tomcat-5.5.26  tomcat5.5

6:安装native, 我下载的为tomcat-native-1.1.20-src.tar.gz

安装方法如下:

[root@localhost software]# tar zxvf tomcat-native-1.1.20-src.tar.gz
[root@localhost native]# ./configure --with-apr=/opt/apr/bin/apr-1-config --with-java-home=/usr/local/jdk --with-ssl=yes --prefix=/opt/tomcat5.5/

[root@localhost native]# make

[root@localhost native]# make install
make[1]: Entering directory `/home/software/tomcat-native-1.1.20-src/jni/native'
make[1]: Nothing to be done for `local-all'.
make[1]: Leaving directory `/home/software/tomcat-native-1.1.20-src/jni/native'
/opt/apr/build-1/mkdir.sh /opt/tomcat5.5//include/apr-1 /opt/tomcat5.5//lib/pkgconfig \
             /opt/tomcat5.5//lib /opt/tomcat5.5//bin
mkdir /opt/tomcat5.5/include
mkdir /opt/tomcat5.5/include/apr-1
mkdir /opt/tomcat5.5/lib
mkdir /opt/tomcat5.5/lib/pkgconfig
/usr/bin/install -c -m 644 tcnative.pc /opt/tomcat5.5//lib/pkgconfig/tcnative-1.pc
list=''; for i in $list; do \
        ( cd $i ; make DESTDIR= install ); \
done
/bin/sh /opt/apr/build-1/libtool --mode=install /usr/bin/install -c -m 755 libtcnative-1.la /opt/tomcat5.5//lib
/usr/bin/install -c -m 755 .libs/libtcnative-1.so.0.1.20 /opt/tomcat5.5//lib/libtcnative-1.so.0.1.20
(cd /opt/tomcat5.5//lib && { ln -s -f libtcnative-1.so.0.1.20 libtcnative-1.so.0 || { rm -f libtcnative-1.so.0 && ln -s libtcnative-1.so.0.1.20 libtcnative-1.so.0; }; })
(cd /opt/tomcat5.5//lib && { ln -s -f libtcnative-1.so.0.1.20 libtcnative-1.so || { rm -f libtcnative-1.so && ln -s libtcnative-1.so.0.1.20 libtcnative-1.so; }; })
/usr/bin/install -c -m 755 .libs/libtcnative-1.lai /opt/tomcat5.5//lib/libtcnative-1.la
/usr/bin/install -c -m 755 .libs/libtcnative-1.a /opt/tomcat5.5//lib/libtcnative-1.a
chmod 644 /opt/tomcat5.5//lib/libtcnative-1.a
ranlib /opt/tomcat5.5//lib/libtcnative-1.a
PATH="$PATH:/sbin" ldconfig -n /opt/tomcat5.5//lib
----------------------------------------------------------------------
Libraries have been installed in: ##通过此信息显然native安装成功
   /opt/tomcat5.5//lib

显然去/opt/tomcat5.5目录下 ,你会发现多了一个lib目录

7:仅仅这样还是不行,还需要如下配置:

文档:

Edit $CATALINA_HOME/bin/setenv.sh (creating the file if necessary) and add the path to the tc-native libraries to LD_LIBRARY_PATH. Something like: 

    LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CATALINA_HOME/lib
    export LD_LIBRARY_PATH

[root@localhost bin]# pwd
/opt/apache-tomcat-5.5.26/bin
[root@localhost bin]# cat setenv.sh  ##文件内容
LD_LIBRARY_PATH=:/opt/tomcat5.5/lib
export LD_LIBRARY_PATH
8:测试native是否已经生效,如果不进行配置,甚至不安装native,则监控catalina.out时会有如下的输出:
[root@localhost logs]# cat catalina.out
Jun 11, 2010 10:32:44 AM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/local/jdk1.5.0_19/jre/lib/i386/client:/usr/local/jdk1.5.0_19/jre/lib/i386:/usr/local/jdk1.5.0_19/jre/../lib/i386
Jun 11, 2010 10:32:44 AM org.apache.coyote.http11.Http11BaseProtocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Jun 11, 2010 10:32:44 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1994 ms
Jun 11, 2010 10:32:45 AM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Jun 11, 2010 10:32:45 AM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/5.5.26
Jun 11, 2010 10:32:45 AM org.apache.catalina.core.StandardHost start
INFO: XML validation disabled
Jun 11, 2010 10:32:47 AM org.apache.coyote.http11.Http11BaseProtocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Jun 11, 2010 10:32:48 AM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Jun 11, 2010 10:32:48 AM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/36  config=null
Jun 11, 2010 10:32:48 AM org.apache.catalina.storeconfig.StoreLoader load
INFO: Find registry server-registry.xml at classpath resource
Jun 11, 2010 10:32:48 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 3366 ms
安装配置成功后,再次监控日志信息(tail -f catalina.out)查看或先将原来的文件内容清空,然后启动tomat,待启动完成后查看文件内容:
[root@localhost logs]# cat catalina.out
Jun 11, 2010 10:39:15 AM org.apache.coyote.http11.Http11BaseProtocol pause
INFO: Pausing Coyote HTTP/1.1 on http-8080
Jun 11, 2010 10:39:16 AM org.apache.catalina.core.StandardService stop
INFO: Stopping service Catalina
Jun 11, 2010 10:39:16 AM org.apache.coyote.http11.Http11BaseProtocol destroy
INFO: Stopping Coyote HTTP/1.1 on http-8080
Jun 11, 2010 10:39:16 AM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: Failed shutdown of Apache Portable Runtime
Jun 11, 2010 10:39:35 AM org.apache.coyote.http11.Http11AprProtocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Jun 11, 2010 10:39:35 AM org.apache.coyote.ajp.AjpAprProtocol init
INFO: Initializing Coyote AJP/1.3 on ajp-8009
Jun 11, 2010 10:39:35 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1091 ms
Jun 11, 2010 10:39:35 AM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Jun 11, 2010 10:39:35 AM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/5.5.26
Jun 11, 2010 10:39:35 AM org.apache.catalina.core.StandardHost start
INFO: XML validation disabled
Jun 11, 2010 10:39:37 AM org.apache.coyote.http11.Http11AprProtocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Jun 11, 2010 10:39:37 AM org.apache.coyote.ajp.AjpAprProtocol start
INFO: Starting Coyote AJP/1.3 on ajp-8009
Jun 11, 2010 10:39:37 AM org.apache.catalina.storeconfig.StoreLoader load
INFO: Find registry server-registry.xml at classpath resource
Jun 11, 2010 10:39:37 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 1822 ms
发现已经没有了上面日志中红色字体部分
显然native已经生效
阅读(1965) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~