spring-session之4 redis集群配置
前文,我们 spring-session之3 redis配置参数配置
, 我们可以配置简单的ip和port,但是生产环境,我们的redis是做了集群
,肯定不是单点,此时就不能单单hostName 和 port了, 怎么办?
好,今天的目标是:
- 配置
spring-session
redis 集群
1. 我们原来的 redis data 配置
1.1. spring-redis.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:context="http://www.springframework.org/schema/context" xmlns:loxia="http://loxia.benjamin.cn/schema/core"
xmlns:p="http://www.springframework.org/schema/p" xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://loxia.benjamin.cn/schema/core http://loxia.benjamin.cn/schema/core/loxia-spring-ext.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
">
<bean id="redisconfig" class="redis.clients.jedis.JedisPoolConfig">
<property name="maxActive" >
<value type="long">#{redis['redis.MaxActive']}</value>
</property>
<property name="maxIdle" >
<value type="long">#{redis['redis.MaxIdle']}</value>
</property>
<property name="maxWait">
<value type="long">#{redis['redis.MaxWait']}</value>
</property>
<property name="testOnBorrow" >
<value type="boolean">true</value>
</property>
<property name="testOnReturn" >
<value type="boolean">true</value>
</property>
</bean>
<bean id="jedisSentinelPool" class="redis.clients.jedis.JedisSentinelPool">
<constructor-arg ref="redisconfig"></constructor-arg>
<constructor-arg type="java.util.Set">
<set>
<value>#{redis['redis.sentinel1']}</value>
<value>#{redis['redis.sentinel2']}</value>
<value>#{redis['redis.sentinel3']}</value>
</set>
</constructor-arg>
<constructor-arg >
<value>#{redis['redis.mastername']}</value>
</constructor-arg>
</bean>
</beans>
1.2 redis.properties
#A string containing whitespace or comma separated host or IP addresses and port numbers of the form "host:port host2:port" or "host:port, host2:port".
redis.sentinel1=redis01.public.test.baozun.cn:26379
redis.sentinel2=redis02.public.test.baozun.cn:26379
redis.sentinel3=redis03.public.test.baozun.cn:26379
redis.mastername=testenv
redis.timeout=1000
redis.MaxActive=50
redis.MaxIdle=60000
redis.MaxWait=5000
##这个是我们自定义的 key前缀, 以便用同一套redis集群,适应多个不同的商城
redis.keystart=feilongdev
2.redis 集群配置
那么我们怎么使用上面的环境来配置我们的spring-session呢?
使用通过上述的参数表格, JedisPoolConfig 可以使用,但是没有 JedisSentinelPool参数
而 JedisShardInfo
属性并不是list,只是 包含了jedis服务器的一些信息 ,咋整?
这时候,我们来看看 JedisConnectionFactory 构造函数:
可以看出 ,构造函数支持 RedisSentinelConfiguration
或者 RedisClusterConfiguration
此处的 JedisConnectionFactory
是 spring-data-redis 内容, 有兴趣的可以看看, 这里也有入门版的教程,参见使用Spring Data Redis操作Redis(一)
2.1 RedisSentinelConfiguration
我们先使用 redis 哨兵机制的集群
那么我们尝试修改以下配置配置:
<?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:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p" xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
">
<context:annotation-config />
<util:properties id="redis" location="classpath:redis.properties"></util:properties>
<!-- RedisHttpSessionConfiguration -->
<bean class="org.springframework.session.data.redis.config.annotation.web.http.RedisHttpSessionConfiguration" />
<!--JedisConnectionFactory -->
<bean class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
<constructor-arg index="0">
<bean class="org.springframework.data.redis.connection.RedisSentinelConfiguration">
<constructor-arg index="0" value="#{redis['redis.mastername']}" />
<constructor-arg index="1">
<set>
<value>#{redis['redis.sentinel1']}</value>
<value>#{redis['redis.sentinel2']}</value>
<value>#{redis['redis.sentinel3']}</value>
</set>
</constructor-arg>
</bean>
</constructor-arg>
<constructor-arg index="1">
<bean class="redis.clients.jedis.JedisPoolConfig">
<property name="maxActive" value="#{redis['redis.MaxActive']}" />
<property name="maxIdle" value="#{redis['redis.MaxIdle']}" />
<property name="maxWait" value="#{redis['redis.MaxWait']}" />
<property name="testOnBorrow" value="true" />
<property name="testOnReturn" value="true" />
</bean>
</constructor-arg>
</bean>
</beans>
启动应用
出现以下的错误
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'maxActive' of bean class [redis.clients.jedis.JedisPoolConfig]: Bean property 'maxActive' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:1044)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:904)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:75)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:57)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1452)
... 30 more
JedisPoolConfig 不支持 maxActive 属性了 see xetorthio/jedis#1031
好吧, 修改下配置 spring-session.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:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p" xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
">
<context:annotation-config />
<util:properties id="redis" location="classpath:redis.properties"></util:properties>
<!-- RedisHttpSessionConfiguration -->
<bean class="org.springframework.session.data.redis.config.annotation.web.http.RedisHttpSessionConfiguration" />
<!--JedisConnectionFactory -->
<bean class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
<constructor-arg index="0">
<bean class="org.springframework.data.redis.connection.RedisSentinelConfiguration">
<constructor-arg index="0" value="#{redis['redis.mastername']}" />
<constructor-arg index="1">
<set>
<value>#{redis['redis.sentinel1']}</value>
<value>#{redis['redis.sentinel2']}</value>
<value>#{redis['redis.sentinel3']}</value>
</set>
</constructor-arg>
</bean>
</constructor-arg>
<constructor-arg index="1">
<bean class="redis.clients.jedis.JedisPoolConfig">
<property name="maxIdle" value="#{redis['redis.MaxIdle']}" />
<property name="testOnBorrow" value="true" />
<property name="testOnReturn" value="true" />
<!-- 新版jedis 不支持这个参数了 -->
<!-- <property name="maxWait" value="#{redis['redis.MaxWait']}" /> -->
<!-- <property name="maxActive" value="#{redis['redis.MaxActive']}" /> -->
</bean>
</constructor-arg>
</bean>
</beans>
redis.properties
#A string containing whitespace or comma separated host or IP addresses and port numbers of the form "host:port host2:port" or "host:port, host2:port".
redis.sentinel1=redis01.public.test.baozun.cn:26379
redis.sentinel2=redis02.public.test.baozun.cn:26379
redis.sentinel3=redis03.public.test.baozun.cn:26379
redis.mastername=testenv
redis.timeout=1000
redis.MaxIdle=60000
#新版jedis 不支持这个参数了
#redis.MaxActive=50
#redis.MaxWait=5000
redis.keystart=gowilddev
启动
报了新错
Caused by: redis.clients.jedis.exceptions.JedisDataException: ERR Unsupported CONFIG parameter: notify-keyspace-events
at redis.clients.jedis.Protocol.processError(Protocol.java:117)
at redis.clients.jedis.Protocol.process(Protocol.java:151)
at redis.clients.jedis.Protocol.read(Protocol.java:205)
at redis.clients.jedis.Connection.readProtocolWithCheckingBroken(Connection.java:297)
at redis.clients.jedis.Connection.getStatusCodeReply(Connection.java:196)
at redis.clients.jedis.Jedis.configSet(Jedis.java:2612)
at org.springframework.data.redis.connection.jedis.JedisConnection.setConfig(JedisConnection.java:633)
... 25 more
什么鬼,参见 ERR Unsupported CONFIG parameter: notify-keyspace-events
看来我是使用新的jedis 连接了老版本的redis集群
服务器上面的 redis 版本
找运维组重新搭建 redis新版本的集群环境
[vmuser@test01 ~]$ redis-cli --version
redis-cli 3.2.4
由于采用了新版的集群技术,所以我们只能使用 RedisClusterConfiguration
2.2 RedisClusterConfiguration
2.2.1 3主3从 Cluster服务端配置
我们先看看运维组兄弟配置的集群情况
[vmuser@test01 ~]$ /home/vmuser/redis-3.2.4/src/redis-trib.rb check 10.88.21.31:10000
可以看到是官网推荐的标准的 3主 3从
方案,参见 官方文档 http://redisdoc.com/topic/cluster-tutorial.html
10.88.21.31:10000 | 10.88.22.25:10001 |
10.88.22.25:10000 | 10.88.21.31:10002 |
10.88.21.31:10001 | 10.88.22.25:10002 |
2.2.2 spring配置
这时我们可以使用 org.springframework.data.redis.connection.RedisClusterConfiguration
,注意 since spring-data-redis
1.7
<?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:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p" xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
">
<context:annotation-config />
<util:properties id="redis" location="classpath:redis-cluster.properties"></util:properties>
<!-- RedisHttpSessionConfiguration -->
<bean class="org.springframework.session.data.redis.config.annotation.web.http.RedisHttpSessionConfiguration" />
<!--JedisConnectionFactory -->
<bean class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
<constructor-arg index="0">
<bean class="org.springframework.data.redis.connection.RedisClusterConfiguration">
<constructor-arg index="0">
<set>
<!-- slave -->
<!-- <value>10.88.22.25:10001</value>
<value>10.88.21.31:10002</value>
<value>10.88.22.25:10002</value> -->
<!-- master -->
<value>10.88.21.31:10000</value>
<value>10.88.22.25:10000</value>
<value>10.88.21.31:10001</value>
</set>
</constructor-arg>
<!-- 一般当此值设置过大时,容易报:Too many Cluster redirections -->
<!-- <property name="maxRedirects">3</property> -->
</bean>
</constructor-arg>
<constructor-arg index="1">
<bean class="redis.clients.jedis.JedisPoolConfig">
<property name="maxIdle" value="#{redis['redis.jedisPoolConfig.MaxIdle']}" />
<property name="testOnBorrow" value="#{redis['redis.jedisPoolConfig.testOnBorrow']}" />
<property name="testOnReturn" value="#{redis['redis.jedisPoolConfig.testOnReturn']}" />
<!-- 新版jedis 不支持这个参数了 -->
<!-- <property name="maxWait" value="#{redis['redis.jedisPoolConfig.MaxWait']}" /> -->
<!-- <property name="maxActive" value="#{redis['redis.jedisPoolConfig.MaxActive']}" /> -->
</bean>
</constructor-arg>
</bean>
</beans>
此时,我们仅需要配置 master 到 RedisClusterConfiguration
中,系统会自动分配
上面配置可以提取精炼到配置文件中
<?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:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p" xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
">
<context:annotation-config />
<util:properties id="redis" location="classpath:redis-cluster.properties"></util:properties>
<!-- RedisHttpSessionConfiguration -->
<bean class="org.springframework.session.data.redis.config.annotation.web.http.RedisHttpSessionConfiguration" />
<!--JedisConnectionFactory -->
<bean class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
<constructor-arg index="0">
<!-- since spring-data-redis 1.7 -->
<bean class="org.springframework.data.redis.connection.RedisClusterConfiguration">
<constructor-arg index="0">
<set>
<value>#{redis['redis.redisClusterConfiguration.clusters']}</value>
</set>
</constructor-arg>
<!--
用于 redis.clients.jedis.JedisCluster.JedisCluster(Set<HostAndPort>, int, int, GenericObjectPoolConfig) 第三个参数 maxRedirections
默认值是5
一般当此值设置过大时,容易报:Too many Cluster redirections
-->
<property name="maxRedirects" value="#{redis['redis.redisClusterConfiguration.maxRedirects']}" />
</bean>
</constructor-arg>
<constructor-arg index="1">
<bean class="redis.clients.jedis.JedisPoolConfig">
<property name="maxIdle" value="#{redis['redis.jedisPoolConfig.MaxIdle']}" />
<property name="testOnBorrow" value="#{redis['redis.jedisPoolConfig.testOnBorrow']}" />
<property name="testOnReturn" value="#{redis['redis.jedisPoolConfig.testOnReturn']}" />
<!-- 新版jedis 不支持这个参数了 -->
<!-- <property name="maxWait" value="#{redis['redis.jedisPoolConfig.MaxWait']}" /> -->
<!-- <property name="maxActive" value="#{redis['redis.jedisPoolConfig.MaxActive']}" /> -->
</bean>
</constructor-arg>
</bean>
</beans>
redis-cluster.properties
#############for org.springframework.data.redis.connection.RedisClusterConfiguration###################
#只需要配置 master
#理论上只需要配置一个节点即可,配置多个是为了防止单个节点挂掉,
redis.redisClusterConfiguration.clusters=10.88.21.31:10000,10.88.22.25:10000,10.88.21.31:10001
#用于 redis.clients.jedis.JedisCluster.JedisCluster(Set<HostAndPort>, int, int, GenericObjectPoolConfig) 第三个参数 maxRedirections
#默认值是5
#一般当此值设置过大时,容易报:Too many Cluster redirections
redis.redisClusterConfiguration.maxRedirects=3
###########for redis.clients.jedis.JedisPoolConfig##############################
redis.jedisPoolConfig.MaxIdle=60000
redis.jedisPoolConfig.testOnBorrow=true
redis.jedisPoolConfig.testOnReturn=true
#新版jedis 不支持这个参数了
#redis.jedisPoolConfig.MaxActive=50
#redis.jedisPoolConfig.MaxWait=5000
#redis.keystart=gowilddev
启动
成功没有报错
2.2.3 为什么标准的 3主 3从
方案,我们 clusterNodes
仅配置了 3个 master?
- 首先配置多个是为了防止单个节点挂掉,理论上只需要配置一个节点即可
- 至于为什么不配置slave节点,参见 https://github.com/spring-projects/spring-data-examples spring data 示例中也只配置了master
2.2.4 关于 RedisClusterConfiguration
中的 maxRedirects
属性
重试次数,在执行失败后,进行的重试次数,默认是5, 参见 https://www.zybuluo.com/SailorXiao/note/159072#解读
主要用于 org.springframework.data.redis.connection.jedis.JedisConnectionFactory.createCluster(RedisClusterConfiguration, GenericObjectPoolConfig)
构造 redis.clients.jedis.JedisCluster.JedisCluster(Set, int, int, GenericObjectPoolConfig) 使用的
源码:
/**
* Creates {@link JedisCluster} for given {@link RedisClusterConfiguration} and {@link GenericObjectPoolConfig}.
*
* @param clusterConfig must not be {@literal null}.
* @param poolConfig can be {@literal null}.
* @return
* @since 1.7
*/
protected JedisCluster createCluster(RedisClusterConfiguration clusterConfig, GenericObjectPoolConfig poolConfig) {
Assert.notNull("Cluster configuration must not be null!");
Set<HostAndPort> hostAndPort = new HashSet<HostAndPort>();
for (RedisNode node : clusterConfig.getClusterNodes()) {
hostAndPort.add(new HostAndPort(node.getHost(), node.getPort()));
}
int redirects = clusterConfig.getMaxRedirects() != null ? clusterConfig.getMaxRedirects().intValue() : 5;
if (StringUtils.hasText(getPassword())) {
throw new IllegalArgumentException("Jedis does not support password protected Redis Cluster configurations!");
}
if (poolConfig != null) {
return new JedisCluster(hostAndPort, timeout, redirects, poolConfig);
}
return new JedisCluster(hostAndPort, timeout, redirects, poolConfig);
}
一般当此值设置过大时,容易报:Too many Cluster redirections
3.问题
3.1 spring-session>1.2.2.RELEASE 不兼容 spring-data-redis > 1.7.4.RELEASE
目前 spring-session
最新版本是 1.2.2.RELEASE
,内置依赖 spring-data-redis
版本是 1.7.1.RELEASE
而目前 spring-data-redis
最新版本是 1.7.4.RELEASE
尝试升级 spring-data-redis
>1.7.4.RELEASE
启动报异常
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionRedisTemplate' defined in class path resource [org/springframework/session/data/redis/config/annotation/web/http/RedisHttpSessionConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.springframework.core.serializer.support.DeserializingConverter.<init>(Ljava/lang/ClassLoader;)V
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1514)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:191)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:921)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:864)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:779)
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:817)
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:745)
... 38 more
Caused by: java.lang.NoSuchMethodError: org.springframework.core.serializer.support.DeserializingConverter.<init>(Ljava/lang/ClassLoader;)V
at org.springframework.data.redis.serializer.JdkSerializationRedisSerializer.<init>(JdkSerializationRedisSerializer.java:53)
at org.springframework.data.redis.core.RedisTemplate.afterPropertiesSet(RedisTemplate.java:119)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1573)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1511)
... 49 more
4.参考
- 使用Spring Data Redis操作Redis(一)
- Why 2.7 JedisPoolConfig not Compatible with 2.1 JedisPoolConfig
- ERR Unsupported CONFIG parameter: notify-keyspace-events
- http://redisdoc.com/topic/cluster-tutorial.html
- https://github.com/spring-projects/spring-data-examples/tree/master/redis/cluster
--to be continued
相关推荐
web服务部署多个,nginx反向代理,其中要实现session共享,采用spring-session的redis集群存储方案 mysql主从复制,读写分离 3技术要点 后端: spring-boot、spring-session、spring-security等全家桶 dubbo + ...
web服务部署多个,nginx反向代理,其中要实现session共享,采用spring-session的redis集群存储方案 mysql主从复制,读写分离 3技术要点 后端: spring-boot、spring-session、spring-security等全家桶 dubbo + ...
data-redis|[lettuce,redis,session redis,YAML配置,连接池,对象存储](https://github.com/smltq/spring-boot-demo/blob/master/data-redis/HELP.md) quartz|[Spring Scheduler,Quartz,分布式调度,集群,mysql持久化...
技术发展到今天, 集群/负载均衡已经变的相对简单了. 下面用通俗的语言给刚入门的同学介绍下这两个概念: 某KFC开业时只有一个点餐窗口(一台Tocmat服务器, 可以节约成本)对外提供点餐服务. 应对日常点餐没有问题, 当饭...
Redis是一个key-value存储系统,是当下互联网公司常用的NoSQL数据库之一,是进入互联网行业的Java开发工程师必备技术。 在本课程中,你将了解Redis是什么、能干什么...5 Redis集群实现Tomcat集群的Session共享等......
4. 修改 spring-elasticsearch 文件,配置自己的ElasticSearch集群设置 5. 如果需要自定义一些配置可以修改 spring-mybatis.xml 文件 6. 代码生成在Test的com.ssrs.mp.TestGenerator 按照注释修改配置即可。
job集群:创建job、取消job、查询job、下拉搜索spring bean 数据源监控:druid 接口swagger文档 日志查询 邮件管理:发送邮件、搜索邮件 文件管理:上传文件、文件列表、文件删除 公告管理:公告未读提醒、...
- chapter9-1-4:[Spring Cloud构建微服务架构(四)分布式配置中心](http://blog.didispace.com/springcloud4/) - chapter9-1-5:[Spring Cloud构建微服务架构(五)服务网关]...
Redis(REmote DIctionary Server)是一个key-value存储系统,是当下互联网公司最常用的NoSQL数据库之一,是进入互联网行业的Java开发工程师必备技术。... 5 Redis集群实现Tomcat集群的Session共享等
为实现Web应用的分布式集群部署,要解决登录session的统一。本文利用shiro做权限控制,redis做session存储,结合spring boot快速配置实现session共享。
4. 修改 spring-elasticsearch 文件,配置自己的ElasticSearch集群设置 5. 如果需要自定义一些配置可以修改 spring-mybatis.xml 文件 6. 代码生成在Test的com.ssrs.mp.TestGenerator 按照注释修改配置即可。 软件...
redis:Nosql数据库,搭配shiro的会话管理功能将session存入redis中,实现tomcat多服务器集群的session共享 nginx:反向代理服务器,用来调度多台tomcat h2:内存数据库,用于测试 开发环境 ==== jdk...
缓存:redis集群,使用spring-data-redis 图片存储:fastDFS集群 网页静态化:freemarker 单点登录:cas 权限管理:SpringSecurity, 跨域:cros 支付:微信扫描 短信验证:阿里大于 密码加密:BCrypt 富文本:...
本教程为授权出品 Redis是一个key-value存储系统,是当下互联网公司常用的NoSQL数据库之一,是进入互联网行业的Java开发工程师必备技术。在本课程中,你将了解... 5 Redis集群实现Tomcat集群的Session共享等......
Spring session | 分布式Session管理 | [http://projects.spring.io/spring-session/](http://projects.spring.io/spring-session/) MyBatis | ORM框架 | [http://www.mybatis.org/mybatis-3/zh/index.html]...
+ 熔断机制 + eureka + 单元测试(controller、service、mapper层) + redis集群集成练习 + redis操作练习 + fastDFS集成练习 + 全局拦截器 + 定时器配置 + 定时器任务设计[线程池+分布式锁] +关闭挂钩 + 单例应用 + ...
springMvc4.3+spring4.3+mybatis3.4+shiro1.4+log4j2+freemarker2.3+shiro-redis2.9
# 集群模式,如有配置,将优先使用集群 fat.redis.cluster.nodes=x.x.x.x:x,x.x.x.x:x # zookeeper服务器地址 fat.zookeeper.host=x.x.x.x:x,x.x.x.x:x # zookeeper活跃时间 fat.zookeeper.sessionTimeout=x.x.x.x:...
支持多实例集群,分布式锁,spring cache 整合,session集群,消息队列,对象存储。redisson是java支持redis的redlock的唯一实现, 集成该项目后只需要极少的配置.就能够使用redisson的全部功能. 目前支持 集群模式,云托管...
Maven Spring(IOC DI AOP 声明式事务处理) SpringMVC(支持Restful风格) Hibernate Validate(参数校验) Mybatis(最少配置方案) ...Tomcat集群(Redis共享Session) Sping Shiro权限控制(待完善)