Tomcat的三种运行模式

tomcat的运行模式有3种.修改他们的运行模式.3种模式的运行是否成功,可以看他的启动控制台,或者启动日志.或者登录他们的默认页面http://localhost:8080/查看其中的服务器状态。

1)bio

默认的模式,性能非常低下,没有经过任何优化处理和支持.

2)nio

利用java的异步io护理技术,noblocking IO技术.

想运行在该模式下,直接修改server.xml里的Connector节点,修改protocol为

<Connector port="80" protocol="org.apache.coyote.http11.Http11NioProtocol"          connectionTimeout="20000"          URIEncoding="UTF-8"          useBodyEncodingForURI="true"          enableLookups="false"          redirectPort="8443" />
启动后,就可以生效。

3)apr

安装起来最困难,但是从操作系统级别来解决异步的IO问题,大幅度的提高性能.

必须要安装apr和native,直接启动就支持apr。下面的修改纯属多余,仅供大家扩充知识,但仍然需要安装apr和native

如nio修改模式,修改protocol为org.apache.coyote.http11.Http11AprProtocol

安装APR

APR项目有APR,APR-util和APR-iconv,其中APR-iconv是可选安装的。

下载最新的APR和APR-util源码包

2.1安装APR

1)解压apr-1.4.6:tar -zxf apr-1.4.6

2) cd apr-1.4.6

3)依次执行./configure

make  

sudo make install

在apr被安装到了/usr/local/apr目录下面



2.2 安装APR-util

1) 解压apr-util-1.4.1:tar -zxfapr-util-1.4.1

2) cd apr-util-1.4.1

3) 依次执行./configure--with-apr=/usr/local/apr/bin/apr-1-config  (如果不加后面的可能会报APR找不到的错误"checkingfor APR... no
    configure: error: APR could not be located. Please use the--with-apr option."

make

sudo make install

apr-util也被安装找/usr/local/apr下面



2.3进入tomcat主目录下,在bin/tomcat-native-1.1.23-src/jni/native下面依次执行:

./configure--with-apr=/usr/local/apr/bin/apr-1-config  (如果不加后面的可能会报APR找不到的错误"checkingfor APR... no
    configure: error: APR could not be located. Please use the--with-apr option."

make

sudo make install



2.4. 设置启动参数:

在catalina.sh 加入启动参数:

CATALINA_OPTS="$CATALINA_OPTS-Djava.library.path=/usr/local/apr/lib"



根据以上步骤安装

报错:2013-1-1516:43:48 org.apache.catalina.core.AprLifecycleListener init

An incompatibleversion 1.1.0 of the APR based Apache Tomcat Nativelibrary is installed, while Tomcat requires version 1.1.24

出现这个错误一般应该是/etc/profile里面设置没生效,加在catalina.sh中即可,只要你装的版本不低,就不要试图重装其他啥的,那些只会浪费时间精力

猜你喜欢

转载自Field-notes.iteye.com/blog/2076978