在 CentOS 上 Redis 配置失败,常见原因一般集中在以下几类。你可以对照排查:
/etc/redis.confredis-server /wrong/path/redis.conf
chown -R redis:redis /var/lib/redis
chown redis:redis /etc/redis.conf
netstat -tunlp | grep 6379
bind 127.0.0.1
如果想远程访问,需改为:bind 0.0.0.0
或注释掉 bindprotected-mode yes
在以下情况会拒绝连接:
解决方式:
requirepass yourpassword
protected-mode no
查看错误:
systemctl status redis
journalctl -xe
常见问题:
redis.service 文件中路径写错echo 1 > /proc/sys/vm/overcommit_memory
ulimit -n
setenforce 0
firewall-cmd --add-port=6379/tcp --permanent
firewall-cmd --reload
检查:
redis-server /etc/redis.conf --test-memory 1
Can't chdir to '/var/lib/redis': No such file or directoryFatal error, can't initialize Background JobsAddress already in use如果你能贴出:
我可以帮你精确判断是哪一种原因。