-
-
Notifications
You must be signed in to change notification settings - Fork 93
Description
Hi,
I am looking for the best way to export a full redis-cluster to a single redis instance.
I know: rmt is able to sync a (given) cluster node to a single redis.
I also know that rmt is able to fetch the list of CLUSTER NODES and get only the masters with their IPs and Ports, because it's presumably what -m does, otherwise it would not work without the cluster.conf
AFAIK, there is no good/short/clean way to get the cluster masters into a bash list.
look how ugly it would be, to sync all keys from all cluster masters into a single redis:
HOSTS=$(redis-cli -a ${REDIS_DEST_PASS} -h ${REDIS_DEST} -p ${REDIS_DEST_PORT} -c cluster nodes | grep master | awk '{ print $2 }' | cut -f1 -d'@')
for HOST in $HOSTS
do
rmt -s redis://default:${REDIS_DEST_PASS}@${HOST} -m redis://${REDIS_STAGE} -r -d 0
done
This works, but I'm curious if you could
- provide a command to output the list of cluster masters in a cleaner approach,
and possibly, - implement this loop (i mean, the complete sync/migration) with
rmt, like this:
rmt -s redis://default:password@AnyClusterMember:Port -m redis://Target-Single-Redis:Port -r
I think, rmt should safely be able to always check if the source is a cluster or not and proceed to work as "expected"
where in case source is a single, proceed as usual.
in case its a cluster, fetch the masters, and loop over them repeating the usual bgsave and dump to target. This should seemlessly work, even if the target is also a cluster