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

相關文章
相關標籤/搜索