9

How do I tell StackExchange.Redis (v1.0.481) that it's about to connect to a Redis cluster (v3.2.6, in case it matters), and not just a standalone/replicated instance? When I use the redis-cli for example, I have to pass a -c flag to make it cluster-aware. Is there an equivalent flag in the StackExchange.Redis connection string?

I've searched for and come across several examples of connection strings that include multiple comma-separated host:port parameters, but nothing that explicitly makes StackExchange.Redis cluster-aware.

Thanks.

user7295971
  • 91
  • 1
  • 1
  • 2

1 Answers1

10

If you have a cluster, you will connect to the cluster no matter if you put one or more endpoints on the connection string. There is no flag to connect to a cluster.

Putting more than one endpoint on your connection string is good for High Availability, so if one of the nodes is down, you'll be able to start the connection to other node.

The internal list of nodes is updated and expanded automatically. You don't need to put all the endpoints on the connection string.

Check this issue for more details.

thepirat000
  • 12,362
  • 4
  • 46
  • 72
  • is your answer still accurate for client v1.2.6? – chester89 Mar 20 '18 at 18:40
  • but what if I have 3 master nodes with 3 slave nodes and each of them has different password? where can I pass these password? – Niklaus Wirth Dec 12 '18 at 07:20
  • 2
    @NiklausWirth AFAIK, you must use the same password in all the cluster servers. Check [this](https://trodzen.wordpress.com/2017/02/09/redis-cluster-with-passwords/) – thepirat000 Dec 12 '18 at 16:02
  • @thepirat000 as you said, it is good for HA to bring more endpoint to connectionString, and we dont need put all the endpoits. . first we should put all master and slaves address or just put Masters? for ex u have 3 master and 3 slave nodes which endpoint u put in ur connection string? – pmn Dec 19 '20 at 14:23
  • @pejman I would suggest putting all master nodes in the cs, or use envoy as a proxy. Think of it this way... you have three(3) master nodes and each of them have a slave(replica). You have a master node failure, and your replica failsover the master node, now one of your master node ips has changed, but your cs has the other two, so you will still be able to discover the new master from them. Hope this helps your understanding of HA. – Edd Feb 08 '21 at 15:05