分布式Ehcache
参考
这个文档包括一个Terracotta
分布cache的参考信息
快速安装
与定制安装
有2种方法来安装Terracotta分布cache:快速与定制。快速安装适用于只需要一个cache的集群。定制安装适用于需要一个cache集群和其他java对象,例如sessions和定制POJOs,或者使用Terracotta应用,或者使用Terracotta整合模块(Terracotta integration Modules:TIMs)整合其他技术。
如果你使用Ehcache在一个单独的JVM上,或者使用一个集群响应,可以考虑快速安装(在这里
)。如果你是一个前沿的Terracotta使用者,而且想要添加一个分布caching,可以考虑使用定制安装。
如果你不确定用哪种方式安装,请阅读2中安装方法,然后找到适合你的安装方法。这2中安装方法不兼容,也不能被兼容使用。
分布式cache配置文件
Terracotta分布式配置文件(默认为ehcache.xml)包含一个CacheMananger(the Ehcache class managing a set of defined caches)的一个实例的配置。这个配置文件必须在你应用的classpath里面。当你使用WAR文件的时候,需要将ehcache.xml复制到WEB-INF/classes中。
Terracotta集群配置元素
<terracotta>
这个element是一个<cache>中可选的sub-element。在ehcache.xml中定义的每个<cache>中,<terracotta>可以做不同的设置。
<terracotta>有以下这些特性:
clusted - 开启("true")或者关闭("false")terracotta集群对于某个cache。
valueMode - 设置cache序列化的方式(the standard Ehcache "copy" cache)或者标识 (Terracotta object identity)。标识只能在定制安装中被使用(查看快速安装
)
提示:比较序列化和标识模块
In serialization mode, getting an element from the cache gets a copy of that element. Changes made to that copy do not affect any other copies of the same element or the value in the cache. Putting the element in the cache overwrites the existing value. This type of cache provides high performance with small, read-only data sets. Large data sets with high traffic, or caches with very large elements, can suffer performance degradation because this type of cache serializes clustered objects. In read-write data sets, data coherency issues may arise because this type of cache cannot guarantee a consistent view of object values. Objects clustered in this mode _must be_ serializable.
In identity mode, getting an element from the cache gets a reference to that element. Changes made to the referenced element updates the element on every node on which it exists (or a reference to it exists) as well as updating the value in the cache. Putting the element in the cache does not overwrite the existing value. This mode guarantees data coherence. It can be used only with a custom Terracotta Distributed Cache installation. Objects clustered in this mode must be portable
and must be locked when accessed.
默认的在<cache>模块中添加<terracotta/>等价于添加<terracotta clustered="true" valueMode="seralization">。如果valueMode没有指明,会使用默认的"seralization"。
<terracottaConfig>
这个元素只在快速安装中使用(查看快速安装
)。当Terracotta对于某个cache打开时,这个元素必须用url或者用一个内嵌配置,指明Terracotta配置文件(默认为tc-config.xml)。
用URL属性
为<terracottaConfig>元素添加一个URL属性:
<terracottaConfig url="<source>" />
<source>可以是以下几种方式:
路径:(例如:url="/path/to/tc-config.xml")
URL:(例如:url="http://www.mydomain.com/path/to/tc-config.xml)
Terracotta主机地址:(例如:url="host1:9510")
Note the following about using server addresses in the form <host>:<dso-port>:
- * The default DSO port is 9510.
- * In a multi-server cluster, you can specify a comma-delimited list (for example, url="host1:9510,host2:9510,host3:9510" ).
内嵌Terracotta配置
你可以在ehcache.xml中内嵌一个关于Terracotta配置的内容:
<terracottaConfig>
<tc-config>
<servers>
<server host="server1" name="s1"/>
<server host="server2" name="s2"/>
</servers>
<clients>
<logs>app/logs-%i</logs>
</clients>
</tc-config>
</terracottaConfig>
编辑不相容的配置
对于任何被集群的cache,你必须删除、disable、或者编辑那些在Terracotta集群时不相容的配置元素。被集群的caches有个<terracotta>或者<terracotta clustered=”true”>元素。
下面这些Ehcache配置属性或者元素需要删除或者disable。
- DiskStore-related attributes overflowToDisk and diskPersistent .
Terracotta 服务器自动提供一个磁盘储存。
- Replication-related configuration elements, such as <cacheManagerPeerProviderFactory>, <cacheManagerPeerListenerFactory>, <bootstrapCacheLoaderFactory>, <cacheEventListenerFactory>.
当一个变化发生在Terracotta集群的时候,所以包含变化元素和对象的节点都会更新。 Unlike the replication methods used to cluster Ehcache, cache event listeners are not (and do not need to be) notified of remote changes. Listeners are still aware of local changes.
- Replication-related attributes such as replicateAsynchronously and replicatePuts .
MemoryStoreEvictionPolicy属性需要被设置成LFU或者LRU。设置MemoryStoreEvictionPolicy为FIFO将会引起IllegalArgumentException错误。
可以查看Ehcache documentation
得到更多标准的配置关于Ehcache。
分享到:
相关推荐
记载了terracotta如何与tomcat、jetty等服务器的集群,解释了tc-config.xml中各个配置的作用
其实terracotta集群tomcat这方面的资料也算不少了··但还是会很容易出现错误·· 希望我这个文档能帮助大家!
通过_Terracotta实现基于Tomcat的Web应用集群
java ehcache terracotta 集群, 分布式缓存配置
Terracotta实现基于Tomcat的Web应用集群
Terracotta的基本原理是对于集群间共享的数据,当在一个节点发生变化的时候,Terracotta只把变化的部分发送给Terracotta服务器,然后由服务器把它转发给真正需要这个数据的节点。这样对网络的压力就非常小,各个节点...
terracotta集群负载,是个好东西
Terracotta
NULL 博文链接:https://lihongchao87.iteye.com/blog/1727802
ehcache3集群相关资源,包括ehcache-clustered-3.10.0-kit、ehcache-3.10.0.jar、ehcache-clustered-3.10.0.jar、terracotta-3.7.7.tar.gz、ehcache-transactions-3.10.0.jar
《基于Terracotta和Continuent的可扩展集群架构》 1) 关键应用架构待解决的集群问题 2) 基于JVM的透明数据复制技术 3) Oracle RAC 的开源数据库替代技术 演讲人:程勇 灰狐开源社区共同创始人
terracotta-toolkit-1.3-runtime-3.2.0.jar 集群实现JAR
Terracotta 3.2.1 英文文档
linux安装包terracotta-3.7.7.tar.gz,用于tomcat的session集群
terracotta-ee-3.5.2破解版
1.0 博文链接:https://phl.iteye.com/blog/1993833
terracotta license.key ,
ehcache的terracotta方案的比较.docx