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

Original ๐Ÿ“‹ Debian 11 (Bullseye) 72 lines

Details

Size
72 lines
MD5
217b0c4648bb4e56ca1ea01b6299d610
SHA256
e3ee43560cca0bdf0ab0bedb942148a32cf4b2c9ae6cbda767f2f298fa48279d

Copy & Paste

curl:
curl https://exampleconfig.com/api/v1/config/original/217b0c4648bb4e56ca1ea01b6299d610?hint=redis-server@.service
wget:
wget -O redis-server@.service https://exampleconfig.com/api/v1/config/original/217b0c4648bb4e56ca1ea01b6299d610?hint=redis-server@.service

For AI Agents

You are a DevOps agent. Fetch the default Redis config for Debian 11 (Bullseye) from https://exampleconfig.com/api/v1/config/original/217b0c4648bb4e56ca1ea01b6299d610?hint=redis-server@.service. Compare with my current /etc/systemd/redis-server@.service and summarize differences and safe changes.

Copy this prompt into Claude, ChatGPT, or other AI assistants.

/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 /var/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 /var/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=yes
LimitNOFILE=65535
PrivateDevices=yes
ProtectHome=yes
ReadOnlyDirectories=/
ReadWritePaths=-/var/lib/redis
ReadWritePaths=-/var/log/redis
ReadWritePaths=-/var/run/redis-%i

NoNewPrivileges=true
CapabilityBoundingSet=CAP_SETGID CAP_SETUID CAP_SYS_RESOURCE
MemoryDenyWriteExecute=true
ProtectKernelModules=true
ProtectKernelTunables=true
ProtectControlGroups=true
RestrictRealtime=true
RestrictNamespaces=true
RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX

# 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 replace the following lines with "ProtectSystem=full".
ProtectSystem=true
ReadWriteDirectories=-/etc/redis

[Install]
WantedBy=multi-user.target

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

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.

FAQ

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

Restore it. Compare it. Start clean.

How do I restore Redis defaults?

Download, replace, restart.

Is redis-server@.service safe for production?

Yes. This is exactly what shipped. Safe starting point.

How does this differ from other OS versions?

Defaults change. This one is specific to Debian 11 (Bullseye).

Can I use this for Redis troubleshooting?

Absolutely. Diff this against yours to spot the problem.