Debian Jessie – Set Open Files Limit for Redis User

debiandebian-jessieredis

When starting redis 3.0.6 (installed from jessie-backports) under Debian 8.4 jessie, I get the following warning/error:

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'.

When running ulimit -n as root I get:

65536

The open file limit for the redis user:

$ 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

How do I increase the open files limit for the redis user, so it can set the appropriate limit for the maxclients setting? I tried editing /etc/security/limits.conf and sysctl -w fs.file-max=2459017, but none really worked for the redis user.

Best Answer

limits.conf does not apply to systemd services (https://bugzilla.redhat.com/show_bug.cgi?id=754285)

so you should:

  1. edit /lib/systemd/system/redis-server.service and add to the [Service] section the line (after: User=redis and Group=redis) LimitNOFILE=65536

  2. run: systemctl daemon-reload && systemctl restart redis-server

and ... it should get the new limit

check: https://sskaje.me/systemd-ulimit/

good luck!