Useful cluster commands for Redis Cluster
集群
// 打印集群的信息
CLUSTER INFO
// 列出集群当前已知的所有节点(node),以及这些节点的相关信息。
CLUSTER NODES
节点
// 将 ip 和 port 所指定的节点添加到集群当中,让它成为集群的一份子。
CLUSTER MEET <ip> <port>
// 从集群中移除 node_id 指定的节点。
CLUSTER FORGET <node_id>
// 将当前节点设置为 node_id 指定的节点的从节点。
CLUSTER REPLICATE <node_id>
// 将节点的配置文件保存到硬盘里面。
CLUSTER SAVECONFIG
// 将一个或多个槽(slot)指派(assign)给当前节点。
CLUSTER ADDSLOTS <slot> [slot ...]
// 移除一个或多个槽对当前节点的指派。
CLUSTER DELSLOTS <slot> [slot ...]
// 移除指派给当前节点的所有槽,让当前节点变成一个没有指派任何槽的节点。
CLUSTER FLUSHSLOTS
// 将槽 slot 指派给 node_id 指定的节点。
CLUSTER SETSLOT <slot> NODE <node_id>
// 将本节点的槽 slot 迁移到 node_id 指定的节点中。
CLUSTER SETSLOT <slot> MIGRATING <node_id>
// 从 node_id 指定的节点中导入槽 slot 到本节点。
CLUSTER SETSLOT <slot> IMPORTING <node_id>
// 取消对槽 slot 的导入(import)或者迁移(migrate)。
CLUSTER SETSLOT <slot> STABLE
键
// 计算键 key 应该被放置在哪个槽上。
CLUSTER KEYSLOT <key>
// 返回槽 slot 目前包含的键值对数量。
CLUSTER COUNTKEYSINSLOT <slot>
返回 count 个 slot 槽中的键。
CLUSTER GETKEYSINSLOT <slot> <count>
// 返回一个master节点的slaves 列表
CLUSTER SLAVES node-id
Reference: https://redis.io/commands#cluster
Disclaimer
- License under
CC BY-NC 4.0
- Copyright issue feedback
me#imzye.me
, replace # with @ - Not all the commands and scripts are tested in production environment, use at your own risk
- No privacy information is collected here