The multiple rdb files are from different redis servers. Now I want to combine the data files to a single redis server. By far I only find the answers to recover with a single dump.rdb file.
Starting from Redis 6.0 DEBUG RELOAD
redis-cli
command got a new NOSAVE
option that will ingest data from an RDB file (without overwriting it with memory dump and without the need to stop redis-server
).
DEBUG RELOAD [MERGE] [NOFLUSH] [NOSAVE]
Save the RDB on disk and reload it back in memory. By default it will save the RDB file and load it back.
With the
NOFLUSH
option the current database is not removed before loading the new one, but conficts in keys will kill the server with an exception.When
MERGE
is used, conflicting keys will be loaded (the key in the loaded RDB file will win).When
NOSAVE
is used, the server will not save the current dataset in the RDB file before loading.Use
DEBUG RELOAD NOSAVE
when you want just to load the RDB file you placed in the Redis working directory in order to replace the current dataset in memory.Use
DEBUG RELOAD NOSAVE NOFLUSH MERGE
when you want to add what is in the current RDB file placed in the Redis current directory, with the current memory content.Use
DEBUG RELOAD
when you want to verify Redis is able to persist the current dataset in the RDB file, flush the memory content, and load it back.",
The above is taken from debug.c
, applied friendly format (see debug.c source for Redis 7.0).
So, use DEBUG RELOAD NOSAVE NOFLUSH
if you want to ensure there are no duplicate keys in different RDBs. Use DEBUG RELOAD NOSAVE NOFLUSH MERGE
if you know you have duplicates, load last the one you want to prevail.
Caution: versions of Redis earlier than 6.0 (without the NOSAVE option, see debug.c source for Redis 5.0) DEBUG RELOAD
always began by overwriting the file with memory dump, an example of a silent fail, because redis-cli
would accept any non-existing options after DEBUG RELOAD
, not just "probable" ones such as NOSAVE
but also completely contrived, such as NOSAVING FAILS IN REDIS50
).