Redis maxmemory-policy noeviction但键消失没有错误 [英] Redis maxmemory-policy noeviction but keys disappear without error

查看:108
本文介绍了Redis maxmemory-policy noeviction但键消失没有错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 docker 中使用 redis 和 image: redis:5.0.3 并且我不时面对所有密钥感到沮丧.我试图弄清楚发生了什么.首先检查 maxmemory-policymaxmemory 看起来是正确的,但也许 noeviction 应该在顶部?

I use redis in docker with image: redis:5.0.3 and time to time I faced with all keys was despirred. I try to figure out what is going on. First checked maxmemory-policy and maxmemory looks like correct, but maybe noeviction should be on a top ?

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"

然后检查了我的redis_server.conf,看起来是正确的maxmemory-policy noeviction

then checked my redis_server.conf, looks like correct 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.

But time to time my keys disappear, yesterday I had 7514 keys but today I found only 76. I checked it executed keys * or dbsize.

你能帮帮我吗,请检查我的 redis 配置.

Could you help me, check please my redis config.

当我使用 image: redis:alpine 时也是如此.maxmemory-policy 和 maxmemory 的结果相同.我想我应该在键用完所有内存时遇到关于允许内存大小的错误,但不,只是消失键.

the same cased when I use image: redis:alpine. The same result in maxmemory-policy and maxmemory. I thought I should faced with error about allow memory size when keys spent all memory, but no, just disappear keys.

推荐答案

你的 redis.conf 看起来不错,你正在执行的关于内存和驱逐的命​​令也表明了这一点.

Your redis.conf looks fine, the commands you are executing about the memory and evictions also show that.

redis 文档

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

noeviction return errors when the memory limit was reached and the client is trying to execute commands that could result in more memory to be used (most write commands, but DEL and a few more exceptions).

因此,如果您有 n 个应用程序与此 redis 通信,其中 maxmemory 设置为 zero 并且 eviction policynoeviction 那么当你超过限制时,那些应用程序会抛出异常.如果您没有收到任何 OOM 错误/异常,那么我乐观的猜测是它与 eviction 无关.

So if you have n applications talking to this redis of which's maxmemory set to zero and eviction policy is noeviction then when you exceed the limit, those applications will throw exceptions. If you are not getting any OOM error/exception, then my optimist guess is that it is not related to the eviction.

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

Here are the possible problems and debugging solutions i may suggest;

从7514急剧下降到74.我认为可以;

There is a drastic drop from 7514 to 74. I think it could;

  • 使密钥的政策过期
    • 请确保没有强"这些密钥的过期政策.
    • 您可以查看Redis日志,查看是否有restart/shutdown活动的相关日志.
    • You may check Redis logs to see is there any related logs about restart/shutdown activities.
    • 您可以执行SLOWLOG 查看是否有刷新命令.
    • 如果密钥丢失经常发生,您可以尝试监控一段时间(grep/write进入日志文件并在其中搜索,您将看到执行命令的客户端的IP地址).
    • 您可以禁用 flushall/flushdb 方法来自 redis.conf 并继续检查之后是否有任何密钥丢失.
    • You may execute SLOWLOG to see if there is any flush commands.
    • If key disappearance happens regularly, you may try to monitor it for a while (grep/write into a log file and search inside it, you will see the ip address of the client executing the command).
    • You may disable flushall/flushdb methods from redis.conf and keep checking is there any key loss after it.
    • You may use keyspace notifications too any key deletion commands are executed.

    这篇关于Redis maxmemory-policy noeviction但键消失没有错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