redis:处理故障转移?

发布于 2024-09-06 15:21:18 字数 420 浏览 2 评论 0原文

Redis 看起来确实是一个很棒的产品,具有内置的复制功能和惊人的速度。经过测试,感觉绝对像是 2010 年 memcached 的替代品。

然而,由于通常使用 memcached 时,会使用一致的哈希来将数据均匀地分布在池中的服务器上。如果池中的一台服务器出现故障并停止访问,则会以透明方式对其进行处理,并且只会重新创建丢失的密钥,并将其均匀分布在池中剩余的可用服务器上。

另一方面,Redis 也有内置的分片,而且还有另一个非常有趣的功能,称为自动复制。正因为如此,数据的可用性可以大大提高,同时利用从属服务器在发生故障时使用。

但是,我还没有找到任何好的解决方案来处理自动将 Redis 服务器的从属服务器状态更改为新的主服务器或通过任何其他方式自动处理 Redis 的故障转移。

这怎么可能做到呢?对此适当的方法是什么?

Redis really seems like a great product with the built in replication and the amazing speed. After testing it out, it feels definitely like the 2010 replacement of memcached.

However, since when normally using memcached, a consistent hashing is being used to evenly spread out the data across the servers in a pool. If one of the servers in the pool goes down and stops being accessible, it is being handled transparently and only the keys that were lost will be recreated and evenly distributed across the remaining available servers in the pool.

Redis has on the other hand also built-in sharding, but also another really interesting feature called automatic replication. Thanks to that, availability of the data could be greatly increased while utilizing slave servers to use in the event of the shit hitting the fan.

However, I have yet not found any good solution to handle changing a redis server's status as a slave to become a new master automatically or by any other way automatically handling the failover with Redis.

How could this be done? What would be an appropriate approach to this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

默嘫て 2024-09-13 15:21:18

但是,由于通常使用 memcached 时,会使用一致的哈希来将数据均匀分布在池中的服务器上。如果池中的一台服务器出现故障并停止访问,则会以透明方式对其进行处理,并且只会重新创建丢失的密钥,并将其均匀分布在池中剩余的可用服务器上。

这不是 memcached 所做的,客户端库正在完成所有这些魔法;)

但是,我还没有找到任何好的解决方案来处理将 Redis 服务器的从属服务器状态自动更改为新的主服务器,或通过任何其他方式自动处理 Redis 的故障转移。

使用 SlaveofCommand 更改特征。自动故障转移将需要更多的编码,连接到服务器,如果您断开连接并且在 X 时间内无法再次建立连接,则选择一个从服务器作为主服务器,并更改所有其他服务器的从主状态。

更新(2012年8月1日):现在有redis Sentinel,一个监控以及 2.4.16 及更高版本的自动故障转移解决方案。

However, since when normally using memcached, a consistent hashing is being used to evenly spread out the data across the servers in a pool. If one of the servers in the pool goes down and stops being accessible, it is being handled transparently and only the keys that were lost will be recreated and evenly distributed across the remaining available servers in the pool.

This is not what memcached does, the client library is doing all this magic ;)

However, I have yet not found any good solution to handle changing a redis server's status as a slave to become a new master automatically or by any other way automatically handling the failover with Redis.

Use the SlaveofCommand to change the characteristics. Automatic failover will need a bit more coding, connect to the server and if you loose the connection and can't establish it again for a time X then choose one slave to be master and change the slave-master-status of all other servers.

Update (01. Aug. 2012): There's now redis sentinel, a monitoring and automatic failover solution for version 2.4.16 and higher.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文