tomcatjavascript
./configure --prefix=/usr/local/aprjava
make && make installlinux
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/aprweb
make && make installapache
./configure --prefix=/data/apache --enable-rewrite --enable-so --with-apr=/data/app/apr --with-apr-util=/data/app/apr-util --with-pcre=/data/app/pcrevim
make && make installtomcat
./configure --prefix=/usr/local/pcresession
make && make installapp
tar -zxvf tomcat-connectors-1.2.32-src.tar.gzdom
cd tomcat-connectors-1.2.32-src/native
./buildconf.sh
./configure --with-apxs=/usr/local/apache2/bin/apxs --with-java-home=$JAVA_HOME --with-java-platform=2 --enable-jni
make && make install
若是成功结束,你能够在/usr/local/apache/modules/下找到mod_jk.so文件。
tar zxvf 包
vim conf/httpd.conf
LoadModule jk_module modules/mod_jk-1.2.26-httpd-2.2.4.so //表示载入JK模块
JkWorkersFile conf/workers.properties //tomcat实例配置
JkMount /* controller //设置apache分发器,/*表示apache将全部文件都由分发器controller 进行分发,你能够自行设置*.jsp,*.do等
vim conf/ workers.properties
worker.list=controller
#Tomcat1实例配置
worker.tomcat80.host=10.71.144.80
worker.tomcat80.port=8009 //ajp的端口
worker.tomcat80.type=ajp13
# 分发权重 值越大负载越大
worker.tomcat1.lbfactor = 1
#Tomcat2实例配置
worker.tomcat81.host=10.71.144.81
worker.tomcat81.port=8009
worker.tomcat81.type=ajp13
# 分发权重 值越大负载越大
worker.tomcat81.lbfactor = 1
worker.lbcontroller.type=lb
worker.lbcontroller.balance_workers=tomcat80,tomcat81,tomcat82
worker.lbcontroller.sticky_session=True
这里就是tomcat80和tomcat82必须与以后tomcat中的server.xml中jvmRoute值一致
vim conf/server.xml
<Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat35">
……
<Cluster
className="org.apache.catalina.ha.tcp.SimpleTcpCluster"
channelSendOptions="8">
<Manager
className="org.apache.catalina.ha.session.DeltaManager"
expireSessionsOnShutdown="false"
notifyListenersOnReplication="true"/>
<Channel
className="org.apache.catalina.tribes.group.GroupChannel">
<Membership
className="org.apache.catalina.tribes.membership.McastServi
ce"
address="228.0.0.4"
port="45564"
frequency="500"
dropTime="3000"/>
<Receiver
className="org.apache.catalina.tribes.transport.nio.NioRece
iver"
address="auto"
port="4000"
autoBind="100"
selectorTimeout="5000"
maxThreads="6"/>
<Sender
className="org.apache.catalina.tribes.transport.Replication
Transmitter">
<Transport
className="org.apache.catalina.tribes.transport.nio.Poole
dParallelSender"/>
</Sender>
<Interceptor
className="org.apache.catalina.tribes.group.interceptors.Tc
pFailureDetector"/>
<Interceptor
className="org.apache.catalina.tribes.group.interceptors.Me
ssageDispatch15Interceptor"/>
</Channel>
<Valve
className="org.apache.catalina.ha.tcp.ReplicationValve"
filter=""/>
<Valve
className="org.apache.catalina.ha.session.JvmRouteBinderValve
"/>
<Deployer
className="org.apache.catalina.ha.deploy.FarmWarDeployer"
tempDir="/tmp/war-temp/"
deployDir="/tmp/war-deploy/"
watchDir="/tmp/war-listen/"
watchEnabled="false"/>
<ClusterListener
className="org.apache.catalina.ha.session.JvmRouteSessionIDBi
nderListener"/>
<ClusterListener
className="org.apache.catalina.ha.session.ClusterSessionListe
ner"/>
</Cluster>
tomcat集群中的 session管理,主要有两种方式:
1).粘性session
表示从同一窗口发来的请求都将有集群中的同一个tomcat进行处理。配 置方式是在上面workers.properties文件中
worker.lbcontroller.sticky_session=True
粘性session的好处在不会在不一样的tomcat上来回跳动处理请求,可是坏处是若是处理该session的tomcat崩溃,那么以后 的请求将由其余tomcat处理,原有session失效而从新新建一个新的session,这样若是继续从session取值,会抛出 nullpointer的访问异常。
2).session复制
session复制是指tomcat彼此之间经过组播方式将session 发到各个tomcat实例上,若是其中一个访问出错,则另外tomcat仍然具备有效的session内容,从而能正常接管其session。坏处是当 tomcat实例不少,或者用户在session中有大量操做时,组播发送的信息量十分惊人。session复制配置则是在发布的web应用程序中的 web.xml中添加
<distributable/>
此外,session复制所需的JDK必须是JDK 5.0及其以上版本
注:单机部署多个tomcat须要改端口
……/apache/bin/apachectl start
……/apache/bin/apachectl stop 关闭
……/tomcat-xxx/bin/startup.sh
……/tomcat-xxx/bin/shutup.sh 关闭
问题:
configure: error: APR not found. Please read the documentation
解决:
安装apr apr-util
问题:
执行make命令时报错
xml/apr_xml.c:35:19: error: expat.h: No such file or directory
……
make[1]: * [xml/apr_xml.lo] Error 1
make[1]: Leaving directory `/root/Downloads/apache_svn/apr-util-1.6.0'
make: * [all-recursive] Error 1
解决:
yum install expat-devel
问题:
编译APR包的时候,在执行configure可能会出现 rm: cannot remove `libtoolT': No such file or directory
解决:
编辑configure这个文件,将 $RM “$cfgfile” 那行注释掉 ,而后从新编译便可。
问题:
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.58.135. Set the 'ServerName' directive globally to suppress this message
vim .../apache/conf/httpd.conf
#ServerName www.example.com:80
ServerName localhost:80
这个主要是记录tomcat启动时候的信息,相似于咱们在eclipse中启动服务的时候在控制台看到的信息。在里面能够看到启动的JVM参数以及操做系统等日志信息。若是没有使用log4j等日志机制,系统的的错误信息与打印语句也在这个日志文件中记录。(linux下全部的日志都在catalina.out中)
这个日期放的估计是利用服务方式启动tomcat做为守护进程的日志记录,由于个人tomcat启动方式是以服务的方式启动的,索引产生这个日志文件记录了服务的启动状态。
这个估计是放tomcat的自带的manager项目的日志信息的,也没有看到有什么重要的日志信息
这个相似于第一种日志,但是信息没有第一种全
这个是存放访问tomcat的请求的全部地址以及请求的路径、时间,请求协议以及返回码等信息(重要)
这个估计也是manager项目专有的日志文件,看不出有什么重要的信息
这个是log4j的错误日志,所以在程序中要合理的捕捉异常。
相似于eclipse的控制台的信息
这个是程序中的System语句打印的日志(包括系统抛出的异常),也终于明白了为何一再强调不能用打印语句进行系统调试