Skip to content

Useful cluster commands for Redis Cluster

homepage-banner

Cluster

// Print information about the cluster.
CLUSTER INFO

// List all nodes in the cluster, along with their information.
CLUSTER NODES

Nodes

// Add the node at ip:port to the cluster.
CLUSTER MEET <ip> <port>

// Remove the node with node_id from the cluster.
CLUSTER FORGET <node_id>

// Configure the current node to replicate from the node with node_id.
CLUSTER REPLICATE <node_id>

// Save the cluster configuration to disk.
CLUSTER SAVECONFIG

// Assign one or more slots to the current node.
CLUSTER ADDSLOTS <slot> [slot ...]

// Remove one or more slots from the current node.
CLUSTER DELSLOTS <slot> [slot ...]

// Remove all slots assigned to the current node, turning it into a node without any assigned slots.
CLUSTER FLUSHSLOTS

// Assign slot to the node with node_id.
CLUSTER SETSLOT <slot> NODE <node_id>

// Migrate slot from the current node to the node with node_id.
CLUSTER SETSLOT <slot> MIGRATING <node_id>

// Import slot from the node with node_id to the current node.
CLUSTER SETSLOT <slot> IMPORTING <node_id>

// Cancel the import or migration of slot.
CLUSTER SETSLOT <slot> STABLE

Keys

// Calculate the slot for key.
CLUSTER KEYSLOT <key>

// Return the number of key-value pairs in the slot.
CLUSTER COUNTKEYSINSLOT <slot>

// Return count keys from slot.
CLUSTER GETKEYSINSLOT <slot> <count>

// Return a list of slaves for a master node.
CLUSTER SLAVES node-id

Reference

  • https://redis.io/commands#cluster
Leave a message







Disclaimer
  • Welcome to visit the knowledge base of SRE and DevOps!
  • License under CC BY-NC 4.0
  • Made with Material for MkDocs and improve writing by generative AI tools
  • Copyright issue feedback me#imzye.com, replace # with @