Skip to content
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

Will hostnames be supported ? #2186

Closed
jichilee opened this issue Dec 4, 2014 · 24 comments · Fixed by #9530
Closed

Will hostnames be supported ? #2186

jichilee opened this issue Dec 4, 2014 · 24 comments · Fixed by #9530

Comments

@jichilee
Copy link

jichilee commented Dec 4, 2014

I see "Hostnames are not supported. IPs only." in Redis-trib by using hostnames fails to join cluster #2071, I want to know if hostnames will be supported?
Sometime the IPs are not the best way.

@antirez
Copy link
Contributor

antirez commented Dec 19, 2014

Here the feature request is not clear since there is something that may be supported, and something that may be never supported:

  1. Possibly supported: redis-trib resolving names provided, but configuring the cluster using IPs.
  2. Never going to be supported in the short timeframe: Redis Cluster itself registering node addresses as hostnames.

However about 2 note that Redis Cluster is able to detect addresses switches of nodes and auto-reconfigure.

@baptistedonaux
Copy link

What's the feature's state ? Thx

@allanwax
Copy link

@antirez Could you explain more about 'However about 2 note that Redis Cluster is able to detect addresses switches of nodes and auto-reconfigure' and how if all nodes in the cluster have new addresses, how this would be communicated to the other nodes. The problem I see is that while any particular node can examine its nodes.conf file and detect the change, the ip addresses of the other nodes in the nodes.conf file are invalid and communicating with them will fail. Is there some other underlying mechanism for walking the network to detect other cluster nodes on it and check to see if any of them (based upon their id) have changed?

@badboy
Copy link
Contributor

badboy commented Jul 30, 2015

@allanwax It won't work if all of them change their address, exactly because then no node knows how to reach another node. But it works if one node changes its address and connects to an existing node.

@olljanat
Copy link

olljanat commented Oct 2, 2018

@antirez time is going forward and world is changing so I just wanted to check that is this still the case or would it be possible finally get hostnames support to Redis?

Never going to be supported in the short timeframe: Redis Cluster itself registering node addresses as hostnames.

I'm trying to make Redis Cluster working on Docker Swarm. Initial connection actually works already using hostnames (or Docker service names actually) but then Redis will update IP addresses to config files. I really would like to avoid setting up static IPs for these containers.

@drnybble
Copy link

@olljanat You can use the announce-ip option and supply the Virtual IP of the service

@martin-wong
Copy link

martin-wong commented Mar 21, 2019

@olljanat You can use the announce-ip option and supply the Virtual IP of the service

@drnybble Should i fill the announce-ip with the Virtual IP ? But how could i get the VIP before creating service?

@drnybble
Copy link

Use a bash script to perform a lookup on the hostname and then once it resovles, launch redis. Beware though that sometimes the hostname will not resolve right away you should do this in a sleep loop. Example:

# Resolve hostnames to IPs so redis doesn't get confused
if [ -n "$ANNOUNCE_IP" ]; then
  # Seems that hostname does not resolve right away so try a few times
  for i in $(seq 1 10); do
    RESOLVED_IP=$(getent hosts $ANNOUNCE_IP | awk '{print $1}')
    if [ -n "$RESOLVED_IP" ]; then
      ANNOUNCE_IP=$RESOLVED_IP
      break;
    fi  
    sleep 1
  done
fi

@martin-wong
Copy link

@drnybble Thanks for your answer. And i have another question. I have tried to run redis cluster (3 masters and 3 slaves ,as 6 service ) on docker swarm using the VIP of service and everything goes well. When i stop one node of the redis cluster , swarm will start a new instance of service automaticlly. But i still have to use the command redis-cli --cluster add-node xxx yyy in order to make the new instance joining the redis cluster .
So what's the difference between using container ip and VIP ?

@allanwax
Copy link

@martin-wong This seems like odd behavior but I'm not an docker guy, I run on bar metal. What is supposed to happen is that you set up a cluster using redis-trib and specify 3 masters and 3 slaves. They are set up to talk to each other. Upon the failure of a master the assigned slave for that master takes over.

You shouldn't have to add-node since its already there. Possibly the cluster was not set up properly. Easy check redis-cli -c -h host -p port cluster info. You should see three masters and three slaves each slave referencing the master it's a slave of. If you don't see this the cluster was not up up properly.

@olljanat
Copy link

olljanat commented Apr 2, 2019

@olljanat You can use the announce-ip option and supply the Virtual IP of the service

That is good tip and actually I noticed that it actually works now with service names too. Redis Sentinel updates service IPs to configs but as they are static as long they exists you don't need fill them manually.

@itamarhaber
Copy link
Member

/cc @artix75

@ra-coder
Copy link

ra-coder commented Nov 5, 2019

need this feature for cluster in docker swarm (without it only dirty haks allow to make cluster)

@marcinma
Copy link

