A Redis client can connect to a cluster via Jedis, but using Jediscluster to connect a redis cluster has been reported could not get a resource from the pool

Source: Internet
Author: User
Tags redis desktop manager redis cluster

One, the problem description:

Connect Redis Standalone via Jedis successfully, using Jediscluster to connect Redis cluster has been reported could not get a resource from the pool

But using a Redis client, you can connect to the cluster (the Redis desktop Manager I'm using)

The Redis standalone connection via Jedis in Java is also successful, but using Jediscluster to connect a redis cluster has been reported could not get a resource from the pool,

I do this in the command line mode, as follows:

Paste the code First:

<!--Redis Client--
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.8.2</version>
</dependency>

The relevant code is as follows:

Jedispoolconfig config = new Jedispoolconfig ();
Config =new jedispoolconfig ();
Config.setmaxtotal (60000);//Set maximum number of connections
Config.setmaxidle (1000); Set maximum idle number
Config.setmaxwaitmillis (3000);//Set timeout time
Config.settestonborrow (TRUE);


Cluster nodes
setJedisclusternode.add (New Hostandport ("192.168.246.128", Integer.parseint ("7001"));
Jedisclusternode.add (New Hostandport ("192.168.246.128", Integer.parseint ("7002"));
Jedisclusternode.add (New Hostandport ("192.168.246.128", Integer.parseint ("7003"));
Jedisclusternode.add (New Hostandport ("192.168.246.128", Integer.parseint ("7004"));
Jedisclusternode.add (New Hostandport ("192.168.246.128", Integer.parseint ("7005"));
Jedisclusternode.add (New Hostandport ("192.168.246.128", Integer.parseint ("7006"));

Jediscluster JC = new Jediscluster (jedisclusternode, config);
Jediscluster JC = new Jediscluster (Jedisclusternode);
Jc.set ("name", "Zhangsan");
String value = Jc.get ("name");
System.out.println (value);

Tangled two days is also no sei, just a few lines of code, it seems to see no problem ah, even on GitHub to see the author's example, the same ah, once doubted life ah;

Because my stand-alone version with the command line and Java code access is not a problem, and the cluster through the command line mode is not a problem, so I have not doubted the environment I set up the problem, I suspect the code, whether the project is dependent on the Jedis version of the bug, changed several versions or reported the same error, Finally I began to check the environment, the environment first shut down the firewall, useless, and then check the configuration file, found

Two: Find the problem: This place IP problem, above is the correct version, the previous problematic version of the IP is 127.0.0.1,

The reason is that I didn't comment on this place before. The command to use bind 127.0.0.1 in the redis.conf file and then do the cluster is:

./redis-trib.rb Create--replicas 1 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005 127.0.0.1:7006

Three: Solve the problem:

Delete all of the above inside this node.conf file

And then:

To re-do the cluster:

./redis-trib.rb Create--replicas 1 192.168.246.128:7001 192.168.246.128:7002 192.168.246.128:7003 192.168.246.128:7004 192.168.246.128:7005 192.168.246.128:7006

Then the re-test is solved;

Also note the configuration of the redis.conf under each redis (Below is my):

Port7001//Port 7001,7002,7003
Bind native IP//The default IP for 127.0.0.1 needs to be changed to another node machine accessible IP Otherwise, the corresponding port cannot be accessed when the cluster is created, and the cluster cannot be created, I commented out directly.
Daemonize Yes//Redis Background Run
Pidfile/Var/run/redis_7000.pid//Pidfile file corresponds to 7000,7001,7002
cluster-enabled Yesturn on the cluster and remove the comment #
Cluster-config-file nodes_7000.conf // cluster configuration profile is first started automatically generated 7001,7002,7003
Cluster-node-timeout 15000 // Request time-out default 15 seconds, can be set by itself
AppendOnly Yes //aof Log on if needed, it logs a log every time a write operation is started

A Redis client can connect to a cluster via Jedis, but using Jediscluster to connect a redis cluster has been reported could not get a resource from the pool

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.