简体   繁体   中英

redis cluster url notation in configuration

What's the supposedly commonly used notation for accessing a redis cluster URL in a linux config file? A regular such URL looks something like

 url = redis://<password>@<ip>:<port>

so an example would be

url = redis://secret@1.2.3.4:6379

Trying that out on a cluster gets cryptic errors

redis.exceptions.ResponseError: MOVED 6553 <newip>:<port>
tooz.ToozError

But I can't find, anywhere on the internet, what to do if you have more than one node. The documentation refers to something called 'sentinel' and suggests doing something like;

url = redis://<ip>:<sentinel port>?sentinel=<master name>&sentinel_fallback=<ip2>:<sentinel port>&<sentinel_fallback>=<ip3>:<sentinel port> 

which seems patently absurd. Where's the password? (Hint: this just produces 'permission denied' as-is) What in the world is the "master name"? It does not make any sense. There's N instances (with N = XY, where X is our number of replicas, X >= 2, and Y is the number of shards, Y >= 3), resulting in N >= 6. There's at least 3 nodes, so at least 3 sentinels. Each instance has its own 'name', so there's 6 of those master names. Wildly guessing that can be replaced by @ and using that gets me even more cryptic errors.

tooz.coordination.ToozConnectionError: No master found for <name>








 

The Tooz Redis Driver only supports Redis Sentinel.

The actual driver source code states:

 - Consistent, note that this is still restricted to only one redis server, without the recently released redis (alpha) clustering > 1 server will not be consistent when partitions or failures occur (even redis clustering docs state it is not a fully AP or CP solution, which means even with it there will still be *potential* inconsistencies). - Master/slave failover (when setup with redis `sentinel`_), giving some notion of HA (values *can* be lost when a failover transition occurs).

You are trying to use Redis Cluster , in which case you can have only the primary as connected host.

The error message you got MOVED 6553 is saying that the key you tried to access is in another primary (in an other shard).

Redis Cluster clients usually require only one host:port to be pointed to, and they use CLUSTER SLOTS command to discover the cluster topology. This is not implemented in the Tooz Driver.

Consider switching to Redis Sentinel if you have to use Tooz and require high availability.

Here is more on Redis sentinel vs clustering

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM