CLUSTER MYSHARDID

Since 1.1.0Cluster

Syntax

CLUSTER MYSHARDID

Returns the ID of this node's shard: the master and its replicas, which hold the same slots. Use it to tell which nodes belong together, for example to group the nodes of CLUSTER NODES by shard.

In KiviDB the shard ID is the master's node ID: a master returns its own CLUSTER MYID, and a replica returns its master's. So it changes when a replica takes over: after a failover, both nodes of the shard return the new master's ID. In Redis a shard has an ID of its own, which master and replicas share and which stays the same across failovers.

Reply

The shard ID, 40 hexadecimal characters, as a string.

Errors

  • ERR This instance has cluster support disabled: the server is not a cluster node.

Examples

On a master, then on its replica:

> CLUSTER MYID
"74cea35fa9a656f033023e9f6cb3d78ef2b1a95a"
> CLUSTER MYSHARDID
"74cea35fa9a656f033023e9f6cb3d78ef2b1a95a"
> CLUSTER MYID
"95dc5ee672adb953ccc7fe76c427f5083b7c9b4b"
> CLUSTER MYSHARDID
"74cea35fa9a656f033023e9f6cb3d78ef2b1a95a"

After CLUSTER FAILOVER on the replica, both return "95dc5ee672adb953ccc7fe76c427f5083b7c9b4b".