Could not get a resource from the pool 异常定位和解决

简介: Could not get a resource from the pool 异常定位和解决

  最近在服务中经常看到以下错误,进行下定位和问题解决分析:

2023-12-08 00:10:58.248  WARN [terra-sr-server,a9006fd27ccb81d0,a9006fd27ccb81d0,false] 52 --- [o-14009-exec-38] o.s.b.a.redis.RedisHealthIndicator       : Redis health check failed
org.springframework.data.redis.RedisConnectionFailureException: Cannot get Jedis connection; nested exception is redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool

  

  这个异常 org.springframework.data.redis.RedisConnectionFailureException: Cannot get Jedis connection; nested exception is redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool 表示应用程序无法从连接池中获取一个 Redis 连接。这可能是因为连接池已经耗尽,或者 Redis 服务器无法接受更多的连接。

  解决这个问题的方法是首先确定 Redis 服务器的状态,然后检查应用程序的 Redis 连接配置。

1.登录redis,并查看最大连接数:

redis-cli -h 127.0.0.1 -p 6379
config get maxclients

                 

2.info 查询redis信息:

info

                         

3.服务器端服务器执行以下命令,查看连接数

netstat -nat  |awk '{print $5}'|awk -F: '{print $1}'|sort|uniq -c|sort -nr|head -20

       

        注:忽略上图的数据,截图时问题已经修复,截图只是为了查看命令返回的数据和格式

4.最终解决结果

  在项目中配置的redis最大连接数是100,调整了项目中reids的最大连接数之后 异常便得以解决。

 

 

标签: redis , 异常

相关文章
SpringCloud极简入门-Feign开启Hystrix
1.支付服务集成Hystrix 官方文档:https://cloud.spring.io/spring-cloud-static/Greenwich.SR5/single/spring-cloud.html#spring-cloud-feign-hystrix 支付服务 springcloud-pay-server-1040 之前集成了Feign,修改该工程集成Hystrix。我们除了要给Feign开启Hystrix以外还需要为Feign接口编写托底类。
754 0
|
SQL 数据库
DM达梦数据库 - 设置忽略关键字方法,login关键字处理实例演示
DM达梦数据库 - 设置忽略关键字方法,login关键字处理实例演示
2205 0
DM达梦数据库 - 设置忽略关键字方法,login关键字处理实例演示
|
域名解析 Linux Shell
CentOS 7 执行 yum 命令失败问题的排查方法
本文主要为大家讲解CentOS 7系统中执行yum命令失败等常见问题的排查方法。
5665 0
CentOS 7 执行 yum 命令失败问题的排查方法
|
前端开发 JavaScript 应用服务中间件
前端跨域问题解决Access to XMLHttpRequest at xxx from has been blocked by CORS policy
跨域问题是前端开发中常见且棘手的问题,但通过理解CORS的工作原理并应用合适的解决方案,如服务器设置CORS头、使用JSONP、代理服务器、Nginx配置和浏览器插件,可以有效地解决这些问题。选择合适的方法可以确保应用的安全性和稳定性,并提升用户体验。
9770 90
|
SQL Java 数据库连接
成功解决:was not registered for synchronization because synchronization is not active
这篇文章是关于解决Mybatis在同步过程中出现"was not registered for synchronization because synchronization is not active"错误的技术博客。
成功解决:was not registered for synchronization because synchronization is not active
|
缓存 NoSQL Java
【Azure Redis 缓存 Azure Cache For Redis】当使用Jedis客户端连接Redis时候,遇见JedisConnectionException: Could not get a resource from the pool / Redis connection los
【Azure Redis 缓存 Azure Cache For Redis】当使用Jedis客户端连接Redis时候,遇见JedisConnectionException: Could not get a resource from the pool / Redis connection los
1156 0
|
前端开发 Java Spring
为什么会出现Request method ‘GET‘ not supported`
为什么会出现Request method ‘GET‘ not supported`
5598 1
|
NoSQL 网络协议 Java
Redis客户端Lettuce深度分析介绍(上)
Spring Boot自2.0版本开始默认使用Lettuce作为Redis的客户端(注1)。Lettuce客户端基于Netty的NIO框架实现,对于大多数的Redis操作,只需要维持单一的连接即可高效支持业务端的并发请求 —— 这点与Jedis的连接池模式有很大不同。同时,Lettuce支持的特性更加全面,且其性能表现并不逊于,甚至优于Jedis。本文通过分析Lettuce的特性和内部实现(基于6.0版本),及其与Jedis的对照比较,对这两种客户端,以及Redis服务端进行深度探讨。
103675 8
|
Java Apache
Java代码使用POI导出的单元格的字体加粗设置
【5月更文挑战第3天】Java代码使用POI导出的单元格的字体加粗设置
1615 1
|
监控 关系型数据库 MySQL
如何安装和配置Monit
如何安装和配置Monit
448 0

热门文章

最新文章