docker-compose部署redis报错ERR Client sent AUTH, but no password is set问题及解决
作者:flyingju
这篇文章主要介绍了docker-compose部署redis报错ERR Client sent AUTH, but no password is set问题及解决,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教
redis报错“ERR Client sent AUTH, but no password is set”
采用docker-compose部署redis,业务服务报错连接redis错误:
ERR Client sent AUTH, but no password is set
原因
redis服务器没有设置密码,但客户端向其发送了AUTH(authentication,身份验证)请求携带着密码,导致报错。
既然是没有设置密码导致的报错,那我们就把Redis服务器给设置上密码就好了。
其实我在部署redis的时候写了配置文件redis.conf,里面配置了密码(requirepass 123456 ),但是由于没在docker-compose配置使用自定义配置,所以redis.conf没生效,需要使我们自定义的配置文件生效。
docker-compose安装redis以配置文件方式启动
version: '2.0' services: redis: image: redis:5.0.3 restart: always volumes: - ./redis/redis.conf:/usr/local/etc/redis/redis.conf - ./redis/data:/data:rw - ./redis/logs:/logs command: # 以配置文件的方式启动 redis.conf redis-server /usr/local/etc/redis/redis.conf ports: - 6379:6379
redis.conf配置:
bind 0.0.0.0 protected-mode no port 6379 timeout 0 save 900 1 # 900s内至少一次写操作则执行bgsave进行RDB持久化 save 300 10 save 60 10000 rdbcompression yes dbfilename dump.rdb # dir data # 开启数据持久化[aof] appendonly yes appendfsync everysec # 开启密码验证 requirepass 123456
总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。