天天看点

tomcat 集群下ehcache 整合spring cache-annotation

系统环境:win7

部署环境:apache2.2 tomcat4

应用程序版本:spring3.2 ehcache2.6

1:tomcat 负载和集群配置

1.1 模型图

[img]

[img]http://dl2.iteye.com/upload/attachment/0086/4206/4922f694-3278-3bbf-9c6d-b33f9c0cac1f.png[/img]

[/img]

tomcat负载需要apache协助,apache启的作用就是,接受client请求,调度tomcat.

各个tomcat分载请求,均衡流量,降低web server压力。通过tomcat cluster 可以实现各tomcat数据同步和共享。

1.2 配置

解压两个统一版本的tomcat 分别命名为apache-tomcat-6080 和apache-tomcat-7080

修改6080tomcat srever。xml

修改7080tomcat srever。xml

配置apache

将mod_jk-1.2.31-httpd-2.2.3.so 复制到apache moudles 中。

在conf中创建mod_jk.conf 和workers.properties。

mod_jk.conf 主要定义mod_jk模块的位置以及mod_jk模块的连接日志设置,还有定义worker.properties文件的位置。

workers.properties 定义worker的参数,主要是连接tomcat主机的地址和端口信息。如果Tomcat与apache不在同一台机器上,或者需要做多台机器上tomcat的负载均衡只需要更改workers.properties文件中的相应定义即可。

将conf/httpdf.conf 文件末尾追加:

Include conf/mod_jk.conf
           

2 ehcache 与 spring-cache 整合

2.1 添加ehcache.xml

cacheManagerPeerProviderFactory 其他tomcat 多个url 可以用,分割

cacheManagerPeerListenerFactory 当前tomcat

部署时,需要根据tomcat 集群监听端口 修改各自的ehcache.xml配置.

applictionContext.xml 配置

spring 注解缓存使用