Redis集群踩的坑及报错记录并解决

Redis集群踩的坑及报错记录并解决

四月 08, 2020 阅读数(请刷新)

1、报错redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool

记录解决方案:
1、看看防火墙是否关闭

1
2
3
4
#查看防火墙状态
service iptables status
#关闭防火墙
service iptables stop

2、修改每个节点的redis.conf文件

1
2
3
4
bind 127.0.0.1 10.25.168.129
修改为
bind 0.0.0.0
这样修改是让所有的ip都能访问

我的就是第二种原因。

2、踩坑,重启redis cluster 会报错Node xxx is not empty

这需要删除每个节点中的dump.rdb、*.aof、nodes.conf
在启动脚本里添加

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#删除redis01...redis6节点中的dump.rdb、nodes.conf文件
rm -f redis0*/dump.rdb redis0*/nodes.conf
cd redis01
./redis-server redis.conf
cd ..
cd redis02
./redis-server redis.conf
cd ..
cd redis03
./redis-server redis.conf
cd ..
cd redis04
./redis-server redis.conf
cd ..
cd redis05
./redis-server redis.conf
cd ..
cd redis06
./redis-server redis.conf
cd ..
cd redis01
./redis-cli --cluster create ip:7001 ip:7002 ip:7003 ip:7004 ip:7005 ip:7006 --cluster-replicas 1

最后分配槽的时候一定要输入yes,只输入y不行
这种方案没有根本性解决问题,只是相当于又重新建了个集群。
有真正解决方案的麻烦告知一下。。。
一、Redis服务器搭建与学习
二、Redis Cluster(Redis 集群)的搭建
三、SSM整合Redis Cluster(Redis集群)