terracotta是一家美国公司做的集群框架。是分布式缓存线性扩展平台。它巧妙得隐藏了多个分布式JVM带来的复杂性,使得java对象能够透明得在多个JVM集群中进行分享和同步,并能够进行持久化。
terracotta是怎么样的框架这里不多做叙述。大家可以百度了解。
下面开始集群的配置。
需要用到的软件如,terracotta3.7.7,apche2.2X(32),tomcat6(32).环境windows7
先配置apche跟tomcat集群。
首先下载好apche2.2X(32)。按流程装好apche
然后下载tomcat6(免安装).
下载负载均衡插件tomcat-connectors-1.2.40-windows-i386-httpd-2.0.x 注意tomcat 版本和apache版本
下载好后解压tomcat-connectors-1.2.40-windows-i386-httpd-2.0.x 将里面的mod_jk.so 放到apached的modules下面。
之后新建mod_jk.conf
内容如下:
LoadModule jk_module "D:/Program Files (x86)/Apache Group/Apache2.2/modules/mod_jk.so"  
JkWorkersFile "conf/workers.properties"  
JkMount /*.jsp controller  
JkMount /*.do controller
然后将mod_jk.conf文件复制到apche conf文件夹下面
之后新建workers.properties文件
内容如下
    #server  
    worker.list = controller  
    #========tomcat1========  
    worker.tomcat1.port=7010  
    worker.tomcat1.host=localhost  
    worker.tomcat1.type=ajp13  
    worker.tomcat1.lbfactor = 1  
    #========tomcat2========  
    worker.tomcat2.port=7011  
    worker.tomcat2.host=localhost  
    worker.tomcat2.type=ajp13  
    worker.tomcat2.lbfactor = 1  
    #========controller,负载均衡控制器========  
    worker.controller.type=lb  
    worker.controller.balanced_workers=tomcat1,tomcat2  
    worker.controller.sticky_session=true
    #worker.controller.sticky_session_force=1  
    #worker.controller.sticky_session=1
然后也将此文件复制到apche conf文件夹下面。
在apche conf文件夹下面找到httpd.conf
在最下面加上这句include "D:\Program Files (x86)\Apache Group\Apache2.2\conf\mod_jk.conf"
apche 配置基本完成
tomcat主要是配置conf下面的service文件修改端口等。如ajp访问协议主要是联通apche跟tomcat的。
修改service文件如下
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="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" />  
      
        
      <GlobalNamingResources>  
        
        <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>  
      
      
      <Service name="Catalina">  
        
         
        <Connector port="8081" protocol="HTTP/1.1"   
                   connectionTimeout="20000"   
                   redirectPort="8445" />  
          
               
        
        <Connector port="7010" protocol="AJP/1.3" redirectPort="8445" />  
      
      
         
      
          
        <Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat1">  
      
          
                  
     <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>  
          
          
      
          <!-- 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"/>  
      
          
          <Host name="localhost"  appBase="webapps"  
                unpackWARs="true" autoDeploy="true"  
                xmlValidation="false" xmlNamespaceAware="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" />  
      
        
      <GlobalNamingResources>  
        
        <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>  
      
      
      <Service name="Catalina">  
        
         
        <Connector port="8081" protocol="HTTP/1.1"   
                   connectionTimeout="20000"   
                   redirectPort="8445" />  
          
               
        
        <Connector port="8010" protocol="AJP/1.3" redirectPort="8445" />  
      
      
         
      
          
        <Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat1">  
      
          
                  
     <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>  
          
          
      
          <!-- 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"/>  
      
          
          <Host name="localhost"  appBase="webapps"  
                unpackWARs="true" autoDeploy="true"  
                xmlValidation="false" xmlNamespaceAware="false">  
      
              
             
           
      
          </Host>  
        </Engine>  
      </Service>  
    </Server>

tomcat2

<?xml version='1.0' encoding='utf-8'?>  
      
      
    <Server port="8007" 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" />  
      
      
      <GlobalNamingResources>  
        
        <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>  
      
        
      <Service name="Catalina">  
        
          
          
      
        <Connector port="8083" protocol="HTTP/1.1"   
                   connectionTimeout="20000"   
                   redirectPort="8446" />  
         
                 
        
         
      
         
        <Connector port="7011" protocol="AJP/1.3" redirectPort="8446" />  
      
      
        
      
        
        <Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat2">  
      
            
         <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>  
      
          
      
          <Realm className="org.apache.catalina.realm.UserDatabaseRealm"  
                 resourceName="UserDatabase"/>  
      
           
          <Host name="localhost"  appBase="webapps"  
                unpackWARs="true" autoDeploy="true"  
                xmlValidation="false" xmlNamespaceAware="false">  
      
           
      
      
          </Host>  
        </Engine>  
      </Service>  
    </Server>  
自此集群已经配置好。
现在开始配置terracotta
首先配置tc-config文件
内容如下
    <?xml version="1.0" encoding="UTF-8" ?>  
    <tc:tc-config xmlns:tc="http://www.terracotta.org/config"  
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
      xsi:schemaLocation="http://www.terracotta.org/schema/terracotta-6.xsd">  
      
      <tc-properties>  
        <property name="l2.nha.dirtydb.autoDelete" value="true"/>  
        <property name="l1.cachemanager.enabled" value="true"/>  
        <property name="logging.maxLogFileSize" value="1024"/>  
      </tc-properties>  
        
      
      <system>  
        <configuration-model>development</configuration-model>  
      </system>  
      
      
      <servers>  
      
        <server host="127.0.0.1" name="localhost" bind="0.0.0.0">  
      
      
      
          
          <statistics>/opt/terracotta/server-statistics</statistics>   
          <dso-port bind="127.0.0.1">9510</dso-port>  
          <jmx-port bind="127.0.0.1">9520</jmx-port>  
          <l2-group-port bind="127.0.0.1">9530</l2-group-port>  
          <authentication/>  
      
         
          <dso>  
      
           
            <client-reconnect-window>120</client-reconnect-window>  
      
           
            <persistence>  
              
              <mode>temporary-swap-only</mode>  
            </persistence>  
      
            
            <garbage-collection>  
      
              <enabled>true</enabled>  
      
              <verbose>false</verbose>  
      
              <interval>3600</interval>  
            </garbage-collection>  
      
          </dso>  
        </server>  
         
        <mirror-groups>  
           
          <mirror-group group-name="group1">  
            <members>  
              <member>localhost</member>  
            </members>  
             
            <ha>  
              <mode>networked-active-passive</mode>  
              <networked-active-passive>  
                <election-time>5</election-time>  
              </networked-active-passive>  
            </ha>  
           </mirror-group>  
        </mirror-groups>       
        <ha>  
          <mode>networked-active-passive</mode>  
          <networked-active-passive>  
            <election-time>5</election-time>  
          </networked-active-passive>  
        </ha>  
        <update-check>  
          <enabled>true</enabled>  
          <period-days>10</period-days>  
        </update-check>  
      </servers>  
      <clients>  
        <logs>logs-%i</logs>  
      </clients>  
      
    </tc:tc-config>
然后在terracotta解压下的bin文件下面把tc-config.xml复制过来。
然后将terracotta session文件夹下面 terracotta-session-1.3.7跟common下面的
terracotta-toolkit-1.6-runtime-5.7.0复制到tomcat, lib下面。
然后cmd 命令窗口cd到terracotta3.7.7-bin下执行tim-get.bat tc-config.xml
之后执行start-tc-server.bat
会看到如下
 
然后在需要应用的tomcat的应用下面的META-INF 新建context.xml 并将一下内容复制进去
<?xml version="1.0" encoding="UTF-8"?>
<Context>
    <Valve className="org.terracotta.session.TerracottaTomcat60xSessionValve" tcConfigUrl="127.0.0.1:9510" />
</Context>

之后分别启动两个tomcat,apche

测试页面见附件
有一点要提醒的是请注意jdk跟tomcat版本对应。
本文过程经过实践。也参考了csdn的其他博友的文章。
参考过如博友飞*天的文章。

terracotta3.7.7+apche2.2+tomcat6集群配置相关推荐

  1. 基于redis的cas集群配置(转)

    1.cas ticket统一存储 做cas集群首先需要将ticket拿出来,做统一存储,以便每个节点访问到的数据一致.官方提供基于memcached的方案,由于项目需要,需要做计入redis,根据官方 ...

  2. windows apache 负载均衡配置 Tomcat集群配置

    2019独角兽企业重金招聘Python工程师标准>>> 1.安装 exe可执行文件的安装方式:http://jingyan.baidu.com/article/ed15cb1b73b ...

  3. Hadoop集群配置(最全面总结)

    Hadoop集群配置(最全面总结) 通常,集群里的一台机器被指定为 NameNode,另一台不同的机器被指定为JobTracker.这些机器是masters.余下的机器即作为DataNode也作为Ta ...

  4. redis+主从复制+集群配置

    redis+主从复制+集群配置 redis是一个key-value存储系统.和memcached类似,不过redis支持的value类型更多,主要有:string(字符串).list(链表).set( ...

  5. JavaEE进阶知识学习-----SpringCloud(四)Eureka集群配置

    Eureka集群配置 microservicecloud-eureka-7001使EurekaServer服务注册中心,一旦这个出现问题,那么微服务就不能正常的工作,为防止这种情况,所以出现了集群,就 ...

  6. FastDFS 集群配置(转载)

    本文转载自::https://blog.csdn.net/xiaoweiqb/article/details/68065618 配置最终目标 以4台服务做集群,其中2台作为tracker服务器又作为s ...

  7. Redis高可用之集群配置(六)

    0.Redis目录结构 1)Redis介绍及部署在CentOS7上(一) 2)Redis指令与数据结构(二) 3)Redis客户端连接以及持久化数据(三) 4)Redis高可用之主从复制实践(四) 5 ...

  8. Redis集群配置和常见异常解决

    Redis集群配置和常见异常解决 参考文章: (1)Redis集群配置和常见异常解决 (2)https://www.cnblogs.com/hzb462606/p/11121281.html 备忘一下 ...

  9. Nginx+Tomcat简单集群配置

    2019独角兽企业重金招聘Python工程师标准>>> 1.软件准备 下载Nginx和Tomcat Nginx:http://nginx.org/en/download.html 这 ...

最新文章

  1. 社会学专业喜欢计算机怎么办,考研困惑我是计算机专业的学生可是我喜欢文学想考河北师范大学的研究 爱问知识人...
  2. 计算机职称在线考试报名系统,计算机职称考试报名时间及入口2021年9月
  3. 秘境探索之一个.NET 对象从内存分配到内存回收
  4. 项目管理(1):管理过程
  5. python描述器 有限状态机_笨办法学 Python · 续 练习 30:有限状态机
  6. 都有什么行业是“三年不开张,开张吃三年”?或是稳赚不赔的暴利行业?
  7. 大数据安全的需求有哪些
  8. java.io.StreamCorruptedException: invalid stream header: 20200909
  9. 优学院java架构52破解_2021年优学院Java程序设计(山西工程职业学院)课后习题答案...
  10. 幂级数 | 函数项级数、函数展开成幂级数(泰勒展开+麦克劳林展开)
  11. EXCEL插件《二维码标签工具》
  12. Steam如何打开控制台
  13. 女版乔布斯的覆灭,这是今年我听过最唏嘘的真人故事
  14. mysql计算月初日期_mysql 获取上月、本月月初月末
  15. html里如何打出五角星,html5中怎么做五角星
  16. 随机Tiled Map的生成
  17. 2018年世界杯冠军竟然被大数据算出来了,还要比吗?
  18. [案例4-4]学生和老师
  19. 自定义Drawable实现灵动的红鲤鱼动画(上篇)
  20. 数据结构(王道版本,主讲人:闲鱼学长)P7-P18

热门文章

  1. SRLTE跟CSFB语音方案流程上差异
  2. 【IIS】无法识别的属性“targetFramework”。请注意属性名称区分大小写。
  3. 川大研究生计算机专业有哪些,问问川大计算机研究生招收的小专业有哪些
  4. [附源码]JAVA+ssm计算机毕业设计高校教材征订管理系统(程序+Lw)
  5. 学习烂到留级,却凭着正经发表的第一篇论文,优雅斩获诺贝尔奖
  6. csu 1092 - 大尾巴狼
  7. 如何哄骗文艺青年安装Node.js? 将网易云音乐灰色歌曲变亮
  8. 2022年6月17日STM32——LCD液晶显示
  9. 阶跃函数、斜坡函数、抛物线函数、脉冲函数
  10. 计算机毕业设计Python+Django的B2C线上电子商品购物商城网站