连接redis服务时报错Caused by: io.lettuce.core.RedisReadOnlyException: READONLY You can't write against a read only slave.

修改 Redis 从服务器(slave ) 读写 权限,该方法无需重启redis

127.0.0.1:6379> config set slave-read-only no
(error) NOAUTH Authentication required.
(4.30s)
127.0.0.1:6379> auth 123456
OK
(2.17s)
127.0.0.1:6379> config set slave-read-only no
OK
127.0.0.1:6379> config get slave-read-only
1) "slave-read-only"
2) "no"
(2.71s)
127.0.0.1:6379>

(注意:若Redis从服务器重新启动,之前的设置参数就会失效,又会出现 redis 从服务器只有读权限。但这样比较安全)

永久生效的方法:

修改 redis.windows.conf 配置文件中的参数 slave-read-only yes ,将 yes 修改为 no ;
然后保存并重启 redis 服务,此刻从服务器就具备了 读写权限。

posted @ 2024-01-23 11:27  山茶花llia  阅读(162)  评论(0编辑  收藏  举报