Feature Request: rmt sync from cluster to single redis
sgohl opened this issue · 1 comments
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
Hi
This is a good idea.
But we need to consider more about how we handle master switch to replica. and how other CLI command add cluster support.
- provide a command to output the list of cluster masters in a cleaner approach,
and possibly,
yes. we can add above command to get cluster masters and do more than that : provide a series commands to manage all cluster nodes.
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
if we provide that command can get cluster masters. users can wirte their own shell to loop masters.