READONLY: READONLY You can't write against a read only replica(不能对只读副本执行写入)
Redis含义
写命令被发送到副本(slave)节点。副本默认是只读的;写入只能在 master 上执行。
原因
客户端连接的是副本而非 master、故障转移后旧 master 变成了副本、Sentinel/Cluster 中错误路由到了错误节点,或负载均衡器将写请求转发到了副本。
解决方法
将写请求路由到 master 节点。如果使用 Sentinel,从 Sentinel 查询当前 master(SENTINEL get-master-addr-by-name)。在 Cluster 中,写入正确分片的 master。在客户端库中配置读写分离。故障转移后刷新连接,使其指向新的 master。
同一数据库的其他条目
- OOMOOM command not allowed when used memory > 'maxmemory'(已用内存 > 'maxmemory' 时不允许执行命令)
- NOAUTHNOAUTH Authentication required(需要认证)
- WRONGPASSWRONGPASS invalid username-password pair or user is disabled(用户名-密码组合无效或用户已禁用)
- MASTERDOWNMASTERDOWN Link with MASTER is down and replica-serve-stale-data is set to 'no'(与 MASTER 的连接已断开,且 replica-serve-stale-data 设为 'no')
- CLUSTERDOWNCLUSTERDOWN The cluster is down / Hash slot not served(集群已宕机 / 哈希槽未被服务)
- LOADINGLOADING Redis is loading the dataset in memory(Redis 正在将数据集加载到内存中)
- BUSYBUSY Redis is busy running a script. You can only call SCRIPT KILL or SHUTDOWN NOSAVE(Redis 正忙于运行脚本。只能调用 SCRIPT KILL 或 SHUTDOWN NOSAVE)