When Redis fails to start via systemctl on CentOS 7 despite manual execution working, we're typically dealing with either:
- Systemd unit file misconfiguration
- Resource limitations (file descriptors)
- Permission/security context issues
The critical error message reveals the root cause:
[1972] 29 Jul 18:52:16.258 # Redis can't set maximum open files to 10032 because of OS error: Operation not permitted.
[1972] 29 Jul 18:52:16.258 # Current maximum open files is 1024.
This indicates Redis requires more file descriptors than the current user limit allows.
1. Adjusting System Limits
Create a dedicated limits configuration for Redis:
echo "redis soft nofile 10032" >> /etc/security/limits.conf
echo "redis hard nofile 10032" >> /etc/security/limits.conf
2. Modifying the Systemd Service File
Edit the Redis systemd unit to properly handle limits:
# Create override directory if it doesn't exist
mkdir -p /etc/systemd/system/redis-server.service.d/
# Create limit configuration
cat > /etc/systemd/system/redis-server.service.d/limits.conf << EOF
[Service]
LimitNOFILE=10032
EOF
3. Fixing the Overcommit Memory Warning
Address the memory configuration warning:
echo "vm.overcommit_memory = 1" >> /etc/sysctl.conf
sysctl -p
4. SELinux Context Considerations
If SELinux is enforcing, check and correct the context:
# Check SELinux status
sestatus
# If enforcing, correct context
semanage fcontext -a -t redis_var_lib_t '/var/lib/redis(/.*)?'
restorecon -Rv /var/lib/redis
After implementing all changes:
systemctl daemon-reload
systemctl restart redis-server
systemctl status redis-server
Check the journal for detailed errors if issues persist:
journalctl -xe -u redis-server
For memory-constrained environments (512MB VPS), consider adjusting Redis config:
# /etc/redis.conf
maxclients 4064
maxmemory 256mb
maxmemory-policy allkeys-lru
When attempting to start Redis via systemctl start redis-server
on CentOS 7, many administrators encounter a puzzling situation where the command fails silently. The service appears to start briefly (as seen in systemctl status
output) but immediately terminates.
The /var/log/redis/redis.log
reveals two critical warnings:
[1972] 29 Jul 18:52:16.258 # Redis can't set maximum open files to 10032 because of OS error: Operation not permitted.
[1972] 29 Jul 18:52:16.258 # Current maximum open files is 1024. maxclients has been reduced to 4064
[1972] 29 Jul 18:52:16.259 # WARNING overcommit_memory is set to 0!
The primary issues stem from:
- Insufficient file descriptor limits (ulimit)
- Improper memory overcommit settings
- Systemd service unit configuration mismatch
Step 1: Permanently increase file descriptors
# Add to /etc/security/limits.conf
redis soft nofile 10032
redis hard nofile 10032
# Verify with:
su - redis -c 'ulimit -n'
Step 2: Configure memory overcommit
echo "vm.overcommit_memory = 1" >> /etc/sysctl.conf
sysctl -p
Step 3: Modify systemd service unit
# Create override file
mkdir -p /etc/systemd/system/redis-server.service.d
cat > /etc/systemd/system/redis-server.service.d/limits.conf <
After implementing these changes:
systemctl start redis-server
systemctl status redis-server
redis-cli ping
Expected successful output:
PONG
For low-memory VPS environments (like 512MB), consider these redis.conf adjustments:
maxclients 1000
maxmemory 256mb
maxmemory-policy allkeys-lru
If issues persist, check:
journalctl -u redis-server -f
strace -f systemctl start redis-server
ls -l /var/run/redis.pid