Redis /etc/systemd/redis-server@.service

Authentic ๐Ÿ“‹ Ubuntu 24.04 LTS (Noble Numbat) 92 lines
๐Ÿ“ฅ Download

Compatibility

Currently viewing:
Ubuntu 24.04 LTS (Noble Numbat)
Also compatible:
Debian 12 (Bookworm)
Different versions:

File Info

Size
92 lines
MD5
3450c61e28809e6d1d5c49d0beec589a
SHA256
b97b4c0ce03dbdf2b2631f8af7c6ff38d10228c083cd8e683e11dac391ff1e9d

Quick Commands

curl:
curl https://exampleconfig.com/api/v1/config/original/3450c61e28809e6d1d5c49d0beec589a?hint=redis-server@.service
wget:
wget -O redis-server@.service https://exampleconfig.com/api/v1/config/original/3450c61e28809e6d1d5c49d0beec589a?hint=redis-server@.service
/etc/systemd/redis-server@.service
# Templated service file for redis-server(1)
#
# Each instance of redis-server requires its own configuration file:
#
#   $ cp /etc/redis/redis.conf /etc/redis/redis-myname.conf
#   $ chown redis:redis /etc/redis/redis-myname.conf
#
# Ensure each instance is using their own database:
#
#   $ sed -i -e 's@^dbfilename .*@dbfilename dump-myname.rdb@' /etc/redis/redis-myname.conf
#
# We then listen exlusively on UNIX sockets to avoid TCP port collisions:
#
#   $ sed -i -e 's@^port .*@port 0@' /etc/redis/redis-myname.conf
#   $ sed -i -e 's@^\(# \)\{0,1\}unixsocket .*@unixsocket /run/redis-myname/redis-server.sock@' /etc/redis/redis-myname.conf
#
# ... and ensure we are logging, etc. in a unique location:
#
#   $ sed -i -e 's@^logfile .*@logfile /var/log/redis/redis-server-myname.log@' /etc/redis/redis-myname.conf
#   $ sed -i -e 's@^pidfile .*@pidfile /run/redis-myname/redis-server.pid@' /etc/redis/redis-myname.conf
#
# We can then start the service as follows, validating we are using our own
# configuration:
#
#   $ systemctl start redis-server@myname.service
#   $ redis-cli -s /run/redis-myname/redis-server.sock info | grep config_file
#
#  -- Chris Lamb <lamby@debian.org>  Mon, 09 Oct 2017 22:17:24 +0100
[Unit]
Description=Advanced key-value store (%I)
After=network.target
Documentation=http://redis.io/documentation, man:redis-server(1)

[Service]
Type=notify
ExecStart=/usr/bin/redis-server /etc/redis/redis-%i.conf --supervised systemd --daemonize no
PIDFile=/run/redis-%i/redis-server.pid
TimeoutStopSec=0
Restart=always
User=redis
Group=redis
RuntimeDirectory=redis-%i
RuntimeDirectoryMode=2755

UMask=007
PrivateTmp=true
LimitNOFILE=65535
PrivateDevices=true
ProtectHome=true
ProtectSystem=strict
ReadWritePaths=-/var/lib/redis
ReadWritePaths=-/var/log/redis
ReadWritePaths=-/var/run/redis-%i

CapabilityBoundingSet=
LockPersonality=true
MemoryDenyWriteExecute=true
NoNewPrivileges=true
PrivateUsers=true
ProtectClock=true
ProtectControlGroups=true
ProtectHostname=true
ProtectKernelLogs=true
ProtectKernelModules=true
ProtectKernelTunables=true
ProtectProc=invisible
RemoveIPC=true
RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX
RestrictNamespaces=true
RestrictRealtime=true
RestrictSUIDSGID=true
SystemCallArchitectures=native
SystemCallFilter=@system-service
SystemCallFilter=~ @privileged @resources

# redis-server can write to its own config file when in cluster mode so we
# permit writing there by default. If you are not using this feature, it is
# recommended that you remove this line.
ReadWriteDirectories=-/etc/redis

# This restricts this service from executing binaries other than redis-server
# itself. This is really effective at e.g. making it impossible to an
# attacker to spawn a shell on the system, but might be more restrictive
# than desired. If you need to, you can permit the execution of extra
# binaries by adding an extra ExecPaths= directive with the command
# systemctl edit redis-server.service
NoExecPaths=/
ExecPaths=/usr/bin/redis-server /usr/lib /lib

[Install]
WantedBy=multi-user.target

How to Install Redis

Alpine Linux

sudo apk add redis

Debian

sudo apt update && sudo apt install redis-server

Ubuntu

sudo apt update && sudo apt install redis-server

Configuration File Location

File Path
/etc/systemd/redis-server@.service
Directory
/etc/systemd/
Significance
System-wide configuration directory
Description
Files in /etc/ contain system-wide configuration settings that affect all users.

Complete Redis Configuration Guide

What is redis-server@.service?
Access the original 'redis-server@.service' (redis.conf) configuration file from a fresh Redis installation on Ubuntu 24.04 LTS (Noble Numbat). This is the factory-default configuration for the world's most popular in-memory database, perfect for caching optimization, session management, and real-time application development.
Technical Details
Located at '/etc/systemd/redis-server@.service', this 92-line file controls memory policies, persistence options, clustering settings, pub/sub configurations, and security parameters. Powers caching for Twitter, GitHub, Instagram, and millions of high-performance applications requiring sub-millisecond response times.
Common Configuration Question
How do you configure Redis for optimal caching, session storage, and real-time features on Ubuntu 24.04?
Why Use This Configuration?
This default configuration includes memory optimization, persistence strategies, and clustering support. Essential for backend developers, DevOps engineers, and architects building scalable applications with caching, queues, and real-time features.

Frequently Asked Questions

When should I use this redis-server@.service file?

Use this original configuration file when you need to restore Redis to its default state after misconfiguration, during fresh installations, or as a baseline for customization. It's particularly useful for troubleshooting when your current config isn't working properly.

How do I restore Redis to default settings?

Download this file and replace your current configuration at /etc/systemd/redis-server@.service. Make sure to backup your existing configuration first, then restart the Redis service to apply the changes.

Is this redis-server@.service file secure for production use?

This is the factory-default configuration that ships with Redis on Ubuntu 24.04 LTS (Noble Numbat). While it provides a secure baseline, you should review and customize security settings based on your specific production requirements and compliance needs.

What's the difference between this and other OS versions?

This configuration is specifically from Ubuntu 24.04 LTS (Noble Numbat). Different operating systems and versions may have slightly different default settings, security patches, or feature availability. Check the compatibility section above for other OS versions.

Can I use this configuration file for Redis troubleshooting?

Yes, this original configuration is excellent for troubleshooting. Compare it with your current settings to identify modifications that might be causing issues, or temporarily replace your config with this one to isolate problems.