重定向到从站
REDIS是否有内置机制,当master宕机时会使用slave? 我可以使用虚拟 IP 定向到主站吗?当主站宕机时,是否可以定向到从站?
根据文档:
elect the slave to master using the SLAVEOF NO ONE command, and shut down your master.
但是应用程序如何知道更改后的 IP?
mysql 有一个名为 MMM(带监视器的主主复制)的第三方实用程序。 REDIS 有这样的实用程序吗?
Does REDIS has built-in mechanism that will use slave when master is down?
Can I use virtual IP to direct to master and when Master is down is it possible to direct to slave?
As per the documentaion:
elect the slave to master using the SLAVEOF NO ONE command, and shut down your master.
But how the application will know about the changed IP?
mysql has a third party utility that is called MMM (master master replication with monitor). Is there such an utility for REDIS?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在负载均衡器中使用虚拟 IP,尽管这不是内置于 Redis 中的。任何优质的硬件或软件负载平衡器都应该能够做到这一点。例如,您可以使用“balance”或HAProxy 位于 VIP 前面,并使用脚本或规则来检查 Redis 实例的状态,以了解哪个是主实例,并将其设置为负载均衡器 (LB) 中的目标。
走这条路线将需要一台或多台额外的服务器(或虚拟机,具体取决于您的设置),但它会为您提供一种配置,让客户端与单个 IP 通信,并且不知道他们需要与后端的哪台服务器通信。如何更新与哪个服务器通信的 LB 取决于您使用的 LB。幸运的是,他们都不需要了解或处理 Redis 协议。他们只是在平衡一个端口。
当我走这条路线时,我会选择 Slave-VIP 和 Master-VIP。 Slave-VIP 在所有 Redis 实例之间进行负载均衡,而 Master-VIP 仅启用当前的 Master。如果您的写入负载非常重,您可以将当前的 master 排除在 Slave-VIP 池之外。否则我会把它留在里面;这样就无需对 Slave-VIP 池进行故障转移更新。
You can use a virtual IP in a load balancer, though this is not built in to Redis. Any quality hardware or software load balancer should be able to do it. For example you can use "balance" or HAProxy to front the VIP and use a script or rules that checks the status of Redis instances to see which is master and sets that as the destination in the load balancer (LB).
Going this route would require one or more additional servers (or VMs depending on your setup) but it would provide you with a configuration that has clients talking to a single IP and being clueless about which server they need to talk to on the back end. How you update the LB with which server to talk to is dependent on what LB you use. Fortunately, none of them would need to know or handle the Redis protocol; they are just balancing a port.
When I go this route I go with a Slave-VIP and a Master-VIP. The slave-VIP load balances across all Redis instances, whereas the Master-VIP only has the current master enabled. If your write load is very heavy you can leave the current master out of the Slave-VIP pool. Otherwise I would leave it in; that eliminates the need for failover updating of the Slave-VIP pool.