Redis的故障转移StackExchange /哨兵从C# [英] Redis failover with StackExchange / Sentinel from C#

查看:744
本文介绍了Redis的故障转移StackExchange /哨兵从C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们目前正在使用Redis的2.8.4和StackExchange.Redis(和喜欢它),但是没有任何种类的硬件故障等,此刻的保护。我试图让该解决方案的工作,由此我们有主/从站和定点监测,但不能完全得到那里,我无法找到搜索后,任何真正的指针。



所以,目前我们已经走到这一步:



我们必须在每个节点上3 Redis的服务器和定点(设置由Linux人):
devredis01: 6383(主)
devredis02:6383(从)
devredis03:6383(从)
devredis01:26379(定点)
devredis02:26379(定点)
devredis03: 26379(定点)



我能够在StackExchange客户端连接到Redis的服务器和读/写,并验证数据被跨使用Redis的桌面上所有的Redis实例复制经理。



我也可以连接到使用不同的ConnectionMultiplexer定点服务,查询配置,要求主Redis的节点,请奴隶等。



我们也可以杀死主redis的节点并验证一个奴隶的晋升为掌握和复制到其他从继续工作。我们可以观察到Redis的连接尝试重新连接到主,并且如果我重新创建ConnectionMultiplexer我可以写/再次读到升班马主机和从机读取。



到目前为止好!



我缺少位是你如何把它一起在生产系统中?



我应该得到来自定点Redis的端点,并使用2 ConnectionMultiplexers?
究竟做我必须做的检测节点已经下降?
能StackExchange自动为我做这做它传递事件,所以我可以重新我的Redis ConnectionMultiplexer?
我应该处理为connectionFailed事件,然后重新连接,以使ConnectionMuliplexer找出新的主是什么?
推测,当我重新连接的任何尝试写会丢失?



我希望我不是失去了一些东西很明显这里我只是奋力扑救它一起。



在此先感谢!


解决方案

我刚问到这个问题时,发现了类似的问题你和我,我相信回答了在当前主下山怎么做我们的代码(客户端)现在知道这是新的主服务器上的问题吗?



如何分辨其中新Redis的主站使用Sentinel

显然,你只需要订阅和收听从哨兵事件。有道理..我只是有一个更精简的方式。



我看了一些关于Twemproxy为Linux充当代理,并可能做到这一点的吗?但是我当时在Redis的用于Windows和试图找到一个Windows选项。我们可能只是转移到Linux中,如果是这样的批准方式,它应该做的事。


We're currently using Redis 2.8.4 and StackExchange.Redis (and loving it) but don't have any sort of protection against hardware failures etc at the moment. I'm trying to get the solution working whereby we have master/slaves and sentinel monitoring but can't quite get there and I'm unable to find any real pointers after searching.

So currently we have got this far:

We have 3 redis servers and sentinel on each node (setup by the Linux guys): devredis01:6383 (master) devredis02:6383 (slave) devredis03:6383 (slave) devredis01:26379 (sentinel) devredis02:26379 (sentinel) devredis03:26379 (sentinel)

I am able to connect the StackExchange client to the redis servers and write/read and verify that the data is being replicated across all redis instances using Redis Desktop Manager.

I can also connect to the sentinel services using a different ConnectionMultiplexer, query the config, ask for master redis node, ask for slaves etc.

We can also kill the master redis node and verify that one of the slaves is promoted to master and replication to the other slave continues to work. We can observe the redis connection trying to reconnect to the master, and also if I recreate the ConnectionMultiplexer I can write/read again to the newly promoted master and read from the slave.

So far so good!

The bit I'm missing is how do you bring it all together in a production system?

Should I be getting the redis endpoints from sentinel and using 2 ConnectionMultiplexers? What exactly do I have to do to detect that a node has gone down? Can StackExchange do this for me automatically or does it pass an event so I can reconnect my redis ConnectionMultiplexer? Should I handle the ConnectionFailed event and then reconnect in order for the ConnectionMuliplexer to find out what the new master is? Presumably while I am reconnecting any attempts to write will be lost?

I hope I'm not missing something very obvious here I'm just struggling to put it all together.

Thanks in advance!

解决方案

I just asked this question, and found a similar question to yours and mine which I believe answers the question of how does our code (the client) know now which is the new master server when the current master goes down?

How to tell a Client where the new Redis master is using Sentinel

Apparently you just have to subscribe and listen to events from the Sentinels. Makes sense.. I just figured there was a more streamlined way.

I read something about the Twemproxy for Linux which acts as a proxy and probably does this for you? But I was on redis for Windows and was trying to find a Windows option. We might just moved to Linux if that's the approved way it should be done.

这篇关于Redis的故障转移StackExchange /哨兵从C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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