现在的位置: 首页 > 综合 > 正文

terracota ehcache配置详解

2019年09月09日 ⁄ 综合 ⁄ 共 2644字 ⁄ 字号 评论关闭

一、服务器端配置
     1、安装terracotta
            java -jar terracotta-3.2.1-installer.jar
      2、配置terracotta  server的配置文件  tc-config.xml  ,可以在 服务器terracotta 根目录的 terracotta/platform/samples 下面找到,修改该文件成如下,把house部分的IP地址改成服务真正的IP地址
  <?xml version="1.0" encoding="UTF-8"?>

<!--
All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved.
-->

<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-5.xsd">

  <!-- Tell DSO where the Terracotta server can be found; 
       See 
       - Terracotta Configuration Guide and Reference 
       - About Terracotta Configuration Files
       for additional information. -->
  <servers>
    <server host="10.187.216.28" name="server1">
      <dso-port>9510</dso-port>
      <jmx-port>9520</jmx-port>
      <data>terracotta/demo-server/server-data</data>
      <logs>terracotta/demo-server/server-logs</logs>
      <statistics>terracotta/demo-server/server-statistics</statistics>
    </server>
  </servers>
</tc:tc-config>

第三步:启动terracotta server
     nohup ./bin/start-tc-server.sh tc-config.xml & 

    注意事项:如果启动的时候不添加 tc-config.xml  参数,terracotta 服务器会默认使用 127.0.0.1 作为ip,所以如果不是本级,一定要配置第二步的IP地址

     二、客户端配置:
只需要修改ehcache.xml 文件,添加 
                      <terracottaConfig url="10.187.216.28:9510"/>
                      <terracotta clustered="true"/>
              客户端配置文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<ehcache name="myCache" updateCheck="false">
    <diskStore path="java.io.tmpdir"/>
   <!-- 
    <terracottaConfig url="10.187.216.28:9510"/>
   -->
   <terracottaConfig url="10.187.216.28:9510"/>
    <!-- xul(2009-12-23) -->
    <defaultCache
        maxElementsInMemory="10000"
        eternal="false"
        timeToIdleSeconds="1800"
        timeToLiveSeconds="1800"
        overflowToDisk="false"
        diskSpoolBufferSizeMB="30"
        maxElementsOnDisk="10000000"
        diskPersistent="false"
        diskExpiryThreadIntervalSeconds="120"
        memoryStoreEvictionPolicy="LRU"
        >
    </defaultCache>
    <cache name="syscache"
           maxElementsInMemory="100000"
           eternal="false"
           timeToIdleSeconds="0"
           timeToLiveSeconds="0"
           overflowToDisk="false"
           memoryStoreEvictionPolicy="LFU"
            >
                <terracotta clustered="true"/>
    </cache>  
     <!-- 6 hour-->
    <cache name="shopCache"
           maxElementsInMemory="100000"
           eternal="false"
           timeToIdleSeconds="0"
           timeToLiveSeconds="21600"
           overflowToDisk="false"
           memoryStoreEvictionPolicy="LFU"
            >
                <terracotta clustered="true"/>
    </cache>  
</ehcache>

    

原文地址:http://www.itmmd.com/201410/74.html 
该文章由 android开发 整理发布,转载须标明出处。

抱歉!评论已关闭.