5

I'm trying to create a Redis cluster using an RDB file taken from a single-instance Redis server. Here is what I've tried:

#! /usr/bin/env bash
for i in 6000 6001 6002 6003
do
  redis-server --port $i --cluster-config-file "node-$i.cconf" --cluster-enabled yes --dir "$(pwd)" --dbfilename dump.rdb &
done

That script starts up 4 Redis processes that are cluster enabled. It also initializes each node with the dump file.

Then I run redis-trib.rb so that the 4 nodes can find each other:

redis-trib.rb create 127.0.0.1:6000 127.0.0.1:6001 127.0.0.1:6002 127.0.0.1:6003

I get the following error:

>>> Creating cluster
[ERR] Node 127.0.0.1:6060 is not empty. Either the node already knows other nodes (check with CLUSTER NODES) or contains some key in database 0.

I've also tried a variant where only the first node/process is initialized with the RDB file and the others are empty. I can join the 3 empty nodes into a cluster but not the one that's pre-populated with data.

What is the correct way to import a pre-existing RDB file into a Redis cluster?

In case this is an "X-Y problem" this is why I'm doing this:

I'm working on a migration from a single-instance Redis server to an Elasticache Redis Cluster (cluster mode enabled). Elasticache can easily import an RDB file on cluster startup if you upload it to S3. But it takes a long time for an Elasticache cluster to start. To reduce the feedback loop as I test my migration code, I'd like to be able to start a cluster locally also.

I've also tried using the create-cluster utility, but that doesn't appear to have any options to pre-populate the cluster with data.

Jay
  • 3,471
  • 4
  • 35
  • 49

0 Answers0