-
Notifications
You must be signed in to change notification settings - Fork 43
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
Feature request for using hostname to move and connect to individual node in cluster mode #239
Comments
Good point. CLUSTER SLOTS shows hostnames too when set to preferred, but there it replaces the IP if I remember correctly. Did you try to configure hiredis-cluster to use CLUSTER SLOTS instead of NODES, to check if it uses the hostnames in this case? Regarding IP and NAT-ing, it's also possible configure the NAT-ed IP addresses using cluster-announce-ip. They will be returned to clients. |
then the assumption is the nodes can use the NAT-ed IPs for intra-cluster communication. redis/redis#7460 There is a feature request for what you are suggesting. but until then, having the client support hostnames gets around this issue. and these hostnames/FQDN's are mapped to the NAT-ed IP Address. |
We're not relying on Redis updates anymore because it is no longer open source. Valkey, the open source fork of Redis, has this new config in the upcoming 8.0 release, added in the PR valkey-io/valkey#736:
These IP addresses, if configured, will be reported to clients in CLUSTER SLOTS and similar commands, but they are not used for intra-cluster communication. I think this is what you need in this NAT situation, right? |
Yes, but when cluster-preferred-endpoint-type is set to 'ip', then MOVED and ASK return the IP, even if cluster-announce-hostname is set.
...
I'm not sure. If we connect to a hostname but MOVED still returns IP addresses, we need to know which connection corresponds to the IP address too, so I think we should parse IP and hostname, so we can handle all possible configurations. @bjosv Do you know if we can handle hostnames in CLUSTER SLOTS? |
you have a point. you need both IP and hostname to handle all configurations. and thanks for sharing valkey-io/valkey#736 , this is exactly what I was looking for ! |
Enabling the client to send CLUSTER SLOTS should help you since we support hostnames in CLUSTER SLOTS. You can enable CLUSTER SLOTS with |
Context:
Starting from redis 7.x. two new properties cluster-preferred-endpoint-type and cluster-announce-hostname properties have been added. When cluster-preferred-endpoint-type is set to hostname, Moved and Ask responses contain the hostnames.
When cluster-announce-hostname is set, cluster nodes outputs the hostname along with the Ip. https://redis.io/docs/latest/commands/cluster-nodes/
cluster nodes output:
07c37dfeb235213a872192d90877d0cd55635b91 127.0.0.1:30004@31004,hostname4 slave e7d1eecce10fd6bb5eb35b9f99a514335d9ba9ca 0 1426238317239 4 connected
Problem:
When the nodes in the cluster have announced hostnames. hiredis-cluster should parse the hostnames instead of IPs from cluster nodes output and connect to the nodes via hostnames.
By default, hiredis-cluster runs cluster nodes and uses the IPs to make connections to the individual nodes. This integration will not work when the nodes are behind a proxy/NAT gateway, thus, we are expecting that when cluster-preferred-endpoint-type is set to hostname, on moving and connecting to a different node hiredis-cluster will use hostname instead of IP.
Solution:
Suggesting hiredis-cluster to make connections via hostnames if available and default to IPs if not present
The text was updated successfully, but these errors were encountered: