在 Debian 8.4 jessie 下启动 redis 3.0.6(从 jessie-backports 安装)时,我收到以下警告/错误:
18127:M 13 Apr 15:12:38.730 # You requested maxclients of 10000 requiring at least 10032 max file descriptors.
18127:M 13 Apr 15:12:38.730 # Redis can't set maximum open files to 10032 because of OS error: Operation not permitted.
18127:M 13 Apr 15:12:38.730 # 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'.
以 root 身份运行时ulimit -n
,我得到:
65536
redis 用户的打开文件限制:
$ ps -u redis
PID TTY TIME CMD
18127 ? 00:00:00 redis-server
$ sudo grep 'open files' /proc/18127/limits
Max open files 4096 4096 files
如何增加 redis 用户的打开文件限制,以便它可以为 maxclients 设置设置适当的限制?我尝试编辑/etc/security/limits.conf
and sysctl -w fs.file-max=2459017
,但没有一个真正适用于 redis 用户。