Redis /etc/systemd/redis-server.service

原始 📋 Debian 10 (Buster) 46 行

详情

大小
46 行
MD5
43668088e55a34403b467c28f1e87f20
SHA256
90d77171e33f66eb8cc55710fb68f1cc3c9a860c2733bb347de1668e13434999
/etc/systemd/redis-server.service
[Unit]
Description=Advanced key-value store
After=network.target
Documentation=http://redis.io/documentation, man:redis-server(1)

[Service]
Type=forking
ExecStart=/usr/bin/redis-server /etc/redis/redis.conf
ExecStop=/bin/kill -s TERM $MAINPID
PIDFile=/run/redis/redis-server.pid
TimeoutStopSec=0
Restart=always
User=redis
Group=redis
RuntimeDirectory=redis
RuntimeDirectoryMode=2755

UMask=007
PrivateTmp=yes
LimitNOFILE=65535
PrivateDevices=yes
ProtectHome=yes
ReadOnlyDirectories=/
ReadWriteDirectories=-/var/lib/redis
ReadWriteDirectories=-/var/log/redis
ReadWriteDirectories=-/var/run/redis

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
Alias=redis.service

复制粘贴

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

给 AI Agent 用

<prompt><role>DevOps agent</role><source url='https://exampleconfig.com/api/v1/config/original/43668088e55a34403b467c28f1e87f20?hint=redis-server.service' /><config><app>Redis</app><os>Debian 10 (Buster)</os><location>/etc/systemd/redis-server.service</location><lines>46</lines><md5>43668088e55a34403b467c28f1e87f20</md5><sha256>90d77171e33f66eb8cc55710fb68f1cc3c9a860c2733bb347de1668e13434999</sha256></config></prompt>

粘贴到 Claude、ChatGPT 或任何 AI 助手里。

安装 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

文件位置

文件路径
/etc/systemd/redis-server.service
目录
/etc/systemd/
用途
系统级配置目录
说明
/etc/ 里的文件是系统级配置,影响所有用户。

FAQ

什么时候该用这个 redis-server.service?

用来恢复缺失的默认文件、确认发行版本带了什么,或拿你的 Redis config 做 diff。

怎么恢复 Redis 的默认配置?

下载文件,把 /etc/systemd/redis-server.service 里的当前配置备份好,替换掉,然后 reload 或 restart Redis。

redis-server.service 适合直接上生产吗?

这是 Debian 10 (Buster) 的厂商默认配置,只能当基线。上生产前请检查安全和性能设置。

和其他 OS 版本有什么不同?

默认值会随发行版和版本变化,这份对应 Debian 10 (Buster)。

我可以用它来排查 Redis 吗?

可以。和你的配置做 diff 找出漂移,然后只恢复需要的段落。