CAS (11) —— CAS TicketRegistry使用Ehcache的集群方案

摘要

CAS TicketRegistry使用Ehcache的集群方案

版本


tomcat版本: tomcat-8.0.29

jdk版本: jdk1.8.0_65

cas版本: 4.1.3

**cas4.1.3 (4.x还在开发过程中不是很稳定,迭代比较快,也会有些bug) **

cas-client-3.4.1

Ehcache版本: 2.10.1

内容

目标架构

准备

参照下列文章配置好相关环境

配置

  • Ehcache Maven

      <dependency>
    <groupId>org.jasig.cas</groupId>
    <artifactId>cas-server-integration-ehcache</artifactId>
    <version>${project.version}</version>
    <scope>compile</scope>
    </dependency>
    <dependency>
    <groupId>net.sf.ehcache</groupId>
    <artifactId>ehcache-core</artifactId>
    <version>2.6.11</version>
    </dependency>
    <dependency>
    <groupId>net.sf.ehcache</groupId>
    <artifactId>ehcache</artifactId>
    <version>2.10.1</version>
    </dependency>
  • Ehcache配置文件ehcache-replicated.xml

    • 节点a(以端口8433为例)

        <ehcache name="ehCacheTicketRegistryCache"
      updateCheck="false"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd"> <diskStore path="java.io.tmpdir/cas"/> <!--
      | Automatic peer discovery
      | See http://ehcache.org/documentation/user-guide/rmi-replicated-caching#automatic-peer-discovery
      | for more information.
      -->
      <!--
      <cacheManagerPeerProviderFactory
      class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
      properties="peerDiscovery=automatic, multicastGroupAddress=230.0.0.1, multicastGroupPort=4446, timeToLive=32"
      propertySeparator="," />
      --> <!--
      | Manual peer discovery
      | See http://ehcache.org/documentation/user-guide/rmi-replicated-caching#manual-peer-discovery-manual-peer-discovery
      | for more information
      -->
      <!--
      <cacheManagerPeerProviderFactory
      class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
      properties="peerDiscovery=manual,rmiUrls=//peer-2:41001/cas_st|//peer-3:41001/cas_st|//peer-2:41001/cas_tgt|//peer-3:41001/cas_tgt" />
      <cacheManagerPeerListenerFactory
      class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"
      properties="port=41001,remoteObjectPort=41002" />
      --> <cacheManagerPeerProviderFactory
      class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
      properties="peerDiscovery=manual,rmiUrls=//127.0.0.1:41041/cas_st|//127.0.0.1:41041/cas_tgt" />
      <cacheManagerPeerListenerFactory
      class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"
      properties="port=41031, remoteObjectPort=41032" /> </ehcache>
    • 节点b(以端口8443为例)

         <cacheManagerPeerProviderFactory
      class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
      properties="peerDiscovery=manual,rmiUrls=//127.0.0.1:41031/cas_st|//127.0.0.1:41031/cas_tgt" />
      <cacheManagerPeerListenerFactory
      class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"
      properties="port=41041,remoteObjectPort=41042" />

    注意以上ProviderFactory和ListenerFactory中的给出的端口:

    • ListenerFactory是指定本地Cache节点的端口

    • ProviderFactory是配置远程Cache节点的端口

    • 如果二个以上节点,则所有节点都要列出并用 | 符号分隔

  • Ehcache在CAS TicketRegistry.xml 中的配置

      <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:c="http://www.springframework.org/schema/c"
    xmlns:p="http://www.springframework.org/schema/p"
    xsi:schemaLocation="
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    " >
    <description>
    Configuration for the default TicketRegistry which stores the tickets in Ehcache
    </description>
    <bean id="ticketRegistry"
    class="org.jasig.cas.ticket.registry.EhCacheTicketRegistry"
    p:serviceTicketsCache-ref="serviceTicketsCache"
    p:ticketGrantingTicketsCache-ref="ticketGrantingTicketsCache" /> <bean id="abstractTicketCache" abstract="true"
    class="org.springframework.cache.ehcache.EhCacheFactoryBean"
    p:cacheManager-ref="cacheManager"
    p:diskExpiryThreadIntervalSeconds="0"
    p:diskPersistent="false"
    p:eternal="false"
    p:maxElementsInMemory="10000"
    p:maxElementsOnDisk="20000"
    p:memoryStoreEvictionPolicy="LRU"
    p:overflowToDisk="true"
    p:bootstrapCacheLoader-ref="ticketCacheBootstrapCacheLoader" /> <!-- MUST use synchronous repl for service tickets for correct behavior. -->
    <bean id="serviceTicketsCache"
    class="org.springframework.cache.ehcache.EhCacheFactoryBean"
    parent="abstractTicketCache"
    p:cacheName="cas_st"
    p:timeToIdle="0"
    p:timeToLive="300"
    p:cacheEventListeners-ref="ticketRMISynchronousCacheReplicator" /> <bean id="ticketGrantingTicketsCache"
    class="org.springframework.cache.ehcache.EhCacheFactoryBean"
    parent="abstractTicketCache"
    p:cacheName="cas_tgt"
    p:timeToIdle="0"
    p:timeToLive="7201"
    p:cacheEventListeners-ref="ticketRMIAsynchronousCacheReplicator" /> <bean id="cacheManager"
    class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"
    p:configLocation="classpath:ehcache-replicated.xml"
    p:shared="false"
    p:cacheManagerName="ticketRegistryCacheManager" /> <bean id="ticketRMISynchronousCacheReplicator"
    class="net.sf.ehcache.distribution.RMISynchronousCacheReplicator"
    c:replicatePuts="true"
    c:replicatePutsViaCopy="true"
    c:replicateUpdates="true"
    c:replicateUpdatesViaCopy="true"
    c:replicateRemovals="true" /> <!--Richard modify cater to 4.1.3-->
    <bean id="ticketRMIAsynchronousCacheReplicator"
    class="net.sf.ehcache.distribution.RMIAsynchronousCacheReplicator"
    parent="ticketRMISynchronousCacheReplicator"
    c:replicatePuts="true"
    c:replicatePutsViaCopy="true"
    c:replicateUpdates="true"
    c:replicateUpdatesViaCopy="true"
    c:replicateRemovals="true"
    c:replicationInterval="10000"
    c:maximumBatchSize="100" /> <bean id="ticketCacheBootstrapCacheLoader"
    class="net.sf.ehcache.distribution.RMIBootstrapCacheLoader"
    c:asynchronous="true"
    c:maximumChunkSize="5000000" /> </beans>

