5

升级 Debian 后,启动时出现问题redis-server.service。在我的输出中,journalctl -xe我看到以下内容:

redis-server.service: Failed at step NAMESPACE spawning /usr/bin/redis-server: Stale file handle.

我无法启动 redis-server.service 并且在systemctl start redis-server我的输出中:

Job for redis-server.service failed because the control process exited with error code.
See "systemctl status redis-server.service" and "journalctl -xe" for details.

systemctl status redis-server我的输出中:

● redis-server.service - Advanced key-value store
   Loaded: loaded (/lib/systemd/system/redis-server.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Mon 2018-01-29 10:29:08 MSK; 58s ago
     Docs: http://redis.io/documentation,
           man:redis-server(1)
  Process: 11701 ExecStop=/bin/kill -s TERM $MAINPID (code=exited, status=226/NAMESPACE)
  Process: 11720 ExecStart=/usr/bin/redis-server /etc/redis/redis.conf (code=exited, status=226/NAMESPACE)
 Main PID: 10193 (code=exited, status=0/SUCCESS)

Jan 29 10:29:08 xxx systemd[1]: redis-server.service: Service hold-off time over, scheduling restart.
Jan 29 10:29:08 xxx systemd[1]: redis-server.service: Scheduled restart job, restart counter is at 5.
Jan 29 10:29:08 xxx systemd[1]: Stopped Advanced key-value store.

我的问题是如何解决这个问题并启动 redis-server.service?

4

3 回答 3

3

找到了解决方法:

/lib/systemd/system/redis-server.service以 root 身份使用编辑服务文件,注释掉不同的字段,试图找出故障发生的位置并重新启动 systemd(通过systemctl daemon-reload, systemctl stop redis-server, systemctl start redis-server

对我来说,问题是 redis-server.service 文件中的以下行:

ReadOnlyDirectories=/

我已将其注释掉并允许 redis-server 成功启动。

所以我现在/lib/systemd/system/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=/var/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
#Modified 20180129 to avoid issue to start redis
#redis-server.service: Failed at step NAMESPACE spawning /usr/bin/redis-server: Stale file handle
#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
于 2018-01-29T07:41:01.207 回答
1

我刚刚在运行后遇到了这个问题,sudo apt -y dist-upgrade并得到了这个略有不同的错误/var/log/syslog

redis-server.service: Failed at step NAMESPACE spawning /usr/bin/redis-server: Invalid argument

解决方案 Launchpad Bug 1638410是:

sudo systemctl edit redis-server

[Service]
ProtectHome=no

保存退出编辑器,完成升级:

sudo apt install -f

cat /etc/os-release

NAME="Ubuntu"
VERSION="16.04.5 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04.5 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
VERSION_CODENAME=xenial
UBUNTU_CODENAME=xenial


$ apt policy redis-server

redis-server:
  Installed: 5:5.0.0-3chl1~xenial1
  Candidate: 5:5.0.0-3chl1~xenial1
  Version table:
 *** 5:5.0.0-3chl1~xenial1 500
        500 http://ppa.launchpad.net/chris-lea/redis-server/ubuntu xenial/main amd64 Packages
        100 /var/lib/dpkg/status
     2:3.0.6-1 500
        500 http://archive.ubuntu.com/ubuntu xenial/universe amd64 Packages
于 2018-11-04T02:34:29.743 回答
0

如果您使用的是 Ubuntu,请在

/etc/redis/redis.conf 你应该有 :

supervised systemd

于 2019-12-22T16:24:16.103 回答