-
Notifications
You must be signed in to change notification settings - Fork 354
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[QUESTION] RedisCluster Class surports multiple ip address At initialization? #317
Comments
Hi @HHcamel, You could (and probably should) use There are however other ways to handle masters that are down, but your design/architecture must be done in such a way that you can use this. For instance, if your workers would use Hope this helped. |
Hi, @wingunder , Thank you for your help! |
Hi @HHcamel,
or
I cannot explain how
Your second sentence, above, is hard to understand, but I'll try to explain. You now have one of two choices:
Regards |
@HHcamel You only need to ensure that the configured node is alive when So, normally there's no need to set multiple addresses at initialization. Regards |
@wingunder In fact, we don't need to use Redis Sentinel to do failover for nodes in Redis Cluster, since Redis Cluster will do the failover by the nodes in the cluster. Redis Sentinel is used for failover of standalone deployment of Redis. Regards |
Hi @sewenew,
Yes, you're right. Sentinel can be used for finding healthy Redis nodes (regardless if it is a clustered or non-clustered set of Redis servers), and this is what I was trying to explain. If the app is connected to a healthy master and it goes down so catastrophically, that you lose your connection, you can't just re-connect, as that host:port is down. In this case, you could use Sentinel to connect to a healthy master or slave. |
@wingunder If RedisCluster already connects to the cluster, it works normally even if the node is gone. Because it will get the new master address from other nodes in the cluster, and connects to this new master. As you mentioned in the comments, it does not reconnect to the old master. When working with standalone deployment of Redis, Redis Sentinel works exactly as you mentioned. However, I don’t think Redis sentinel can be used to monitor nodes in Redis Cluster. Since both sentinel and the cluster itself will do failover, and that might cause conflict, e.g. they might elect different new masters. And this is what I wanted to explain :) Regards |
HI, @sewenew , |
Hi @sewenew
Interestingly enough, I tried this out last month and I could successfully run Redis Sentinel that monitors a Redis Cluster. I have not had problems with Sentinel trying to failover the cluster, as I set the timeouts for sentinel to be long enough, so that the cluster can do the failover first. Once the failover is done, by the cluster, Sentinel is happy again and does nothing. The nice thing is however, that one can get info on the masters in the cluster, via Sentinel. For example: redis-cli -h hostname -p 7100 sentinel masters | grep -A1 -e name -e flags -we port I'm aware that one can also call redis-cli -h hostname -p 7000 -c cluster nodes The Sentinel solution for monitoring a Redis Cluster could be seen as an overhead, but this is an independent and easy way to find out the host:port and status of all masters of a Redis Cluster. One can also log (or monitor) what happens to nodes under certain conditions, by subscribing to the Sentinel events. This, I found very handy and much easier than trying to monitor what happens in a Redis Cluster. As far as I know, with Redis Cluster, one cannot subscribe to cluster events, as this does not exists. |
@HHcamel Yes, that's a potential problem. In that case, So far, you can try @wingunder's solution, i.e. using a properly configured Redis Sentinel to get the master node address. Regards |
@wingunder It's a very nice idea by setting the failover timeout long enough, to avoid failover conflict! This looks like a hidden feature, since no document mentioned this deployment. The only problem is that we have to carefully configure the sentinel to have a longer timeout than Redis Cluster. It should be better, if Redis Sentinel has built-in support for disabling failover. Regards |
Hi @sewenew,
Yes, you're right. Documenting this and making it official, as well as adding a flag to disable quora-polling and fail-overs, could be a nice enhancement to Sentinel, but this task/request needs to be sent to https://github.com/redis/redis. I have limited time, but will check what I can do. Regards |
Hi @sewenew , @wingunder , Thank you for your answers and help! |
Following up on this issue to mention native support for multiple initialization addresses would be amazing! It may be possible to handle this in our app logic, but definitely adds some overhead to the initialization process compared to other language Redis clients. (e.g. the ideal case is I can provide a list of addresses to the cluster client constructor and if one of those nodes happens to be down at init time, redisplusplus will try alternative nodes in the list till it can make the initial connection). Thank you for considering! |
HI,
In cluster mode, if the Node with the configured IP address is down, other nodes are normal. In this case, RedisCluster is initialized with the configured IP address. Can RedisCluster be used normally?
Example as follows:
Thanks for your answer and help.
The text was updated successfully, but these errors were encountered: