开发手记:JedisConnectionException: Could not get a resource from the pool

对于Redis,生产环境是集群模式,测试环境是单例模式,如果在生产环境中用单例模式会报错。

解决办法,通过云配置,将配置进行自动化配置。

另附一份Redis配置:

#*********************Redis单节点配置************************
# Redis服务器地址
spring.redis.host=10.5.172.67
# Redis服务器连接端口
spring.redis.port=7006  

#*********************RedisCluster集群配置************************
# Redis服务器地址
spring.redis.hosts=10.30.10.169:6379,10.30.10.170:6379,10.30.10.171:6379,10.30.10.169:6380,10.30.10.170:6380,10.30.10.171:6380
# 读取超时时间(毫秒),源码:JedisConnectionFactory中在jedisCluster中设置的和timeout连接超时是一致的。
#         return StringUtils.hasText(getPassword())
#                ? new JedisCluster(hostAndPort, timeout, timeout, redirects, password, poolConfig)
#                : new JedisCluster(hostAndPort, timeout, redirects, poolConfig);
spring.redis.sotimeout=1000
# 最大重试次数
spring.redis.maxAttempts=2
#集群间最大跳转次数,如果不设置maxRedirects值,源码中默认为5。一般当此值设置过大时,容易报:Too many Cluster redirections
#源码是在JedisConnectionFactory中设置的new JedisCluster(hostAndPort, timeout, timeout, redirects, password, poolConfig)
spring.redis.maxRedirects=5

#*********************Redis通用配置************************
# Redis服务器连接密码(默认为空)
spring.redis.password=  [email protected]123456
# 连接池最大连接数(使用负值表示没有限制)
spring.redis.pool.max-active=8
# 连接池最大阻塞等待时间(使用负值表示没有限制),单位毫秒
spring.redis.pool.max-wait=-1
# 连接池中的最大空闲连接
spring.redis.pool.max-idle=8
# 连接池中的最小空闲连接
spring.redis.pool.min-idle=1
# 连接池中逐出连接的最小空闲时间 默认1800000毫秒(30分钟)
spring.redis.pool.min-evictableIdleTimeMillis=1800000
# 连接超时时间(毫秒)
spring.redis.timeout=1000
# redis cacheManager过期时间,单位秒,默认为0,代表永不过期
spring.redis.cacheManager.expire = 86400

原文地址:https://www.cnblogs.com/gudi/p/8409046.html

时间: 2024-08-07 01:17:53

开发手记:JedisConnectionException: Could not get a resource from the pool的相关文章

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

今天在链接redis时,遇到问题: redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool Could not get a resource from the pool. redis的配置是: <bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig&qu

redis JedisConnectionException: Could not get a resource from the pool

HTTP Status 500 - Cannot get Jedis connection; nested exception is redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool type Exception report message Cannot get Jedis connection; nested exception is redis.cl

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

启动项目报该异常.原因是因为该项目是需要启动redis的,报错原因是因为没有安装redis或者没有手动启动redis,把redis设置成自启动就行了 一.下载windows版本的Redis 官网下载地址:http://redis.io/download github下载地址:https://github.com/MSOpenTech/redis/tags 二.安装Redis 1.这里下载的是Redis-x64-3.2.100版本,我的电脑是win7 64位,所以下载64位版本的,在运行中输入cm

Redis2.1.0:Could not get a resource from the pool的分析

节前的最后一天,sso登陆出现问题,多数用户无法正常登陆.经查询日志,报错如下: 错误日志截取如下2015-02-15 08:40:30,536 INFO [org.jasig.cas.authentication.AuthenticationManagerImpl] - <com.gaochao.oa.module.sso.authentication.handler.FxLdapMixAuthenticationHandler successfully authenticated[usern

Redis一个异常的解决办法,异常描述:Could not get a resource from the pool

异常描述: redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool at redis.clients.util.Pool.getResource(Pool.java:22) at com.derbysoft.jredis.longkeytest.BorrowObject.run(BorrowObject.java:22) at java.lang.Thread.

java 连接 redis集群时报错:Could not get a resource from the pool

由于弄这个的时候浪费了太多的时间,所以才记录下这个错,给大伙参考下 检查了一下,配置啥的都没问题的,但在redis集群机器上就可以,错误如下: Exception in thread "main" redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool 原因: 是因为我在创集群的时候的ip地址是:127.0.0.1,不是本机的电脑访问的话是不能访问的,

Could not get a resource from the pool

异常描述: redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool   at redis.clients.util.Pool.getResource(Pool.java:22)   at com.derbysoft.jredis.longkeytest.BorrowObject.run(BorrowObject.java:22)   at java.lang.T

[转]灯灯小程序开发手记:仿今日头条(上)

本文转自:http://www.jianshu.com/p/a1e0b8abb12d 写在前面 新的一年,祝大家新年快乐!当然对于程序员来说,新的一年,也要有新的改变.因此灯灯决定凑热闹编写微信小程序啦! 上一篇文章<记一次小程序开发过程>中,灯灯大致写了下自己第一次开发小程序的感受和流程.这一次灯灯会详细记录下自己制作一个小程序的思路.遇到的问题.涉及到的代码等和大家分享.    视频教程地址:http://study.163.com/course/introduction.htm?cour

[分享]源代码&amp;开发手记:SAE应用“车百科” (Python + SAE + Bottle + Bootstrap) - Bottle - Python4cn(news, jobs)

[分享]源代码&开发手记:SAE应用"车百科" (Python + SAE + Bottle + Bootstrap) - Bottle - Python4cn(news, jobs) [分享]源代码&开发手记:SAE应用"车百科" (Python + SAE + Bottle + Bootstrap)[分享]源代码&开发手记:SAE应用"车百科" (Python + SAE + Bottle + Bootstrap) -