服务启动报错 RedisCommandExecutionException: READONLY You can‘t write against a read only replica.
服务启动报错 RedisCommandExecutionException: READONLY You can't write against a read only replica.org.springframework.data.redis.RedisSystemException: Error in execution; nested exception is io.lettuce.core
报错日志
org.springframework.data.redis.RedisSystemException: Error in execution; nested exception is io.lettuce.core.RedisCommandExecutionException: READONLY You can’t write against a read only replica.
Caused by: io.lettuce.core.RedisCommandExecutionException: READONLY You can’t write against a read only replica.
解决方法
报错原因是当前访问的 redis 是从(slave)节点,进入redis客户端通过role指令可以查看redis是master、slave还是sentinel。
redis默认slave节点的 replica-read-only 属性为 yes(只读),将其修改为 no 即可(非集群模式下有效,cluster模式下无效)
- 进入redis容器
docker exec -it redis容器的CONTAINER ID或者NAMES /bin/bash
# 如下
docker exec -it f3e /bin/bash
- redis-cli 进入redis客户端
redis-cli
- 将 replica-read-only 设置为 no
config set replica-read-only no

ps: 或者直接修改 redis.config 文件,搜索 replica-read-only 设置为 no 即可
更多推荐



所有评论(0)