数据库
首页 > 数据库> > Redis “max number of clients reached“的分析过程

Redis “max number of clients reached“的分析过程

作者:互联网

问题描述

生产环境上突然出现数据中断的情况,分析日志发现应用连接Redis出现“max number of clients reached”的异常。那么问题很明显了,某个应用将Redis的连接占满了。

分析方法

################################### CLIENTS ####################################

# Set the max number of connected clients at the same time. By default
# this limit is set to 10000 clients, however if the Redis server is not
# able to configure the process file limit to allow for the specified limit
# the max number of allowed clients is set to the current file limit
# minus 32 (as Redis reserves a few file descriptors for internal uses).
#
# Once the limit is reached Redis will close all the new connections sending
# an error 'max number of clients reached'.
#
# maxclients 10000
redis-cli -p 6379 -axxxx client list |wc -l

发现连接数已经几乎占满,因此进一步分析是通过连接的IP分布情况来确定出问题的应用:

redis-cli -p 6379 -axxxx client list |awk '{print $2}'|awk -F '=' '{print $2}'|awk -F ':' '{print $1}'|sort | uniq -c
1 192.168.1.4
1733 192.168.1.55
848 192.168.1.66
919 192.168.1.77
1857 192.168.1.88

标签:max,clients,Redis,number,192.168,limit
来源: https://blog.csdn.net/longchi176/article/details/115347637