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开机启动