EhCache 集群 配置(RMI方式)
这里先说明下环境:JDK1.6、ehcache-core-2.1.0.jar、Tomcat6、Spring3.0.2。使用的是RMI方式配置集群的,这里先吐槽下遇到的情况,在搜相关知识的时候发现到处都是同一篇文章,被抄来抄去,最后没办法只好用英文在google上搜索才找到了大量有用的文章以及遇到类似的帖子,哎,继续写我的配置。(出自博客园)
RMI的介绍不多说,因为我也不是非常理解,不敢妄加说明,还怕误导别人。
我的集群环境是两台硬件服务器分别为A服务器和B服务器,每台服务器上有两个tomcat,A服务器上的是Tomcat1和Tomcat2,B服务器上的是Tomcat3和Tomcat4,大家一定要注意环境,因为有的环境不同,配置就不同,RMI集群有两种方式配置:自动成员发现和手动成员发现。我采用的是自动成员发现(本人不会考虑手动成员发现,局限性太大,不利于项目的统一部署,原因是:因为每次都要修改配置文件)。项目是通过Spring配置文件来加载ehcache.xml的,不再说明,这里只说ehcache.xml配置(配置中的中文注释是在编写这篇文章的时候添加的,因为这个配置文件中存在中文注释让我的项目启动不起来):
- <?xml version="1.0" encoding="UTF-8"?>
- <ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="ehcache.xsd" updateCheck="false"
- monitoring="autodetect">
- <diskStore path="java.io.tmpdir" />
- <!--缓存成员发现工厂,管理cacheManager对象 -->
- <cacheManagerPeerProviderFactory
- class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
- properties="peerDiscovery=automatic, multicastGroupAddress=230.0.0.1, multicastGroupPort=4446,
- multicastPacketTimeToLive=32" />
- <!--针对cacheManager事件的监听,这里只介绍properties中的hostName、port属性,
- 这里我忽略了hostName的配置,查看他们的源码发现如果不填写hostName,
- 他们就会通过JDK中的InterAddress.getLocalHost().getHostAddress()获取本机的ip地址,
- 所以在这里我没有填写hostName的配置,方便部署到多台硬件服务器上。
- 但是如果一台已经服务器上有多个网卡,这里一定要指定hostName的IP,原因参考InterAddress源码。
- post这里我指定的时40001,如果这里不填写port配置,ehcache就会通过ServerSocket的getLocalPort获取一个本机没有被占用的端口 -->
- <cacheManagerPeerListenerFactory
- class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"
- properties="port=40001" />
- <!--默认缓存配置 -->
- <defaultCache maxElementsInMemory="10000" eternal="false"
- timeToIdleSeconds="120" timeToLiveSeconds="120" overflowToDisk="false"
- maxElementsOnDisk="10000000" diskPersistent="false"
- diskExpiryThreadIntervalSeconds="120" memoryStoreEvictionPolicy="LRU" />
- <!--自定义缓存配置1 -->
- <cache name="cache1" maxElementsInMemory="10000"
- maxElementsOnDisk="10000" eternal="false" overflowToDisk="false"
- diskSpoolBufferSizeMB="20" timeToIdleSeconds="7200" timeToLiveSeconds="7200"
- diskPersistent="false" memoryStoreEvictionPolicy="LFU">
- <!--监听缓存事件,缓存移除、修改的时候同步其他服务器(Tomcat)的缓存,时间限制,具体属性不在这里说明 -->
- <cacheEventListenerFactory
- class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
- properties="replicateAsynchronously=true, replicatePuts=true, replicateUpdates=true,replicateUpdatesViaCopy=false, replicateRemovals=true " />
- <!--服务器(Tomcat)启动就同步其他服务器(Tomcat)中的缓存,时间限制,具体属性不再这里说明 -->
- <bootstrapCacheLoaderFactory
- class="net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory" />
- </cache>
- <!--自定义缓存配置2 -->
- <cache name="cache2" maxElementsInMemory="10000"
- maxElementsOnDisk="10000" eternal="false" overflowToDisk="false"
- diskSpoolBufferSizeMB="20" timeToIdleSeconds="7200" timeToLiveSeconds="7200"
- diskPersistent="false" memoryStoreEvictionPolicy="LFU">
- <cacheEventListenerFactory
- class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
- properties="replicateAsynchronously=true, replicatePuts=true, replicateUpdates=true,replicateUpdatesViaCopy=false, replicateRemovals=true " />
- <bootstrapCacheLoaderFactory
- class="net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory" />
- </cache>
- </ehcache>
EhCache 集群 配置(RMI方式)的更多相关文章
- ehcache 集群使用 rmi方式 有图有真想
来源:http://www.tuicool.com/articles/MJzYZbR ehcache 有几种方式集群 ,rmi,jgroup还有jms:这里讲一下ehcache的使用 ehcache ...
- [转]RMI方式Ehcache集群的源码分析
RMI方式Ehcache集群的源码分析 Ehcache不仅支持基本的内存缓存,还支持多种方式将本地内存中的缓存同步到其他使用Ehcache的服务器中,形成集群.如下图所示: Ehcache支持 ...
- RMI方式Ehcache集群的源码分析
Ehcache不仅支持基本的内存缓存,还支持多种方式将本地内存中的缓存同步到其他使用Ehcache的服务器中,形成集群.如下图所示: Ehcache支持多种集群方式,下面以RMI通信方式为例,来具体分 ...
- 浅析Quartz的集群配置
浅析Quartz的集群配置(一) 收藏人:Rozdy 2015-01-13 | 阅:1 转:22 | 来源 | 分享 1 基本信息 摘要:Quar ...
- Ubuntu 14.04中Elasticsearch集群配置
Ubuntu 14.04中Elasticsearch集群配置 前言:本文可用于elasticsearch集群搭建参考.细分为elasticsearch.yml配置和系统配置 达到的目的:各台机器配置成 ...
- MongoDB高可用集群配置的方案
>>高可用集群的解决方案 高可用性即HA(High Availability)指的是通过尽量缩短因日常维护操作(计划)和突发的系统崩溃(非计划)所导致的停机时间,以提高系统和应用的可用性. ...
- MySQL Cluster 7.3.5 集群配置实例(入门篇)
一.环境说明: CentOS6.3(32位) + MySQL Cluster 7.3.5,规划5台机器,资料如下: 节点分布情况: MGM:192.168.137. NDBD1:192.168.137 ...
- 关于ActiveMQ的几种集群配置
ActiveMQ的几种集群配置. Queue consumer clusters 此集群让多个消费者同时消费一个队列,若某个消费者出问题无法消费信息,则未消费掉的消息将被发给其他正常的消费者,结构图如 ...
- solrCloud+tomcat+zookeeper集群配置
solrcolud安装solrCloud+tomcat+zookeeper部署 转载请出自出处:http://eksliang.iteye.com/blog/2107002 http://eksli ...
随机推荐
- DotnetBrowser高级教程-(4)使用MVC框架3-文件上传
网站有时候需要上传文件,本节以上传一张图片为例,在UserController.cs里添加如下代码: public string UploadImgPage() { return "< ...
- squid.conf 的cache_peer 详解
通过squid.conf配置文件中的cache_peer选项来配置代理服务器阵列,通过其他的选项来控制选择代理伙伴的方法.Cache_peer的使用格式如下: cache_peer hostname ...
- hive on spark VS SparkSQL VS hive on tez
http://blog.csdn.net/wtq1993/article/details/52435563 http://blog.csdn.net/yeruby/article/details/51 ...
- IntelliJ IDEA 快捷键整理-from imooc
IntelliJ IDEA 快捷键整理-from imooc 学习了:https://www.imooc.com/learn/9241, main2, 100.for 3, new Date().so ...
- [Functional Programming] Transition State based on Existing State using the State ADT (liftState, composeK)
While sometimes outside input can have influence on how a given stateful transaction transitions, th ...
- RabbitMQ二----' helllo world '
RabbitMQ实现了AMQP定义的消息队列.它实现的功能”非常简单“:从Producer接收数据然后传递到Consumer.它能保证多并发,数据安全传递,可扩展. 我们将会设计两个程序,一个发送He ...
- 怎么关闭win10快速访问功能?关闭Windows10系统快速访问方法
怎么关闭win10快速访问功能?关闭Windows10系统快速访问方法 Windows10系统的"快速访问"功能很容易泄露电脑中的隐私,用什么方法可以让这个功能消失,避免电脑的个人 ...
- Https单向认证和双向认证介绍
一.Http HyperText Transfer Protocol,超文本传输协议,是互联网上使用最广泛的一种协议,所有WWW文件必须遵循的标准.HTTP协议传输的数据都是未加密的,也就是明文的,因 ...
- requests 模块入门玩法和高级玩法
1.安装 pip install requests 2. http://docs.python-requests.org/zh_CN/latest/user/quickstart.html http: ...
- flume配置和说明(转)
Flume是什么 收集.聚合事件流数据的分布式框架 通常用于log数据 采用ad-hoc方案,明显优点如下: 可靠的.可伸缩.可管理.可定制.高性能 声明式配置,可以动态更新配置 提供上下文路由功能 ...