Redis 主/从复制 - 单点故障?
如何在零停机的情况下升级到较新版本的 Redis? Redis 从站是只读的,因此您似乎必须关闭主站,并且在您等待它重新加载数据库时,您的站点将处于只读状态 45 秒或更长时间。
有办法解决这个问题吗?
How does one upgrade to a newer version of Redis with zero downtime? Redis slaves are read-only, so it seems like you'd have to take down the master and your site would be read-only for 45 seconds or more while you waited for it to reload the DB.
Is there a way around this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Redis 团队对此
核心步骤有非常好的文档:
完整文档:
无需停机即可升级或重新启动 Redis 实例
Redis Team has very good documentation on this
Core Steps:
Full Documentation:
Upgrading or restarting a Redis instance without downtime
当节点离线时,使用 SLAVEOF 命令将从节点提升为主节点,然后当你将其重新上线时,将其设置为从节点,它将从在线节点复制所有数据。
您可能还需要确保您的客户端可以适当地处理更改/丢失的主节点。
如果您想真正变得更奇特,您可以设置您的客户端,以便在检测到写入主服务器的错误时升级从服务器。
When taking the node offline, promote the slave to master using the SLAVEOF command, then when you bring it back online you set it up as a slave and it will copy all data from the online node.
You may also need to make sure your client can handle changed/missing master nodes appropriately.
If you want to get really fancy, you can set up your client to promote a slave if it detects an error writing to the master.
您可以使用 Redis Sentinel 来执行此操作,哨兵会自动将从站提升为新的主站。
您可以在这里找到更多信息http://redis.io/topics/sentinel。
Sentinel是一个用于管理redis服务器的系统,它持续监控redis master和slave,每当master宕机时,它会自动将slave提升为master。当旧主站启动时,它将成为新主站的从站。
这里不会有停机时间或需要手动配置配置文件。
您可以访问上面的链接以了解如何为您的 Redis 服务器配置哨兵。
You can use Redis Sentinel for doing this, the sentinel will automatically promote a slave as new master.
you can find more info here http://redis.io/topics/sentinel.
Sentinel is a system used to manage redis servers , it monitors the redis master and slaves continuously, and whenever a master goes down it will automatically promote a slave in to master. and when the old master is UP it will be made as slave of the new master.
Here there will be no downtime or manual configuration of config file is needed.
You can visit above link to find out how to configure sentinel for your redis servers.
请注意,您可能需要检查并设置以下配置才能写入您的从站。
(“从 Redis 2.6 开始,默认从站是只读的”)
-- 示例
Note, you may have to check and set the following config to write to your slave.
("Since Redis 2.6 by default slaves are read-only")
-- Example