本人服务器是Ubuntu16.4的,使用apt安装redis后,其默认的最大连接数为4064,但是由于业务需求,需要调大此值,但是执行
时出现以下错误信息
127.0.0.1:6379> CONFIG set maxclients 100000
(error) ERR The operating system is not able to handle the specified number of clients, try with 4064
在网上找了各种教程,有的说是要改ulimit -n
的值,但是我的服务器上该值已经是60000多了,所以肯定不是这里的问题,然后大牛扔我这样一个网页,哎,解决了....
解决办法:
1 修改/etc/systemd/system/redis.service
文件,如下加上LimitNOFILE
参数
/etc/systemd/system/redis.service
[Service]
...
User=redis
Group=redis
# should be fine as long as you add it under [Service] block
LimitNOFILE=65536
2 重新加载service配置
sudo systemctl daemon-reload
sudo systemctl restart redis.service
3 在redis中修改最大连接数
127.0.0.1:6379> CONFIG set maxclients 10000
OK
127.0.0.1:6379> CONFIG get maxclients
1) "maxclients"
2) "10000"
网友评论