CLUSTER SLOTS
CLUSTER SLOTS
- Group
- Cluster
- Complexity
- O(N) where N is the number of slot ranges
- Arity
- 2 (exactly, counting the command name)
- HotKV Cloud
- All plans
- On-Premise
- no license needed
CLUSTER SLOTS returns the cluster’s slot map: each range of consecutive
slots served by one primary, with that primary and its replicas. Many
cluster clients read it at startup and after a -MOVED redirect. Newer
clients can use CLUSTER SHARDS instead.
Only replicas that can serve reads are listed: a replica marked as failed, or one that has not finished its first sync, is left out.
Return value
Section titled “Return value”An array of ranges. Each range is an array:
- Start slot (integer).
- End slot (integer).
- The primary, then one entry per replica. Each node is an array of:
- its endpoint (bulk string), as
cluster-preferred-endpoint-typechooses: the IP address, the hostname, or nil (RESP2) / null (RESP3) withunknown-endpoint, - its client port (integer), the TLS port when you are connected over TLS,
- its node ID (bulk string),
- its other addresses:
ipwhen the endpoint is not the IP, andhostnamewhen the node has one and the endpoint is not the hostname, thenavailability-zonewhen the node has anavailability-zonesetting. A map in RESP3, a flat array of pairs in RESP2 (empty when there is nothing to add).
- its endpoint (bulk string), as
The address and port of a node are the ones it announces to clients:
cluster-announce-client-ipv4 and cluster-announce-client-port when it has
them, which can differ from the address the nodes use among themselves.
With cluster mode off, the reply is an empty array.
Examples
Section titled “Examples”127.0.0.1:6379> CLUSTER SLOTS1) 1) (integer) 0 2) (integer) 5460 3) 1) "10.0.0.1" 2) (integer) 6379 3) "b4240bf759694b9ba85b3b5efd51785b86261c3e" 4) (empty array) 4) 1) "10.0.0.4" 2) (integer) 6379 3) "80c69623243ebb98309adbe1d4c95f7857e37c2c" 4) (empty array)2) 1) (integer) 5461 2) (integer) 10922 3) 1) "10.0.0.2" 2) (integer) 6379 3) "0e2a97d798979a2e3e5e7f940e2ac533fb36b69b" 4) (empty array) 4) 1) "10.0.0.5" 2) (integer) 6379 3) "a406ec695ab17e4f731d29cd54e36d4ce81e2c65" 4) (empty array)3) 1) (integer) 10923 2) (integer) 16383 3) 1) "10.0.0.3" 2) (integer) 6379 3) "db0203ba69a674ed0b0cde72c4dfcecc846ed307" 4) (empty array) 4) 1) "10.0.0.6" 2) (integer) 6379 3) "087d5d8db5c8df0f3152afcd17b94d5879f9107f" 4) (empty array)A node started with --availability-zone zone-a, --cluster-announce-hostname host0.example.com, --cluster-announce-client-ipv4 10.0.0.1 and
--cluster-announce-client-port 7000 is listed like this (the address and port
are the announced client ones, and the map holds the hostname and the zone):
127.0.0.1:7005> CLUSTER SLOTS1) 1) (integer) 0 2) (integer) 16383 3) 1) "10.0.0.1" 2) (integer) 7000 3) "7a28581ffafcbe156e07d2e0fc7107eb808e2f1f" 4) 1) "hostname" 2) "host0.example.com" 3) "availability-zone" 4) "zone-a"Compatibility
Section titled “Compatibility”Same layout as Redis 7 and Valkey 8, including the endpoint and the extra
address map. The availability-zone entry is Valkey 8.1’s.
See also
Section titled “See also”CLUSTER SHARDS, CLUSTER NODES, CLUSTER KEYSLOT
In a cluster: Cluster clients
Was this page helpful?
Thanks for the feedback.