OOM command not allowed when used memory > 'maxmemory'.报错
作者:吴炳锡 来源:http://wubx.net/ 联系方式: wubingxi#163.com 转载请注明作/译者和出处,并且不能用于商业用途,违者必究.
OOM command not allowed when used memory > ‘maxmemory’ 报错排查
grep “OOM command not allowed when used memory > ‘maxmemory'” * -rsrc/redis.c: “-OOM command not allowed when used memory > ‘maxmemory’.\r\n”));
查看src/redis.c
shared.oomerr = createObject(REDIS_STRING,sdsnew( "-OOM command not allowed when used memory > 'maxmemory'.\r\n")); 。。。 /* Handle the maxmemory directive. * * First we try to free some memory if possible (if there are volatile * keys in the dataset). If there are not the only thing we can do * is returning an error. */ if (server.maxmemory) { int retval = freeMemoryIfNeeded(); if ((c->cmd->flags & REDIS_CMD_DENYOOM) && retval == REDIS_ERR) { flagTransaction(c); addReply(c, shared.oomerr); return REDIS_OK; } }
shared . oomerr = createObject ( REDIS_STRING , sdsnew ( "-OOM command not allowed when used memory > 'maxmemory'.\r\n" ) ) ; 。。。 /* Handle the maxmemory directive. * * First we try to free some memory if possible (if there are volatile * keys in the dataset). If there are not the only thing we can do * is returning an error. */ if ( server . maxmemory ) { int retval = freeMemoryIfNeeded ( ) ; if ( ( c - & gt ; cmd - & gt ; flags & amp ; REDIS_CMD_DENYOOM ) & amp ; & amp ;retval == REDIS_ERR ) { flagTransaction ( c ) ; addReply ( c , shared . oomerr ) ; return REDIS_OK ; } } |
从代码确认报这个错,大概是内存达到最大限时不能释放出来内存报的错。
做一个简单的验证:
配置一个10M大小的Redis,利用一个python程序往里面写数据,很快得到报错:
#python t_redis.py Traceback (most recent call last): File "t_redis.py", line 21, in <module> start() File "t_redis.py", line 15, in start s = r.set(key, v1) File "/usr/lib/python2.6/site-packages/redis/client.py", line 647, in set return self.execute_command('SET', name, value) File "/usr/lib/python2.6/site-packages/redis/client.py", line 330, in execute_command **options File "/usr/lib/python2.6/site-packages/redis/client.py", line 312, in _execute_command return self.parse_response(command_name, **options) File "/usr/lib/python2.6/site-packages/redis/client.py", line 390, in parse_response response = self._parse_response(command_name, catch_errors) File "/usr/lib/python2.6/site-packages/redis/client.py", line 349, in _parse_response raise ResponseError(response) redis.exceptions.ResponseError: OOM command not allowed when used memory > 'maxmemory'.
#python t_redis.py Traceback ( most recent call last ) : File "t_redis.py" , line 21 , in & lt ; module & gt ; start ( ) File "t_redis.py" , line 15 , in start s = r . set ( key , v1 ) File "/usr/lib/python2.6/site-packages/redis/client.py" , line 647 , in set return self . execute_command ( 'SET' , name , value ) File "/usr/lib/python2.6/site-packages/redis/client.py" , line 330 , inexecute_command * * options File "/usr/lib/python2.6/site-packages/redis/client.py" , line 312 , in_execute_command return self . parse_response ( command_name , * * options ) File "/usr/lib/python2.6/site-packages/redis/client.py" , line 390 , in parse_response response = self . _parse_response ( command_name , catch_errors ) File "/usr/lib/python2.6/site-packages/redis/client.py" , line 349 , in _parse_response raise ResponseError ( response ) redis . exceptions . ResponseError : OOM command not allowed when used memory& gt ; 'maxmemory' . |
结论:
- Redis运行中监控内存的使用情况.
- 如果只做缓存使用,需要配置上lru策略,如
maxmemory-policy allkeys-lru maxmemory-samples 5
maxmemory - policy allkeys - lru
maxmemory - samples 5
- 故障现场要看一下Redis的info输出,看看内存配是否达到了上限。
相关推荐
redis-5.0.5.redis-5.0.5.redis-5.0.5.redis-5.0.5.redis-5.0.5.redis-5.0.5.redis-5.0.5.redis-5.0.5.redis-5.0.5.redis-5.0.5.redis-5.0.5.redis-5.0.5.redis-5.0.5.redis-5.0.5.redis-5.0.5.redis-5.0.5.redis-...
redis-5.0.14-1.el7.remi.x86_64.rpm安装包(含有部署手册) redis-5.0.14-1.el7.remi.x86_64.rpm安装包(含有部署手册) redis-5.0.14-1.el7.remi.x86_64.rpm安装包(含有部署手册) redis-5.0.14-1.el7.remi.x86_64.rpm...
redis-5.0.14/src/redis-cli --cluster create 192.168.129.98:7000 192.168.129.99:7003 192.168.129.99:7002 192.168.129.126:7005 192.168.129.126:7004 192.168.129.98:7001 --cluster-replicas
redis++使用说明,windows下编译redis-plus-plus
Redis在CentOS系统中创建集群可能会用到的安装包, 其中redis-3.0.0.tar是Redis服务, redis-3.0.0.gem是Redis通过ruby创建集群要用到的包
redis 配置集群必备
tomcat-redis-session-manager-2.0.0.jar jedis-2.5.2.jar commons-pool2-2.2.jar 2.修改 conf 目录下的 context.xml 文件 host="localhost" port="6379" database="0" maxInactiveInterval="60" /> ...
tomcat-redis-session-manager-1.2-tomcat-7-java-7tomcat-redis-session-manager-1.2-tomcat-7-java-7tomcat-redis-session-manager-1.2-tomcat-7-java-7tomcat-redis-session-manager-1.2-tomcat-7-java-7tomcat-...
1: 下载redis-5.0.4.tar.gz 2: 解压源码并进入目录 tar zxvf redis-5.0.4.tar.gz cd redis-5.0.4 3: 不用configure 4: 直接make (如果是32位机器 make 32bit) 查看linux机器是32位还是64位的方法:file /bin/...
文件夹内包括有Redis-x64-3.0.504.zip、Redis-x64-3.2.100.msi。可供大家下载安装。
redis校验工具redis-full-check,配合redis-shake使用!!!
Redis-x64-5.0.10.msi
压缩文件包括tomcat-redis-session-manager-master-2.0.0.jar、jedis-2.7.3.jar、commons-pool2-2.3.jar三个jar包使用方法请参照https://github.com/jcoleman/tomcat-redis-session-manager。apache-tomcat-8.5.33....
资源在github上下载下来,包含Redis-x64-3.2.100.zip和Redis-x64-3.2.100.msi两个文件
Redis稳定版 Redis-x64-5.0.14.1.zip
Tomcat8亲测可用 tomcat-redis-session-manager的jar包 修改了tomcat-redis-session-manager源码进行的编译生成的jar包
赠送jar包:spring-data-redis-2.5.5.jar; 赠送原API文档:spring-data-redis-2.5.5-javadoc.jar; 赠送源代码:spring-data-redis-2.5.5-sources.jar; 赠送Maven依赖信息文件:spring-data-redis-2.5.5.pom; ...
tomcat-redis-session-manager-2.0.0.jar
redis-3.0.0.gem 执行gem install redis /usr/local/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- redis (LoadError) from /usr/local/lib/ruby/2.3.0/...
Redis下载,Redis Server,Redis-x64-5.0.9.zip