Debian 8.4 jessie为redis用户设置了打开的文件限制

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.confsysctl -w fs.file-max=2459017 ,但是没有一个真正用于redis用户。

limits.conf不适用于systemd服务( https://bugzilla.redhat.com/show_bug.cgi?id=754285

所以你应该:

  1. 编辑/lib/systemd/system/redis-server.service并添加到[Service]部分的行(在User=redisGroup=redisLimitNOFILE=65536

  2. 运行: systemctl daemon-reload && systemctl restart redis-server

而且……它应该得到新的极限

检查: https : //sskaje.me/systemd-ulimit/

祝你好运!