redis集群搭建的常见问题

本文详细解析了Redis在使用过程中常见的四大问题,包括连接时的快照关闭导致的持久化失败、连接失败的iptables问题、集群slot槽占用及节点无法正常加入集群的状态,并提供了具体的解决步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.连接redis数据库时突然报错:MISCONF Redis is configured to save RDB snapshots, but it is currently not able to persist on disk. Commands that may modify the data set are disabled, because this instance is configured to report errors during writes if RDB snapshotting fails (stop-writes-on-bgsave-error option). Please check the Redis logs for details about the RDB error.
原因是因为强制把redis快照关闭了导致不能持久化的问题。
方法一:连接redis之后执行命令:
config set stop-writes-on-bgsave-error no
方法二:打开redis.conf文件,使用快捷匹配模式:/stop-writes-on-bgsave-error定位到stop-writes-on-bgsave-error字符串所在位置,接着把后面的yes设置为no即可。
2.连接redis报错:Could not connect to Redis at 192.168.111.33:7005: No route to host
Could not connect to Redis at 192.168.111.33:7005: No route to host
原因是因为iptables问题
执行下面命令即可:

sudo iptables -F
3.redis集群报错:
在这里插入图片描述原因:redis集群的slot槽占用问题
解决办法:删除redis.conf文件中cluster-config-file生成的文件
linux:生成的文件在redis的src文件夹下
如果还是有相同的问题执行下面命令
redis-cli -p 端口号-h 主机物理地址 FLUSHALL
redis-cli -p 端口号-h 主机物理地址 CLUSTER RESET SOFT
重启redis服务
4.redis集群一直处于join状态:

Nodes configuration updated
Nodes configuration updated
Assign a different config epoch to each node
Sending CLUSTER MEET messages to join the cluster
Waiting for the cluster to join…

检查防火墙redis使用端口是否开放
解决办法:
方法1:在防火墙中开放redis使用的端口
方法2:直接关闭防火墙:service iptables stop(重启后失效)
方法3:永久关闭防火墙:firewall-cmd --state #查看防火墙状态
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值