1. 准备工具

httpd-2.2.25-win32-x86-openssl-0.9.8y.msi

mod_jk-1.2.31-httpd-2.2.3.so

两个tomcat6

2.安装httpd-2.2.25-win32-x86-openssl-0.9.8y.msi(傻瓜式安装)

安装完后修改http.conf

添加

include "D:\WorkTool\apache\setup\conf\mod_jk.conf"

3.在mod_jk.conf配置文件添加

LoadModule jk_module modules/mod_jk-1.2.31-httpd-2.2.3.so

JkWorkersFile conf/workers.properties

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

JkMount /* controller

4.在workers.properties配置文件中添加

#server
worker.list=controller
#worker.list=ajp13
#========tomcat1========

worker.tomcat1.port=11009

worker.tomcat1.host=localhost

worker.tomcat1.type=ajp13

worker.tomcat1.lbfactor = 1

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

worker.tomcat2.port=12009

worker.tomcat2.host=localhost

worker.tomcat2.type=ajp13

worker.tomcat2.lbfactor = 1

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

#worker.tomcat3.port=13009

#worker.tomcat3.host=192.168.0.80 //在我的虚拟机中的,可以算远程的吧

#worker.tomcat3.type=ajp13

#worker.tomcat3.lbfactor = 1

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

worker.controller.type=lb

worker.controller.balanced_workers=tomcat1,tomcat2

worker.controller.sticky_session=false

worker.controller.sticky_session_force=1

#worker.controller.sticky_session=1

4.在自己所在项目中加入web.xml <distribute/>

修改tomcat1

<?xml version='1.0' encoding='utf-8'?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<!-- Note:  A "Server" is not itself a "Container", so you may not
     define subcomponents such as "Valves" at this level.
     Documentation at /docs/config/server.html
 -->
<Server port="8005" shutdown="SHUTDOWN">

<!--APR library loader. Documentation at /docs/apr.html -->
  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
  <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
  <Listener className="org.apache.catalina.core.JasperListener" />
  <!-- Prevent memory leaks due to use of particular java/javax APIs-->
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
  <!-- JMX Support for the Tomcat server. Documentation at /docs/non-existent.html -->
  <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />

<!-- Global JNDI resources
       Documentation at /docs/jndi-resources-howto.html
  -->
  <GlobalNamingResources>
    <!-- Editable user database that can also be used by
         UserDatabaseRealm to authenticate users
    -->
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
              description="User database that can be updated and saved"
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
              pathname="conf/tomcat-users.xml" />
  </GlobalNamingResources>

<!-- A "Service" is a collection of one or more "Connectors" that share
       a single "Container" Note:  A "Service" is not itself a "Container",
       so you may not define subcomponents such as "Valves" at this level.
       Documentation at /docs/config/service.html
   -->
  <Service name="Catalina">
 
    <!--The connectors can use a shared executor, you can define one or more named thread pools-->
    <!--
    <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
        maxThreads="150" minSpareThreads="4"/>
    -->
    
    
    <!-- A "Connector" represents an endpoint by which requests are received
         and responses are returned. Documentation at :
         Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
         Java AJP  Connector: /docs/config/ajp.html
         APR (HTTP/AJP) Connector: /docs/apr.html
         Define a non-SSL HTTP/1.1 Connector on port 8080
    -->
    <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
    <!-- A "Connector" using the shared thread pool-->
    <!--
    <Connector executor="tomcatThreadPool"
               port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
    -->           
    <!-- Define a SSL HTTP/1.1 Connector on port 8443
         This connector uses the JSSE configuration, when using APR, the
         connector should be using the OpenSSL style configuration
         described in the APR documentation -->
    <!--
    <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
               maxThreads="150" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS" />
    -->

<!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="11009" protocol="AJP/1.3" redirectPort="8443" />

<!-- An Engine represents the entry point (within Catalina) that processes
         every request.  The Engine implementation for Tomcat stand alone
         analyzes the HTTP headers included with the request, and passes them
         on to the appropriate Host (virtual host).
         Documentation at /docs/config/engine.html -->

<!-- You should set jvmRoute to support load-balancing via AJP ie :
    <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">         
    -->
    <Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat1">

<!--For clustering, please take a look at documentation at:
          /docs/cluster-howto.html  (simple how to)
          /docs/config/cluster.html (reference documentation) -->
     
      <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
     
      <!-- The request dumper valve dumps useful debugging information about
           the request and response data received and sent by Tomcat.
           Documentation at: /docs/config/valve.html -->
      <!--
      <Valve className="org.apache.catalina.valves.RequestDumperValve"/>
      -->

<!-- This Realm uses the UserDatabase configured in the global JNDI
           resources under the key "UserDatabase".  Any edits
           that are performed against this UserDatabase are immediately
           available for use by the Realm.  -->
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
             resourceName="UserDatabase"/>

<!-- Define the default virtual host
           Note: XML Schema validation will not work with Xerces 2.2.
       -->
      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">

<!-- SingleSignOn valve, share authentication between web applications
             Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
        -->

<!-- Access log processes all example.
             Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"  
               prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>
        -->

</Host>
    </Engine>
  </Service>
</Server>

修改tomcat2

<?xml version='1.0' encoding='utf-8'?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<!-- Note:  A "Server" is not itself a "Container", so you may not
     define subcomponents such as "Valves" at this level.
     Documentation at /docs/config/server.html
 -->
<Server port="8006" shutdown="SHUTDOWN">

<!--APR library loader. Documentation at /docs/apr.html -->
  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
  <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
  <Listener className="org.apache.catalina.core.JasperListener" />
  <!-- Prevent memory leaks due to use of particular java/javax APIs-->
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
  <!-- JMX Support for the Tomcat server. Documentation at /docs/non-existent.html -->
  <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />

<!-- Global JNDI resources
       Documentation at /docs/jndi-resources-howto.html
  -->
  <GlobalNamingResources>
    <!-- Editable user database that can also be used by
         UserDatabaseRealm to authenticate users
    -->
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
              description="User database that can be updated and saved"
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
              pathname="conf/tomcat-users.xml" />
  </GlobalNamingResources>

<!-- A "Service" is a collection of one or more "Connectors" that share
       a single "Container" Note:  A "Service" is not itself a "Container",
       so you may not define subcomponents such as "Valves" at this level.
       Documentation at /docs/config/service.html
   -->
  <Service name="Catalina">
 
    <!--The connectors can use a shared executor, you can define one or more named thread pools-->
    <!--
    <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
        maxThreads="150" minSpareThreads="4"/>
    -->
    
    
    <!-- A "Connector" represents an endpoint by which requests are received
         and responses are returned. Documentation at :
         Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
         Java AJP  Connector: /docs/config/ajp.html
         APR (HTTP/AJP) Connector: /docs/apr.html
         Define a non-SSL HTTP/1.1 Connector on port 8080
    -->
    <Connector port="8081" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
    <!-- A "Connector" using the shared thread pool-->
    <!--
    <Connector executor="tomcatThreadPool"
               port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
    -->           
    <!-- Define a SSL HTTP/1.1 Connector on port 8443
         This connector uses the JSSE configuration, when using APR, the
         connector should be using the OpenSSL style configuration
         described in the APR documentation -->
    <!--
    <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
               maxThreads="150" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS" />
    -->

<!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="12009" protocol="AJP/1.3" redirectPort="8443" />

<!-- An Engine represents the entry point (within Catalina) that processes
         every request.  The Engine implementation for Tomcat stand alone
         analyzes the HTTP headers included with the request, and passes them
         on to the appropriate Host (virtual host).
         Documentation at /docs/config/engine.html -->

<!-- You should set jvmRoute to support load-balancing via AJP ie :
    <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">         
    -->
    <Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat2">

<!--For clustering, please take a look at documentation at:
          /docs/cluster-howto.html  (simple how to)
          /docs/config/cluster.html (reference documentation) -->
     
      <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
     
      <!-- The request dumper valve dumps useful debugging information about
           the request and response data received and sent by Tomcat.
           Documentation at: /docs/config/valve.html -->
      <!--
      <Valve className="org.apache.catalina.valves.RequestDumperValve"/>
      -->

<!-- This Realm uses the UserDatabase configured in the global JNDI
           resources under the key "UserDatabase".  Any edits
           that are performed against this UserDatabase are immediately
           available for use by the Realm.  -->
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
             resourceName="UserDatabase"/>

<!-- Define the default virtual host
           Note: XML Schema validation will not work with Xerces 2.2.
       -->
      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">

<!-- SingleSignOn valve, share authentication between web applications
             Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
        -->

<!-- Access log processes all example.
             Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"  
               prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>
        -->

</Host>
    </Engine>
  </Service>
</Server>

注意点:如果你是初学者,首先要将项目打成war包(具体我就不多说了), 然后将war包放在tomcat中运行,tomcat版本号一定要一致

web.xml千万不要别忘了添加<distribute/>

如果按照上面的步骤操作,实现session共享是没有任何问题的。

linux集群

http://blog.csdn.net/bluishglc/article/details/6867358

//删除

http://jingyan.baidu.com/article/148a1921b803c34d70c3b147.html

//gcc编译器

http://blog.sina.com.cn/s/blog_8653909001013435.html

//

http://jingyan.baidu.com/article/ab0b5630b632dbc15afa7dc4.html

http://blog.sina.com.cn/s/blog_7253980a0101guiz.html

http://blog.chinaunix.net/uid-26881541-id-3338854.html

tomcat集群(小型项目)相关推荐

  1. 50 Tomcat 集群部署

    文章目录 1.JVM基本介绍 2.Tomcat是什么,与Nginx的区别. 3.Tomcat安装.配置.启动 4.Tomcat的HTTP请求过程 4.使用tomcat部署web服务 5.使用tomca ...

  2. dwr消息推送和tomcat集群

    网友的提问: 项目中用到了dwr消息推送.而服务端是通过一个http请求后 触发dwr中的推送方法.而单个tomcat中.服务器发送的http请求和用户都在一个tomcat服务器中.这样就能精准推送到 ...

  3. tomcat7+nginx+memcached 配置tomcat 集群以及负载均衡

    首先:配置tomcat集群 nginx+ tomcat7 1 安装jdk (可以选择6或者7都可以) 此处不用多说. 2 下载nginx-1.2.5 (下载附件) 3 下载 memcached(下载附 ...

  4. Tomcat集群快速入门:Nginx+Tomcat搭建集群

    参数的一些扩展点,那刚刚讲的一些负载均衡策略,都是实际企业当中常用的,负载均衡策略,领着大家分析了优缺点,希望大家好好体会,百分之一百的吸收,那我们现在把这些参数和扩展的点呢,放到一个配置里,一起来给 ...

  5. Tomcat集群快速入门:Nginx负载均衡配置,常用策略,场景及特点

    Nginx负载均衡的配置,常用策略,场景,以及特点,放到这里是需要更细化的讲解,毕竟一期还没有做集群,而我们这一期做集群的时候,很多点要单独拿出来深入讲解,第一个轮询,默认的一个配置,简单也好理解,第 ...

  6. Tomcat集群快速入门2

    首先讲一下mac和linux下,tomcat单击部署多应用,就是一台服务器部署多个应用,首先修改etc/profile,也就是说,我们这个系统的环境变量,我们增加6个环境变量,我们先看前三个,右边的t ...

  7. Tomcat集群快速入门

    这一节我们学习tomcat集群,这一节非常重要,请大家仔细认真学习,首先我们看一下目录,会领着大家一起回顾一下,第一期的tomcat配置,然后是mac和linux下的,还有一个windows下的,然后 ...

  8. kubernetes入门到精通(二):k8s部署Tomcat集群,基于NTFS协议的文件集群共享,Service提供负载均衡,端口转发工具Rinetd配置外部访问

    首先,配置 Docker 镜像加速服务 登录阿里云账号,进入控制台 -> 容器镜像服务 (不需要有阿里云的服务器,只要注册账号即可) 在两台 node 节点上配置好阿里云的镜像加速. 重启一下 ...

  9. Nginx SSL+tomcat集群配置SSL,ngnix配置SSL后js/css访问出现404

    最近在做一个项目, 架构上使用了 Nginx +tomcat 集群, 且nginx下配置了SSL,tomcat no SSL,项目使用https协议 但是,明明是https url请求,发现 log里 ...

  10. Nginx+Tomcat+Memcached实现tomcat集群和session共享

    Nginx+Tomcat+Memcached实现tomcat集群和session共享 [http://blog.csdn.net/shimiso/article/details/8979044] 为什 ...

最新文章

  1. 数学之美 系列八-- 贾里尼克的故事和现代语言处理
  2. 【学习笔记】Redis的geohash数据结构介绍
  3. 一文理解Netty模型架构
  4. hashmap java_Java – HashMap详细说明
  5. 药盒识别/垃圾分类—高精度AI模型训练及边缘部署分享
  6. 分布式选举协议:Bully
  7. 嵌入式Linux系统编程学习之十二守护进程
  8. python打印字符串的前五行_python基础-字符串(6)
  9. 4核a5中断linux,Cortex A5 MPcore寄存器TPIDRPRW复位值不为零,造成Linux Kernel不能启动的问题...
  10. 农田生产潜力数据集、耕地分布矢量数据、土地利用数据、作物分布数据、林地分布数据、绿地分布
  11. 【codevs2333】【BZOJ2002】弹飞绵羊[HNOI2010](分块)
  12. 使用JS读取本地文件
  13. 云服务器显示502错误,云服务器出现502错误怎么办
  14. 苹果手机网页选择框 下拉框点击放大处理
  15. UBUNTU 7.04安装后的配置
  16. Strong-Convexity:强凸性
  17. SDI相机实时采集处理DSP系统 目标跟踪
  18. 回首过去展望未来——14年年终总结
  19. win10下装黑苹果双系统_笔记本加装固态打造黑苹果+WIN双系统,雷克沙NS100升级体验...
  20. GOOGLE 人机验证(RECAPTCHA)无法显示解决方案(可解决大多数 CSP 问题)

热门文章

  1. jQuery练习_狂拍灰太狼
  2. QQ表情发送失败的原因
  3. Foxit PDF SDK for iOS--零基础Cordova开发
  4. 电脑安装Chrome OS
  5. 【事件相机整理】信号处理、噪声与滤波
  6. EDEM颗粒堆积fluent meshing网格生成
  7. plc c语言模拟仿真软件下载,s7-plcsim仿真编程-s7-plcsim最新版下载V5.4-西西软件下载...
  8. 隐马尔可夫模型HMM (机器学习模型)
  9. 如何按关键字搜索商品详情
  10. DHTMLX Suite 7.1.10 Crack