【问题标题】:How to delete a Redis key on disk?如何删除磁盘上的 Redis 密钥?
【发布时间】:2015-12-18 21:13:39
【问题描述】:

我是 Redis 的新手,我试图删除 Ram 上的一个键,但它已经存在于磁盘上的哑文件中。重启服务器后,Ram 上的密钥已经存在。请帮我。如何在内存和磁盘之间同步数据?

【问题讨论】:

标签: java redis key disk del


【解决方案1】:

根据你的配置文件,你可以修改你的redis config file,比如

appendonly yes
appendfsync always
# appendfsync everysec
# append

希望有所帮助。

【讨论】:

  • 我刚刚按照你的建议进行了配置,但它不起作用。请帮助我,下面是我的配置文件。有什么不对吗? link file config
  • redis-server
  • 我附加的文件是。你能帮我找出我配置错误的东西吗?
  • 检查是否存在 appendonly.aof
【解决方案2】:
appendonly yes
appendfsync always
# appendfsync everysec
# append

像 Javy 所说的那样做肯定会有所帮助,这会启用 aof 并确保 ram 中的数据每秒同步到磁盘。 另一种方法是发出 BGSAVE 命令以立即生成新的 dump.rdb 文件。我认为您应该修改自动转储执行的频率。这是在 redis.conf 中。查看项目保存。

我最好把相关段落发给你:

################################ 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 ""

如果您不知道如何更改配置文件,请按指定顺序键入以下命令:

config set appendonly yes
config set appendonly everysec
config rewrite

如果有什么不清楚的地方,欢迎回复。

【讨论】:

  • 我刚刚按照你的建议进行了配置,但它不起作用。请帮助我,下面是我的配置文件。有什么不对吗? link file config
  • 你的 conf 文件没问题,但是你应该把“appendfsync always”改成“appendfsync everysec”,让你的redis运行得更快。
  • 我认为问题可能在于你如何重启你的redis服务器。你能告诉我你用来重启和启动你的 redis 的确切命令吗?
  • @NothingintheWorld 看到后回复我
  • 我不使用任何命令来启动和重启我的redis。我只点击了 redis-server.exe 并关闭了它。我做错什么了吗?
猜你喜欢
  • 2016-12-05
  • 1970-01-01
  • 2023-03-13
  • 2019-09-06
  • 2021-04-20
  • 1970-01-01
  • 2012-02-06
  • 1970-01-01
  • 2017-10-08
相关资源
最近更新 更多