测试

参考

参考来源:

Ehcache Ticket Registry

结束

CAS (11) —— CAS TicketRegistry使用Ehcache的集群方案的更多相关文章

  1. 11. 搭建一个完整的K8S集群

    11. 搭建一个完整的Kubernetes集群 1. kubectl的命令遵循分类的原则(重点) 语法1: kubectl 动作 类 具体的对象 例如: """ kube ...

  2. Spring Boot 2.x基础教程:使用EhCache缓存集群

    上一篇我们介绍了在Spring Boot中整合EhCache的方法.既然用了ehcache,我们自然要说说它的一些高级功能,不然我们用默认的ConcurrentHashMap就好了.本篇不具体介绍Eh ...

  3. 分布式缓存集群方案特性使用场景(Memcache/Redis(Twemproxy/Codis/Redis-cluster))优缺点对比及选型

    分布式缓存集群方案特性使用场景(Memcache/Redis(Twemproxy/Codis/Redis-cluster))优缺点对比及选型   分布式缓存特性: 1) 高性能:当传统数据库面临大规模 ...

  4. Redis集群方案介绍

    由于Redis出众的性能,其在众多的移动互联网企业中得到广泛的应用.Redis在3.0版本前只支持单实例模式,虽然现在的服务器内存可以到100GB.200GB的规模,但是单实例模式限制了Redis没法 ...

  5. Haproxy+Heartbeat 高可用集群方案操作记录

    之前详细介绍了haproxy的基础知识点, 下面记录下Haproxy+Heartbeat高可用web集群方案实现过程, 以加深理解. 架构草图如下: 1) 基本环境准备 (centos6.9系统) 1 ...

  6. LVS+Heartbeat 高可用集群方案操作记录

    之前分别介绍了LVS基础知识和Heartbeat基础知识, 今天这里简单说下LVS+Heartbeat实现高可用web集群方案的操作说明. Heartbeat 项目是 Linux-HA 工程的一个组成 ...

  7. Redis 集群方案介绍

    由于Redis出众的性能,其在众多的移动互联网企业中得到广泛的应用.Redis在3.0版本前只支持单实例模式,虽然现在的服务器内存可以到100GB.200GB的规模,但是单实例模式限制了Redis没法 ...

  8. Redis集群方案收集

    说明: 如果不考虑客户端分片去实现集群,那么市面上基本可以说就三种方案最成熟,它们分别如下所示: 系统 贡献者 是否官方Redis实现 编程语言 Twemproxy Twitter 是 C Redis ...

  9. 基于Twemproxy的Redis集群方案(转载)

    原文地址:基于Twemproxy的Redis集群方案 概述 由于单台redis服务器的内存管理能力有限,使用过大内存redis服务器的性能急剧下降,且服务器发生故障将直接影响大面积业务.为了获取更好的 ...

随机推荐

  1. Thinking In Design Pattern——MVP模式演绎

    原文<Thinking In Design Pattern——MVP模式演绎>不知为何丢失了,故重新整理了一遍. 目录 What Is MVP Domain Model StubRepos ...

  2. js scrollIntoView 滚动到元素可视区域

    老是忘记这个函数名,记录一下啊 // 滚动到可视区域 document.querySelector(".loading").scrollIntoView()

  3. 另辟蹊径 直取通州的“墨迹天气”APP应用的成功故事

    一个天气应用,曾被认为是要挑战国家气象局,网站也莫名其妙地被封,两个合伙人先后离开.创始人金犁是如何把这么一款工具类应用做到人所共知的? 采访 | 郑江波 翟文婷 文 | 翟文婷 出生时间:1982年 ...

  4. SpringBoot actuator 应用监控。

    前言 : 今天在阅读 <SpringCloud微服务实战>一书时看到了SpringBoot actuator相关知识,并且自己也本地调试实践.觉得SpringBoot这一套监控还是挺有意思 ...

  5. 【OfficeWebViewer】在线预览Word,Excel~

    今天有个需求, 直接支持web端预览word,excel等文件, 查了一下很多写的比较麻烦, 这里找到一种简单的方式: http://view.officeapps.live.com/op/view. ...

  6. kafaka学习

    创建一个topic: [root@hdp1 bin]# ./kafka-topics. --replication-factor --partitions --topic justin Created ...

  7. 【转】在 XAML 的属性中,转义大括号 {}

    我们知道大括号"{}"在XAML中是用来处理标记扩展的. 比如: <Button Content="{Binding}"/>   但如何转义而表示普 ...

  8. 服务端 https和SSL

    String keyStoreFilePassword = System .getProperty("keystore.file.password"); /usr/java/jdk ...

  9. android 学习视频汇总

    1.java基础知识 http://www.eoeandroid.com/thread-333511-1-1.html 网易公开课-抽象编程:http://open.163.com/special/o ...

  10. html5中audio的详细使用

    html5的audio功能上已经非常强大,回放,跳转,缓冲等以前只能用flash才能实现的功能,html5的audio都能轻松搞定 最近的一个项目使用到了这个功能,把我使用的情况写下来,供大家参考, ...