如何从多个 RDB 文件中恢复 Redis
How to Recover Redis from Multiple RDB Files
多个rdb文件来自不同的redis服务器。现在我想将数据文件合并到单个 redis 服务器。到目前为止,我只能找到使用单个 dump.rdb 文件恢复的答案。
最简单的方法是使用 DEBUG RELOAD
,一个未记录的命令。
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.",
以上内容摘自debug.c
,采用友好格式。
因此,如果要确保不同 RDB 中没有重复键,请使用 DEBUG RELOAD NOSAVE NOFLUSH
。使用 DEBUG RELOAD NOSAVE NOFLUSH MERGE
如果您知道自己有重复项,请最后加载您想要的那个。
多个rdb文件来自不同的redis服务器。现在我想将数据文件合并到单个 redis 服务器。到目前为止,我只能找到使用单个 dump.rdb 文件恢复的答案。
最简单的方法是使用 DEBUG RELOAD
,一个未记录的命令。
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.",
以上内容摘自debug.c
,采用友好格式。
因此,如果要确保不同 RDB 中没有重复键,请使用 DEBUG RELOAD NOSAVE NOFLUSH
。使用 DEBUG RELOAD NOSAVE NOFLUSH MERGE
如果您知道自己有重复项,请最后加载您想要的那个。