`

Apache+Tomcat集群

 
阅读更多

 

 

准备环境 

 

下载 

 

Apache HTTP Server http://labs.mop.com/apache-mirror/httpd/binaries/win32/ 下载httpd-2.2.22-win32-x86-no_ssl.msi

 

 

 

JK http://www.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/windows/ 下载tomcat-connectors-1.2.37-windows-i386-httpd-2.2.x.zip

 

 

 

Tomcat http://tomcat.apache.org/download-70.cgi

 

 

 

安装

安装Apache HTTP Server,如果没有其他的http服务器(如iis)则应该可以成功安装,端口即为80,能够访问http://localhost/ 说明安装成功。

 

 

 

安装Tomcat7,下载tomcat7解压缩为4个tomcat文件,分别命名tomcat1、tomcat2、tomcat3、tomcat4.

 

tomcat6.X与tomcat7.X集群通用。

 

配置

 

Apache配置

1、修改httpd.conf

在Apache安装目录下找到conf目录下的httpd.conf,在文件的最后一行添加

include conf/mod_jk.conf

 

2、新建mod_jk.conf文件,内容如下:

 

LoadModule jk_module modules/mod_jk.so

JkWorkersFile conf/workers.properties

#指定那些请求交给tomcat处理,"controller"为在workers.propertise里指定的负载分配控制器名

JkMount /* controller

 

3、将下载的JK插件解压拷贝mod_jk.so,复制到Apache安装目录的modules目录下。

 

4、在apache的安装目录conf下新建并编辑workers.properties文件,内容如下:

 

#server

worker.list = controller

 

#========tomcat1========

worker.tomcat1.port=8719

worker.tomcat1.host=localhost

worker.tomcat1.type=ajp13

worker.tomcat1.lbfactor = 1

worker.tomcat1.redirect=tomcat2

 

#========tomcat2========

worker.tomcat2.port=8729

worker.tomcat2.host=localhost

worker.tomcat2.type=ajp13

worker.tomcat2.lbfactor = 1

worker.tomcat2.redirect=tomcat1

#worker.tomcat2.activation=disabled

 

#========tomcat3========

worker.tomcat3.port=8739

worker.tomcat3.host=localhost

worker.tomcat3.type=ajp13

worker.tomcat3.lbfactor = 1

worker.tomcat3.redirect=tomcat4

 

#========tomcat4========

worker.tomcat4.port=8749

worker.tomcat4.host=localhost

worker.tomcat4.type=ajp13

worker.tomcat4.lbfactor = 1

worker.tomcat4.redirect=tomcat3

#worker.tomcat4.activation=disabled  

 

#========controller,负载均衡控制器========

worker.controller.type=lb

worker.controller.balanced_workers=tomcat1,tomcat2,tomcat3,tomcat4

worker.controller.sticky_session=false

#worker.controller.sticky_session_force=1

#worker.controller.sticky_session=1

 

 

 

 

 

PS:#worker.tomcat4.activation=disabled  表示tomcat是否激活

 

tomcat配置

Tomcat1中server.xml配置:

<Connector port="8781" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />

<Connector port="8719" protocol="AJP/1.3" redirectPort="8443" />

<Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat1">

<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.McastService"  

                         address="228.0.0.4"  

                        port="45564"  

                        frequency="500"  

                        dropTime="3000"/>   

            <Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"  

                        address="auto"

                      port="4001"  

                      autoBind="100"  

                      selectorTimeout="5000"  

                      maxThreads="6"/>   

            <!-- timeout="60000"-->   

            <Sender className="org.apache.catalina.tribes.transport.ReplicationTransmitter">   

              <Transport className="org.apache.catalina.tribes.transport.nio.PooledParallelSender" />   

            </Sender>   

            <Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/>   

            <Interceptor className="org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor"/>   

            <Interceptor className="org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor"/>   

          </Channel>   

  

          <Valve className="org.apache.catalina.ha.tcp.ReplicationValve" filter=""/>   

          <Valve className="org.apache.catalina.ha.session.JvmRouteBinderValve"/>   

  

          <ClusterListener className="org.apache.catalina.ha.session.JvmRouteSessionIDBinderListener"/>   

          <ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>   

        </Cluster>

 

....

 

 <Host name="localhost"  appBase="C:\tomcat7-ex\webapps"

            unpackWARs="true" autoDeploy="true">

 

 

Tomcat2中server.xml配置:

<Connector port="8782" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />

<Connector port="8729" protocol="AJP/1.3" redirectPort="8443" />

<Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat2">

<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.McastService"  

                         address="228.0.0.4"  

                        port="45564"  

                        frequency="500"  

                        dropTime="3000"/>   

            <Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"  

                        address="auto"

                      port="4001"  

                      autoBind="100"  

                      selectorTimeout="5000"  

                      maxThreads="6"/>   

            <!-- timeout="60000"-->   

            <Sender className="org.apache.catalina.tribes.transport.ReplicationTransmitter">   

              <Transport className="org.apache.catalina.tribes.transport.nio.PooledParallelSender" />   

            </Sender>   

            <Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/>   

            <Interceptor className="org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor"/>   

            <Interceptor className="org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor"/>   

          </Channel>   

  

          <Valve className="org.apache.catalina.ha.tcp.ReplicationValve" filter=""/>   

          <Valve className="org.apache.catalina.ha.session.JvmRouteBinderValve"/>   

  

          <ClusterListener className="org.apache.catalina.ha.session.JvmRouteSessionIDBinderListener"/>   

          <ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>   

        </Cluster>

 

....

 

 <Host name="localhost"  appBase="C:\tomcat7-ex\webapps"

            unpackWARs="true" autoDeploy="true">

Tomcat3中server.xml配置:

<Connector port="8783" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />

<Connector port="8739" protocol="AJP/1.3" redirectPort="8443" />

<Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat3">

<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.McastService"  

                         address="228.0.0.5"  

                        port="45564"  

                        frequency="500"  

                        dropTime="3000"/>   

            <Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"  

                        address="auto"

                      port="4001"  

                      autoBind="100"  

                      selectorTimeout="5000"  

                      maxThreads="6"/>   

            <!-- timeout="60000"-->   

            <Sender className="org.apache.catalina.tribes.transport.ReplicationTransmitter">   

              <Transport className="org.apache.catalina.tribes.transport.nio.PooledParallelSender" />   

            </Sender>   

            <Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/>   

            <Interceptor className="org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor"/>   

            <Interceptor className="org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor"/>   

          </Channel>   

  

          <Valve className="org.apache.catalina.ha.tcp.ReplicationValve" filter=""/>   

          <Valve className="org.apache.catalina.ha.session.JvmRouteBinderValve"/>   

  

          <ClusterListener className="org.apache.catalina.ha.session.JvmRouteSessionIDBinderListener"/>   

          <ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>   

        </Cluster>

 

...

 

 <Host name="localhost"  appBase="C:\tomcat7-ex\webapps"

            unpackWARs="true" autoDeploy="true">

 

Tomcat4中server.xml配置:

<Connector port="8784" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />

<Connector port="8749" protocol="AJP/1.3" redirectPort="8443" />

<Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat4">

<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.McastService"  

                         address="228.0.0.5"  

                        port="45564"  

                        frequency="500"  

                        dropTime="3000"/>   

            <Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"  

                        address="auto"

                      port="4001"  

                      autoBind="100"  

                      selectorTimeout="5000"  

                      maxThreads="6"/>   

            <!-- timeout="60000"-->   

            <Sender className="org.apache.catalina.tribes.transport.ReplicationTransmitter">   

              <Transport className="org.apache.catalina.tribes.transport.nio.PooledParallelSender" />   

            </Sender>   

            <Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/>   

            <Interceptor className="org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor"/>   

            <Interceptor className="org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor"/>   

          </Channel>   

  

          <Valve className="org.apache.catalina.ha.tcp.ReplicationValve" filter=""/>   

          <Valve className="org.apache.catalina.ha.session.JvmRouteBinderValve"/>   

  

          <ClusterListener className="org.apache.catalina.ha.session.JvmRouteSessionIDBinderListener"/>   

          <ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>   

        </Cluster>

 

...

 

     <Host name="localhost"  appBase="C:\tomcat7-ex\webapps"

            unpackWARs="true" autoDeploy="true">

注意AJP13的connector的poat和jvmRoute名称和workers.properties中配置对应。228.0.0.4和228.0.0.5表示tomcat的群组

 

基于windows环境搭建完毕,参考文档如下

1、Apache+Tomcat集群配置 http://charyle.iteye.com/blog/1017961

2、对tomcat cluster集群配置中session复制用法的一个误解 http://618119.com/archives/2007/11/13/26.html

 

分享到:
评论

相关推荐

    apache+tomcat集群配置

    Apache + Tomcat 集群配置 Apache + Tomcat 集群配置是指将 Apache 服务器与 Tomcat 服务器集成,以提高服务器的性能和可扩展性。本文将详细介绍如何配置 Apache + Tomcat 集群,包括安装 Apache 和 Tomcat 服务器...

    反向代理负载均衡 Apache + Tomcat集群

    反向代理负载均衡 Apache + Tomcat集群 多的我也不多说了 看文档

    apache+tomcat集群

    apache+tomcat集群 配置使用方法

    Apache+Tomcat集群配置

    Apache+Tomcat集群配置,Apache+Tomcat集群配置,Apache+Tomcat集群配置

    apache+tomcat集群文档

    - 本文档针对Apache Tomcat集群配置进行了详尽的说明,特别适合新手入门学习,通过本文档能够快速掌握Apache Tomcat集群的基本概念、搭建步骤及注意事项。 #### 知识点详解: ##### 一、集群基础知识 1. **学习...

    Apache+Tomcat服务器集群配置详细步骤

    本文将详细介绍如何在一机双Tomcat环境下搭建Apache+Tomcat集群,并深入解析其中的关键配置和技术细节。 #### 二、Apache+Tomcat集群的优势 1. **高可靠性(HA)**:通过集群管理软件实现在主服务器发生故障时,备份...

    Apache+Tomcat集群和负载均衡及Session绑定

    【Apache+Tomcat 集群与负载均衡及Session...通过以上配置,Apache+Tomcat集群可以实现高效的负载均衡和高可用性,同时通过Session绑定确保用户会话的连续性。注意定期监控和优化集群性能,以应对不断变化的业务需求。

    apache+tomcat集群技术总结

    4. **本地配置Apache + Tomcat集群** - **环境说明**:在这个例子中,我们有一个Apache服务器和两个Tomcat实例,以及mod_jk模块用于两者之间的通信。 - **安装与配置**: - 安装Apache和Tomcat,确保版本匹配。 ...

    Apache+Tomcat集群配置续

    Apache+Tomcat集群配置续Apache+Tomcat集群配置续Apache+Tomcat集群配置续Apache+Tomcat集群配置续

    apache+tomcat集群配置文件和文档

    这份"apache+tomcat集群配置文件和文档"将涵盖以上所有要点,指导你逐步配置和测试Apache+Tomcat集群。按照文档操作,你将能够构建出一个高效且稳定的Web服务环境。在实际操作中,务必根据你的硬件资源和具体需求...

Global site tag (gtag.js) - Google Analytics