Migrate Redis with multiples databases from non cluster to cluster

0

Hello,

We have a redis in elasticache in non cluster mode which contains 2 databases. We want to migrate to use multi az but redis elasticache in cluster mode or serverless are not compatible with RDB file which contains multiple redis databases. I'm not an expert with redis but it seems that it is not possible to dump only a database or delete only a database. Is there a common way to migrate from the old redis to new redis in cluster mode or serverless when the current backup contains multiple databases ?

thanks

asked 2 months ago106 views
2 Answers
1

You can't restore a Redis backup (.rdb) file containing multiple databases to an ElastiCache (cluster mode enabled) cluster. This is by design - "Redis Cluster does not support multiple databases like the standalone version of Redis. We only support database 0; the SELECT command is not allowed" - Redis Cluster Spec

If you wish to move a a cluster running multiple databases to a Cluster Mode Enabled (CME) or Serverless ElastiCache, then it is recommended to modify the Keyspace to migrate data from all the databases to one single database (db0). If you wish to migrate multiple keys with a single call use the MIGRATE command. You can also use MOVE command if only a few keys need to be moved between databases.

AWS
answered a month ago
0
  • To migrate from the existing Redis instance with multiple databases to ElastiCache Redis in cluster mode, here are the steps:
  • Take a backup of the existing Redis instance using the `redis-cli command. This will create an RDB file containing data from all databases.
  • Launch a new ElastiCache Redis cluster in cluster mode. The cluster should have sufficient number of nodes based on your data size.
  • Restore the RDB backup file into database 0 of one of the nodes. This will populate the cluster with data.
  • Modify your application code to use the new ElastiCache cluster endpoint and handle sharding of keys across nodes. You may need to restructure your data if keys were previously partitioned across multiple databases.
  • Gradually migrate traffic from the existing Redis instance to the new ElastiCache cluster once validation is complete.
  • Delete the existing non-clustered Redis instance once migration is fully complete.
profile picture
EXPERT
answered 2 months ago
  • hello,

    Thanks for your answer, but the elasticache in cluster mode does not accept to load a dump with multiples databases :

    You can't restore from a Redis (cluster mode disabled) cluster to a Redis (cluster mode enabled) cluster if the .rdb file references more than one database. Attempting to do this results in the following error: Error: To restore a snapshot in cluster mode, all keys in the RDB file should reside in DB 0. source : https://repost.aws/knowledge-center/elasticache-restore-cluster-from-s3

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions