Redis 错误排查

今天redis忽然报错,启动不了了记录一下排错过程:node

错误1

Connection refused - Unable to connect to Redis on localhost:6379nginx

首先检查redis是否没有启动,经过以下命令便可
# ps aux | grep redisredis

 

错误2

Short read or OOM loading DB. Unrecoverable error, aborting now.this

删除一下redis的db文件和进程文件,而后重启
# rm -rf /var/lib/redis/dump.rdb
# rm -rf /var/run/redis.pid
# service redis-server startspa

若是以前redis能正常运行,忽然某天出问题了,以上2步应该能解决,多半是因为dump.rdb文件出错致使的server

 

错误3

WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.blog

照着提示在 /etc/sysctl.conf 增长一行试试
vm.overcommit_memory = 1进程

 

错误4

Unable to set the max number of files limit to 10032 (Operation not permitted), setting the max clients configuration to 3984.it

能够作如下尝试:
在文件增长一行 /etc/sysctl.conf
net.core.somaxconn = 1024io

打开文件 /etc/defaults/redis-server,将下面这行去掉注释,若是没有就新增
ULIMIT=65536

打开文件新增如下行 /etc/security/limits.conf
redis soft nofile 65536
redis hard nofile 65536
nginx soft nofile 262144
nginx hard no file 262144

 

参考:

https://community.nodebb.org/topic/1563/redis-advice-on-low-memory-system/7

https://blog.argcv.com/articles/3212.c

https://stackoverflow.com/questions/4670049/rescue-connection-refused-unable-to-connect-to-redis-on-localhost6379

https://stackoverflow.com/questions/19700404/short-read-or-oom-loading-db-unrecoverable-error-aborting-now

相关文章
相关标签/搜索