本地连接服务器的redis,jedisCluster创建问题

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

查看代码:出现在创建jedisCluster对象这里,创建的对象,里面的host为127.0.0.0.1。下一行代码去获取key,直接报错。

JedisCluster cluster = new JedisCluster(Set<HostAndPort>,int int,int ,String,JedisPoolConfig);
cluster.get(key);//报错

2.后来查找原因,原来是当时在服务器上创建集群时,用的127.0.0.1作为host。应该用外网ip即公网ip。

3.重新创建集群

3.1删除dump文件,nodes文件,aof文件,然后清除appendonly*。调用原来的配置文件redis.conf启动服务。(xxx为外网ip)

cd bin
./redis-cli --cluster create xxx:8000 xxx:8001 xxx:8002 120.25.192.133:8003 xxx:8004 xxx:8005 --cluster-replicas 1 -a password

4.这样就ok了

猜你喜欢

转载自www.cnblogs.com/Choleen/p/12373542.html