redis 设置maxclients失败

新手初学单机器redis,搜索引擎找了下在redis.conf里设置

maxclients 10000

重启redis/服务器,使用时日志文件提示

You requested maxclients of 10000 requiring at least 10032 max file
descriptors. Redis can't set maximum open files to 10032 because of OS
error: Operation not permitted. Current maximum open files is 4096.
maxclients has been reduced to 4064 to compensate for low ulimit. If
you need higher maxclients increase 'ulimit -n'.

redis-clie 链接

输入

config get maxclients

clipboard.png

错误提示

ERR The operating system is not able to handle the specified number ofclients, try with 4064

已设置ulimit -n 为65535

clipboard.png

现询问原因,如何成功的将maxclients设置为较大的数?

谢谢~

阅读 11.8k
1 个回答

自行解决了,原因是系统是ubuntu 16,搜索引擎里的都是14的解决方法

/etc/systemd/system/redis.service
[Service]
...
User=redis
Group=redis
# should be fine as long as you add it under [Service] block
LimitNOFILE=65536
...

然后

sudo systemctl daemon-reload
sudo systemctl restart redis.service

cat /run/redis/redis-server.pid
cat /proc/PID/limits

看到
Max open files
Max locked memory
数字变大了

解决方法来自

https://stackoverflow.com/que...

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题