(1)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没生效,需要使我们自定义的配置文件生效。
(2)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