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. SharePoint 关于拓扑错误的解决方案

    Issue Topology报错信息:SharePoint Web Services Round Robin Service Load Balancer Event: EndpointFailure. ...

  2. 凡人视角C++之string(上)

    好久没有更新博客了,这段时间一直在忙图像处理的项目,近期空了下来.也是时候整合C++的相关内容,静心感受下编程语言的魅力.和大家共同探讨学习.我将以头文件的形式展开学习,且仅仅讲述相关接口的应用,至于 ...

  3. ASTER:An Attentional Scene Text Recognizer with Flexible Rectification

    代码链接:https://github.com/bgshih/aster 方法概述 本文方法主要解决不规则排列文字的文字识别问题,论文为之前一篇CVPR206的paper(Robust Scene T ...

  4. ansible 批量推送公钥

    这里我们使用ansible的playbook 的功能来推送秘钥 使用方法参见:http://blog.csdn.net/magedu_linux/article/details/48529645 这里 ...

  5. 定期删除elasticsearch 的index 索引

    #!/bin/bashfind /data/elasticsearch/data/pro-kz-log/nodes/0/indices/ -type d -mtime +7 | awk -F" ...

  6. java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException 的解决办法之一

    在查看别人的代码的时候,遇到了把工程导入到 Android Studio ,报:ExecutionException: com.android.ide.common.process.ProcessEx ...

  7. 36氪首发 | 「myShape」完成千万级人民币 Pre-A轮融资,推出 AI 智能健身私教

    无需任何可穿戴设备. 36氪获悉,myShape(原Shapejoy)已于近期完成千万级人民币的Pre-A轮融资,由天奇阿米巴领投,远洋集团.七熹资本以及老股东跟投.过去 myShape 曾获得元迅资 ...

  8. python-enumerate方法

    enumerate方法用于循环list或tuple,循环的时候可以得到索引值和当前索引的对象: letters = ['a', 'b', 'c', 'd', 'e'] for i, letter in ...

  9. C++11 STL算法简介

    STL(Standard Template Library),即标准模板库,是一个具有工业强度的,高效的C++程序库.它被容纳于C++标准程序库(C++ Standard Library)中,是ANS ...

  10. 每日英语:Got 5 Minutes? 'Flash Fiction' Catches On

    Chinese author Lao Ma has a simple approach to his short stories: In the face of life, everything is ...