简体   繁体   English

在主从配置中使用Spring @EnableRedisHttpSession

[英]Using Spring @EnableRedisHttpSession with master-slave configuration

I have a Spring Cloud based application with multiple backend Spring-Boot servers. 我有一个基于Spring Cloud的应用程序,带有多个后端Spring-Boot服务器。 The servers are all sharing their session with a single Redis server via @EnableRedisHttpSession. 这些服务器都通过@EnableRedisHttpSession与单个Redis服务器共享会话。

I now have a requirement for failover support of Redis in production, which means I will have to setup a master-slave configuration (I guess...). 现在,我需要在生产环境中支持Redis的故障转移,这意味着我将必须设置主从配置(我想...)。

How will I configure Http Session replication via Redis to be aware of the two servers? 如何通过Redis配置Http Session复制以了解这两个服务器? I could not find any documentation on this. 我找不到与此有关的任何文档。 Note that I am not using Spring Data Redis here, just the Spring Session support for Redis. 请注意,我在这里没有使用Spring Data Redis,仅是Spring Session对Redis的支持。

Spring Session Redis uses Spring Data Redis to integrate with Redis and so you can use Redis Sentinel (see http://redis.io/topics/sentinel ). Spring Session Redis使用Spring Data Redis与Redis集成,因此您可以使用Redis Sentinel(请参阅http://redis.io/topics/sentinel )。 To give you the full picture: 为您提供完整的图片:

Redis allows managed (Redis Sentinel) and unmanaged Master-Slave setups. Redis允许托管(Redis Sentinel)和非托管主从设置。 Unmanaged setups provide no failover whereas Sentinel managed setups failover the master node once it's down. 非托管设置不会提供故障转移,而Sentinel托管设置会在主节点关闭后进行故障转移。 Redis Sentinel monitors all master/slave nodes and once a master is not available, a slave will be promoted to a new master. Redis Sentinel监视所有主节点/从节点,一旦主节点不可用,从节点将被提升为新的主节点。

You can configure Spring Data Redis for Sentinel usage with following properties: 您可以使用以下属性来配置用于Sentinel的Spring Data Redis:

  • spring.redis.sentinel.master : name of the master node. spring.redis.sentinel.master :主节点的名称。
  • spring.redis.sentinel.nodes : Comma delimited list of host:port pairs. spring.redis.sentinel.nodes :以逗号分隔的host:port对列表。

or you provide an own RedisConnectionFactory bean. 或者您提供自己的RedisConnectionFactory bean。 See Spring Data Redis docs for further details. 有关更多详细信息,请参见Spring Data Redis文档。

HTH, Mark HTH,马克

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 spring 启动时的主从配置,@Transactional(readOnly = true) 未按预期工作 - Master-slave configuration on spring boot, @Transactional(readOnly = true) not working as expected Java Master-Slave中的套接字 - Sockets in Java Master-Slave 如何以主从模式将任务从主机传递到从机 - How to pass a task from master to slave in master-slave pattern 如何将JMeter(主从)的端口配置到防火墙 - How to configure ports of JMeter(Master-Slave) to firewall 在春季批处理远程分区中,我们可以将主配置和从配置配置为单个配置,并将其作为单个程序运行 - In spring batch remote partitioning can we have the master and slave configuration as a single configuration and run it as a single program 什么是一个很好的基于Java的主从通信机制? - What's a good Java-based Master-Slave communication mechanism? Jenkins Master和Slave配置Linux到AIX - Jenkins Master and Slave configuration linux to AIX 配置c3p0连接池的Mysql主从复制中偶尔会遇到到slave的通信链接失败 - Facing Communication link failure to slave occasionally in Mysql master-slave replication configured with c3p0 connection pooling 如何启用 activemq Rest Api 以支持使用共享存储的主/从配置 - How to enable the activemq Rest Api to support a Master/Slave configuration using a shared storage spring数据redis主从配置 - spring data redis master slave config
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM