JedisPool Could not get a resource from the pool

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

JedisPoolConfig jpc = new JedisPoolConfig();

jpc.setMaxMillionSec(1000*60);//这里设置的没起作用

JedisPool jp = new JedisPool("192.168.1.100",6379,100,"admin");

jedispool设置的connect time太短了,默认是100ms

jedis.close()还回池子jedis实例

JedisCluster Could not get a resource from the pool错误通常是由于连接池中的资源不足或连接超时引起的。以下是一些可能的解决方案: 1. 增加连接池的最大连接数和最大空闲连接数,以确保连接池中有足够的资源可用。 2. 增加连接池的超时时间,以便在连接池中没有可用连接时等待更长的时间。 3. 检查redis集群的配置是否正确,确保所有节点都已正确配置。 4. 检查redis集群的状态,确保所有节点都处于正常状态。 5. 检查网络连接是否正常,确保可以从应用程序服务器访问redis集群。 以下是一些可能的解决方案的代码示例: ```java // 增加连接池的最大连接数和最大空闲连接数 JedisPoolConfig poolConfig = new JedisPoolConfig(); poolConfig.setMaxTotal(100); poolConfig.setMaxIdle(50); // 增加连接池的超时时间 JedisCluster jedisCluster = new JedisCluster(nodes, 5000, 5000, 10, password, poolConfig); // 检查redis集群的配置是否正确 Set<HostAndPort> nodes = new HashSet<HostAndPort>(); nodes.add(new HostAndPort("127.0.0.1", 7000)); nodes.add(new HostAndPort("127.0.0.1", 7001)); nodes.add(new HostAndPort("127.0.0.1", 7002)); JedisCluster jedisCluster = new JedisCluster(nodes, poolConfig); // 检查redis集群的状态 Map<String, JedisPool> clusterNodes = jedisCluster.getClusterNodes(); for (Map.Entry<String, JedisPool> entry : clusterNodes.entrySet()) { Jedis jedis = null; try { jedis = entry.getValue().getResource(); String pong = jedis.ping(); System.out.println(entry.getKey() + " - " + pong); } catch (Exception e) { System.out.println(entry.getKey() + " - " + e); } finally { if (jedis != null) { jedis.close(); } } } // 检查网络连接是否正常 ping redis-server-ip ```
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值