Redis with Resque and Rails: ERR command not allowed when used memory > 'maxmemory'

放肆的年华 提交于 2019-12-03 10:52:29

问题


When using redis, it gives me the error:

ERR command not allowed when used memory > 'maxmemory'

The info command reveals:

redis 127.0.0.1:6379> info
redis_version:2.4.10
redis_git_sha1:00000000
redis_git_dirty:0
arch_bits:64
multiplexing_api:kqueue
gcc_version:4.2.1
process_id:1881
uptime_in_seconds:116
uptime_in_days:0
lru_clock:1222663
used_cpu_sys:0.04
used_cpu_user:0.04
used_cpu_sys_children:0.00
used_cpu_user_children:0.00
connected_clients:1
connected_slaves:0
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0
used_memory:930912
used_memory_human:909.09K
used_memory_rss:1269760
used_memory_peak:931408
used_memory_peak_human:909.58K
mem_fragmentation_ratio:1.36
mem_allocator:libc
loading:0
aof_enabled:0
changes_since_last_save:4
bgsave_in_progress:0
last_save_time:1333432389
bgrewriteaof_in_progress:0
total_connections_received:1
total_commands_processed:2
expired_keys:0
evicted_keys:0
keyspace_hits:0
keyspace_misses:0
pubsub_channels:0
pubsub_patterns:0
latest_fork_usec:0
vm_enabled:0
role:master

Is the used_memory high? I'm a complete redis noob. If so, how does this problem occur and how should I proceed from here? This same error is all occurring in production (Heroku), so any help is greatly appreciated. Thank you.


回答1:


This message is returned when maxmemory limit has been reached. You can check what the current limit is by using the following command:

redis 127.0.0.1:6379> config get maxmemory
1) "maxmemory"
2) "128000000"

The result is in bytes.

Please note an empty Redis instance uses about 710KB of memory (on Linux), so if you plan to store only 1MB of useful data and enforce this limit, then you need to set 1734K in maxmemory parameter. In the configuration file, the maxmemory setting is in bytes, except if you use a K,M,G suffix.

Redis stores everything in memory (it never spills data on the disk), so all the content of your Resque queues has to fit. A few MB seem very low for a Resque engine.

You did not specify which Heroku option you selected, but my understanding is Redis To Go "nano" option (the free one) limit is 5 MB.




回答2:


Great answer by Didier, these are just the steps to increase it:

redis-cli
127.0.0.1:6379> config get maxmemory
1) "maxmemory"
2) "67108864" # (67mb) this will be different in your case

This is how to change it:

127.0.0.1:6379> config set maxmemory 100mb
OK
127.0.0.1:6379> config set maxmemory-policy allkeys-lru
OK
127.0.0.1:6379> config get maxmemory
1) "maxmemory"
2) "104857600"


来源:https://stackoverflow.com/questions/9987832/redis-with-resque-and-rails-err-command-not-allowed-when-used-memory-maxmemo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!