Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Redis maxmemory策略不存在错误,但密钥消失无误_Redis - Fatal编程技术网

Redis maxmemory策略不存在错误,但密钥消失无误

Redis maxmemory策略不存在错误,但密钥消失无误,redis,Redis,我在docker中使用redis和image:redis:5.0.3一起使用,我面对的所有键有时都会被忽略。我试图弄清楚发生了什么事。首先选中的maxmemory policy和maxmemory看起来是正确的,但是可能noeviction应该在顶部 127.0.0.1:6379> config get maxmemory-policy 1) "maxmemory-policy" 2) "noeviction" 127.0.0.1:6379>

我在docker中使用redis和
image:redis:5.0.3
一起使用,我面对的所有键有时都会被忽略。我试图弄清楚发生了什么事。首先选中的
maxmemory policy
maxmemory
看起来是正确的,但是可能
noeviction
应该在顶部

127.0.0.1:6379>  config get maxmemory-policy
1) "maxmemory-policy"
2) "noeviction"
127.0.0.1:6379>  config get maxmemory
1) "maxmemory"
2) "0"
然后检查my
redis\u server.conf
,看起来正确
maxmemory policy noeviction

root@ec59084b3d77:/data# cat /etc/redis-server/redis_server.conf 
# General
port 6379
bind 0.0.0.0
#dir /var/lib/redis
timeout 0
tcp-keepalive 20
tcp-backlog 10000
loglevel notice
logfile ""
databases 16

# Snapshotting
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb

# Replication
slave-serve-stale-data yes
slave-read-only yes
repl-disable-tcp-nodelay no
slave-priority 100
min-slaves-max-lag 10
# Security
# Limits
maxclients 30000
maxmemory-policy noeviction

# Append Only Mode
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb

# Lua
lua-time-limit 5000

# Slow Log
slowlog-log-slower-than 10000
slowlog-max-len 128

# Event Notification
notify-keyspace-events ""

# Advanced
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-entries 512
list-max-ziplist-value 64
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes
但有时我的钥匙不见了,昨天我有7514把钥匙,但今天我只找到76把。我检查了它是否执行了
keys*
dbsize

你能帮我检查一下我的redis配置吗


当我使用
image:redis:alpine
时,情况也是如此。maxmemory策略和maxmemory中的结果相同。我想我应该面对一个关于允许内存大小的错误,当键耗尽了所有内存时,但是没有,只是消失键。

您的
redis.conf
看起来不错,您正在执行的关于内存的命令和逐出也显示了这一点

redis说

noeviction当达到内存限制且客户端尝试执行可能导致使用更多内存的命令时,返回错误(大多数写命令,但DEL和少数例外)

因此,如果您有n个与此redis对话的应用程序,其中的
maxmemory
设置为
zero
execution policy
noeviction
,那么当您超过此限制时,这些应用程序将抛出异常。如果您没有收到任何
OOM
错误/异常,那么我乐观的猜测是,它与
驱逐
无关

以下是我可能建议的可能问题和调试解决方案

从7514大幅下降到74。我想可以,

  • 使密钥上的策略过期
    • 请确保这些密钥上没有“强”过期策略
  • Redis服务器正在重新启动自身。
    • 您可以查看Redis日志,查看是否存在有关
      重新启动
      /
      关闭
      活动的相关日志
  • 一个或多个应用程序/客户端正在执行flushdb。
    • 您可以执行以查看是否有任何刷新命令
    • 如果密钥经常消失,您可以尝试将其删除一段时间(grep/写入日志文件并在其中搜索,您将看到执行命令的客户端的ip地址)
    • 您可以使用redis.conf中的
      flushall
      /
      flushdb
      方法,并不断检查是否有任何密钥丢失
  • 如果您没有
    密码
    ,也许您可以设置并更新您的客户端,看看是否再次发生这种情况
  • 对某些键执行大量删除操作
    • 您也可以在执行任何键删除命令时使用

我在这个问题上提出了悬赏,因为我有同样的症状,但事实证明,这是因为错误代码使用另一个db的方式进行SWAPDB的次数超过了它应有的次数(实际上在导入结束时只有1次)。可能值得检查是否还有其他dbs。@greg0ire我在赏金之后看到了它,这些是我们试图找到根本原因的步骤,它表明库的一个命令正在刷新它。我可能会将赏金奖励给你,但首先听到OP的消息会很好。这篇文章很新,他们可能仍然有这个问题。@greg0ire你完全正确,而且关键的删除原因彼此不同,我想知道op的情况。没有答案……这是悬赏,恭喜!