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. scrapy---Logging
  2. 51汇编与c语言混合编程,C51与汇编混合编程详解
  3. blend 自定义控件
  4. excel表格打开是乱码怎么办?
  5. directadmin php-fpm,centos7.5最新内核安装DirectAdmin面板
  6. More Effective C++之 Item M6:自增(increment)、自减(decrement)操作符前缀形式与后缀形式的区别
  7. poi读取doc文档
  8. 【数据结构】链表 - Go 语言实现
  9. np.random.normal()的含义及实例
  10. Windows下mysql的下载和安装
  11. 在Python中使用Turtle库画“蜂窝状六边形”
  12. Hadoop Shell命令-hdfs常用命令
  13. window10下Oracle 12c详细安装教程
  14. 毕业设计ppt模板内容应该写什么
  15. python-使用电脑摄像头扫码
  16. javascript实现俄罗斯方块
  17. CTraceRoute封装跟踪路由功能
  18. 容智信息受邀参加中国铁塔新产品发布会,共筑AI算法管理平台
  19. 政府大数据之资源目录管理
  20. Flutter用思源宋体炫出你的UI

热门文章

  1. docker build命令详解
  2. Vue3+TS错误解决 Failed to fetch dynamically imported module:
  3. Liveness probe failed: OCI runtime exec failed: exec failed: container_linux.go:345:starting
  4. 小孩子学python有什么用途和价值_学Python有意义吗 就业前景如何?
  5. vs2015无法安装,提示安装包损坏
  6. popper.js——tooltip文档及源码分析
  7. ZeroMemory
  8. AssertionError: Label class 1 exceeds nc=1 in data/steel.yaml. Possible class labels are 0-0
  9. Visual Studio 19.0 资源视图加载失败
  10. KNN算法学习-实现海伦约会网站与手写体识别实验