【问题标题】:How Redis Cluster connection using redis plus plus ensures connection consistency in case the corresponding node shuts downRedis Cluster连接使用redis plus plus如何在对应节点关闭的情况下保证连接一致性
【发布时间】:2022-02-11 08:45:21
【问题描述】:

使用redis plus plus连接Redis Cluster如何在对应节点关闭的情况下保证连接一致性?

https://github.com/sewenew/redis-plus-plus#redis-cluster 中的文档指出“您只需在 ConnectionOptions 中设置一个主节点的主机和端口,RedisCluster 将自动获取其他节点的信息(使用 CLUSTER SLOTS 命令)”

如果用于创建连接的IP和端口在建立连接后莫名其妙地宕机了,并且相应的slave被Redis自动升级为master,redis-plus-plus会处理这个问题吗?或者我们可能会出现错误?

【问题讨论】:

    标签: redis redis-cluster


    【解决方案1】:

    是的,redis-plus-plus 会处理这个问题。

    RedisCluster构造成功后,会通过CLUSTER SLOTS命令获取所有节点的IP和端口。此外,如果集群拓扑发生变化,例如master down, new master elected, redis-plus-plus automatically updates the info.

    但是,旧的主人之间有一个时间窗口,而新的主人则被选举产生。在这种情况下,如果您的命令被发送到损坏的 master,您将得到异常。 Everything will remove to normal, once the new master is elected.

    【讨论】:

      猜你喜欢
      • 2022-11-07
      • 2017-08-06
      • 1970-01-01
      • 2021-02-06
      • 1970-01-01
      • 2019-06-02
      • 1970-01-01
      • 1970-01-01
      • 2022-06-16
      相关资源
      最近更新 更多