如何将redis更改为持久性

如何将redis更改为持久性,redis,Redis,我使用的是redis 我希望数据库是持久的,但当我终止进程时,我注意到数据无法恢复 在这个示例中,我有100个键和值。我的进程在id=26060上运行。当我这样做时: kill -9 26060 再次运行redis server,所有密钥都会丢失 我检查了redis.conf中的相关定义,但没有找到任何内容 我怎样才能使它持久 关于您的测试,如果希望对进程进行快照,则应在终止进程之前等待5分钟 这是Redis(2.8-3.0)的默认配置: 关于您的测试,如果您希望对其进行快照,则应该在终止进程

我使用的是
redis

我希望数据库是持久的,但当我终止进程时,我注意到数据无法恢复

在这个示例中,我有100个键和值。我的进程在id=26060上运行。当我这样做时:

kill -9 26060
再次运行
redis server
,所有密钥都会丢失

我检查了redis.conf中的相关定义,但没有找到任何内容


我怎样才能使它持久

关于您的测试,如果希望对进程进行快照,则应在终止进程之前等待5分钟

这是Redis(2.8-3.0)的默认配置:


关于您的测试,如果您希望对其进行快照,则应该在终止进程之前等待5分钟

这是Redis(2.8-3.0)的默认配置:


关于您的测试,如果您希望对其进行快照,则应该在终止进程之前等待5分钟

这是Redis(2.8-3.0)的默认配置:


关于您的测试,如果您希望对其进行快照,则应该在终止进程之前等待5分钟

这是Redis(2.8-3.0)的默认配置:



我等了24小时。我使用redis 3.0来添加到这个答案中,您还可以使用命令“bgsave”@MiddleWare触发保存。您是否在“dir”中指定的目录中看到dump.rdb文件配置?在您的配置中,您应该有:#转储DB dbfilename dump.rdb dir的文件名。/还要检查日志文件以查看rdb文件是否已实际保存/loadedI等待24小时。我使用redis 3.0来添加到这个答案中,您还可以使用命令“bgsave”@MiddleWare触发保存。您是否在“dir”中指定的目录中看到dump.rdb文件配置?在您的配置中,您应该有:#转储DB dbfilename dump.rdb dir的文件名。/还要检查日志文件以查看rdb文件是否已实际保存/loadedI等待24小时。我使用redis 3.0来添加到这个答案中,您还可以使用命令“bgsave”@MiddleWare触发保存。您是否在“dir”中指定的目录中看到dump.rdb文件配置?在您的配置中,您应该有:#转储DB dbfilename dump.rdb dir的文件名。/还要检查日志文件以查看rdb文件是否已实际保存/loadedI等待24小时。我使用redis 3.0来添加到这个答案中,您还可以使用命令“bgsave”@MiddleWare触发保存。您是否在“dir”中指定的目录中看到dump.rdb文件配置?在您的配置中,您应该有:#转储DB dbfilename dump.rdb dir的文件名。/还要检查日志文件,查看rdb文件是否实际保存/加载
################################ SNAPSHOTTING  ################################
#
# Save the DB on disk:
#
#   save <seconds> <changes>
#
#   Will save the DB if both the given number of seconds and the given
#   number of write operations against the DB occurred.
#
#   In the example below the behaviour will be to save:
#   after 900 sec (15 min) if at least 1 key changed
#   after 300 sec (5 min) if at least 10 keys changed
#   after 60 sec if at least 10000 keys changed
#
#   Note: you can disable saving completely by commenting out all "save" lines.
#
#   It is also possible to remove all the previously configured save
#   points by adding a save directive with a single empty string argument
#   like in the following example:
#
#   save ""

save 900 1
save 300 10
save 60 10000
# The filename where to dump the DB
dbfilename dump.rdb

# For default save/load DB in/from the working directory
# Note that you must specify a directory not a file name.
dir /var/lib/redis/