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.
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.
The simplest way to do this is by using DEBUG RELOAD, an undocumented command.
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
NOFLUSHoption the current database is not removed before loading the new one, but conficts in keys will kill the server with an exception.When
MERGEis used, conflicting keys will be loaded (the key in the loaded RDB file will win).When
NOSAVEis used, the server will not save the current dataset in the RDB file before loading.Use
DEBUG RELOAD NOSAVEwhen 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 MERGEwhen you want to add what is in the current RDB file placed in the Redis current directory, with the current memory content.Use
DEBUG RELOADwhen 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.
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.