ServiceStack PooledRedisClientManager 故障转移如何工作? [英] How does ServiceStack PooledRedisClientManager failover work?

查看:41
本文介绍了ServiceStack PooledRedisClientManager 故障转移如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据 git commit 消息,ServiceStack 最近添加了故障转移支持.我最初认为这意味着我可以关闭我的一个 Redis 实例,我的池客户端管理器将优雅地处理故障转移并尝试连接我的备用 Redis 实例之一.不幸的是,我的代码出了问题并说它无法与初始 Redis 实例连接.

According to the git commit messages, ServiceStack has recently added failover support. I initially assumed this meant that I could pull one of my Redis instances down, and my pooled client manager would handle the failover elegantly and try to connect with one of my alternate Redis instances. Unfortunately, my code just bugs out and says that it can't connect with the initial Redis instance.

我目前正在 Windows 上运行 Redis 2.6.12 实例,主端口位于 6379,从端口位于 6380,设置了哨兵以在主节点出现故障时自动将从节点提升为主节点.我目前正在像这样实例化我的客户经理:

I am currently running instances of Redis 2.6.12 on a Windows, with the master at port 6379 and a slave at 6380, with sentinels set up to automatically promote the slave to a master if the master goes down. I am currently instantiating my client manager like this:

PooledRedisClientManager pooledClientManager =
    new PooledRedisClientManager(new string[1] { "localhost:6379"},
        new string[1] {"localhost:6380"});

其中第一个数组是读写主机(对于master),第二个数组是只读主机(对于slave).

where the first array is read-write hosts (for the master), and the second array is read-only hosts (for the slave).

当我在 6379 端口终止主站时,哨兵将从站提升为主站.现在,当我尝试运行我的 C# 代码时,它不会故障转移到端口 6380,而是简单地中断并返回错误无法连接到 localhost:6379 处的 redis 实例".

When I terminate the master at port 6379, the sentinels promote the slave to a master. Now, when I try to run my C# code, instead of failing over to port 6380, it simply breaks and returns the error "could not connect to redis Instance at localhost:6379".

有没有办法解决这个问题,或者故障转移不会按照我想要的方式工作?

Is there a way around this, or will failover simply not work the way I want it to?

推荐答案

PooledRedisClientManager.FailoverTo 允许您重置哪些是读/写主机,哪些是只读主机,并重新启动工厂.这允许快速转换而无需重新创建客户端.

PooledRedisClientManager.FailoverTo allows you to reset which are the read/write hosts, vs readonly hosts, and restart the factory. This allows for a quick transition without needing to recreate clients.

这篇关于ServiceStack PooledRedisClientManager 故障转移如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