same for Kubernetes cluster. Doing manual step for retrieving IP's for pods is no-go in cloud automated setup. It is 2020 , resolving hostname shouldn't be functionality that need 6 years to develop...

@dmitrypol
Copy link

any updates on this? adding cluster nodes by hostnames would enable so that clients can connect via the same hostname.

@itamarhaber
Copy link
Member

Cc'ing @yossigo as he's fond of hostnames :)

@madolson
Copy link
Contributor

madolson commented Jan 5, 2021

@dmitrypol Are people asking for hostnames in cluster mode, or specifically for redis-trib?

@dmitrypol
Copy link

dmitrypol commented Jan 5, 2021

@madolson - the use case I am thinking of is when users want to connect to nodes via FQDN / hostnames. It would be nice if redis-cluster replied with the hostnames in node map so that client can make connection that way.
Yes, introducing hostnames creates dependency on DNS resolution but it can be an option to redis-cli --cluster create command to specify either IPs or hostnames.

@madolson
Copy link
Contributor

madolson commented Jan 5, 2021

Related to this: #8134

Which is that we want to expose the hostnames in cluster slots for TLS, for hostname validation, but I don't see a reason why we couldn't do that. @dmitrypol Do you actually use the cluster nodes command, or the recommend cluster slots? We were originally not going to update cluster nodes.

I intend to follow up with this in the next 1-2 weeks, after I finish my current thing.

@dmitrypol
Copy link

Ideally it would be nice to have full class support for hostnames in all aspects of Redis Cluster.

@liuchong
Copy link

liuchong commented Jan 12, 2021

It is still not supported... 😹 @liuchong

@smallersoup
Copy link

It is still not supported... 😹

@madolson
Copy link
Contributor

This a draft PR up now with a proposal, anyone waiting on that feature, would appreciate you taking a look to provide input.
#9530

@raphaelauv
Copy link

It work with the redis 7 rc3 -> redis:7.0-rc3-bullseye

 >>> Performing hash slots allocation on 6 nodes...
 Master[0] -> Slots 0 - 5460
 Master[1] -> Slots 5461 - 10922
 Master[2] -> Slots 10923 - 16383
 Adding replica redis-replica-2:6379 to redis-main-1:6379
 Adding replica redis-replica-3:6379 to redis-main-2:6379
 Adding replica redis-replica-1:6379 to redis-main-3:6379
 M: 42c3d7791b335649a2f422556251a8494728f4e2 redis-main-1:6379
    slots:[0-5460] (5461 slots) master
 M: da686f8b341f01ee17f1bef411356e9f2619080d redis-main-2:6379
    slots:[5461-10922] (5462 slots) master
 M: dfac266643ecef91d72a5692a3dba2e6db911bc6 redis-main-3:6379
    slots:[10923-16383] (5461 slots) master
 S: 91fd1aed9e744bf5ff7d9ddf58b98630ae4c9b92 redis-replica-1:6379
    replicates dfac266643ecef91d72a5692a3dba2e6db911bc6
 S: 716099d47c2ae19bd566daa84a9d87b8b26c4429 redis-replica-2:6379
    replicates 42c3d7791b335649a2f422556251a8494728f4e2
 S: e2988cc4ec32c8ac6135f9a7f0f4f1463f926d4e redis-replica-3:6379
    replicates da686f8b341f01ee17f1bef411356e9f2619080d
 Can I set the above configuration? (type 'yes' to accept): >>> Nodes configuration updated
 >>> Assign a different config epoch to each node
 >>> Sending CLUSTER MEET messages to join the cluster
 Waiting for the cluster to join
 .
 >>> Performing Cluster Check (using node redis-main-1:6379)
 M: 42c3d7791b335649a2f422556251a8494728f4e2 redis-main-1:6379
    slots:[0-5460] (5461 slots) master
    1 additional replica(s)
 S: 716099d47c2ae19bd566daa84a9d87b8b26c4429 172.24.0.6:6379
    slots: (0 slots) slave
    replicates 42c3d7791b335649a2f422556251a8494728f4e2
 S: 91fd1aed9e744bf5ff7d9ddf58b98630ae4c9b92 172.24.0.7:6379
    slots: (0 slots) slave
    replicates dfac266643ecef91d72a5692a3dba2e6db911bc6
 S: e2988cc4ec32c8ac6135f9a7f0f4f1463f926d4e 172.24.0.5:6379
    slots: (0 slots) slave
    replicates da686f8b341f01ee17f1bef411356e9f2619080d
 M: da686f8b341f01ee17f1bef411356e9f2619080d 172.24.0.4:6379
    slots:[5461-10922] (5462 slots) master
    1 additional replica(s)
 M: dfac266643ecef91d72a5692a3dba2e6db911bc6 172.24.0.8:6379
    slots:[10923-16383] (5461 slots) master
    1 additional replica(s)
 [OK] All nodes agree about slots configuration.
 >>> Check for open slots...
 >>> Check slots coverage...
 [OK] All 16384 slots covered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.