2

My redis cluster is borked. One node seems to think it's a 3-node cluster with no replication, another node seems to think it's alone, and the third node agrees with the first. I want to have a 3-node cluster with 2 replicated nodes (no splitting).

I don't want to have to figure out how to un-bork my redis cluster, instead: I want to start over.

The existing question How do I delete everything in Redis? doesn't include clusters, for which everything is way more complicated.

Desired result: Clean installation. No cluster config.

Unfortunately simply reinstalling the whole program appears insufficient. How do I tell it to really --yes-I-am-really-sure forget everything about itself and all the other nodes it knows? In particular:

  • Remove all non-config-file-cluster-configuration.

The command CLUSTER FORGET gets me partway there, but nodes can't forget themselves? Why not? Anyway, somehow convincing them to do that might be enough.

aphid
  • 1,135
  • 7
  • 20

1 Answers1

3

The difficult part is in realizing these three things:

  1. There's both redis-cli CLUSTER and redis-cli --cluster, and the cluster commands are randomly divided between the two.
  2. When usingredis-cli --cluster for something involving two nodes, the -a password parameter must be provided twice, both before and after the --cluster part. The one provided after is for the target node, the one provided before is for the 'config' node.
  3. Commands using redis CLUSTER only apply to one node, so must be repeated for each node. (They cannot access the other nodes)

Knowing this, we can proceed wiping the necessary things:

 redis-cli -h host01 -a password CLUSTER NODES

prints a list of nodes with long identifiers. Proceed with

# forget about the other nodes in the cluster on each node
redis-cli -h host01 -a password1 CLUSTER FORGET <host02 key> 
redis-cli -h host01 -a password1 CLUSTER FORGET <host03 key> 

redis-cli -h host02 -a password2 CLUSTER FORGET <host01 key> 
redis-cli -h host02 -a password2 CLUSTER FORGET <host03 key> 

redis-cli -h host03 -a password3 CLUSTER FORGET <host01 key> 
redis-cli -h host03 -a password3 CLUSTER FORGET <host02 key> 
# flush all data so that the node can be reset
redis-cli -h host01 -a password1 FLUSHALL
redis-cli -h host02 -a password2 FLUSHALL
redis-cli -h host03 -a password3 FLUSHALL
# reset the node 
redis-cli -h host01 -a password1 CLUSTER RESET
redis-cli -h host02 -a password2 CLUSTER RESET
redis-cli -h host03 -a password3 CLUSTER RESET
aphid
  • 1,135
  • 7
  • 20