Debian

如何解決 systemd (code=exited, status=227/NO_NEW_PRIVILEGES)?

  • October 23, 2021

我正在嘗試在 Debian Stretch 系統上安裝 GitLab 社區包,但它的依賴項之一redis-server在使用 systemd 啟動服務時無法安裝。

完整的日誌:

$ sudo dpkg --configure redis-server
Setting up redis-server (3:3.2.5-4) ...
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.
invoke-rc.d: initscript redis-server, action "start" failed.
● redis-server.service - Advanced key-value store
  Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor preset: enabled)
  Active: activating (auto-restart) (Result: exit-code) since Thu 2016-12-15 15:00:17 UTC; 31ms ago
Docs: http://redis.io/documentation,
      man:redis-server(1)
 Process: 8764 ExecStart=/usr/bin/redis-server /etc/redis/redis.conf (code=exited, status=227/NO_NEW_PRIVILEGES)
 Process: 8761 ExecStartPre=/bin/run-parts --verbose /etc/redis/redis-server.pre-up.d (code=exited, status=227/NO_NEW_PRIVILEGES)
Main PID: 24283 (code=exited, status=227/NO_NEW_PRIVILEGES)

Dec 15 15:00:17 Serverdatorn-Debian systemd[1]: redis-server.service: Unit entered failed state.
Dec 15 15:00:17 Serverdatorn-Debian systemd[1]: redis-server.service: Failed with result 'exit-code'.
dpkg: error processing package redis-server (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
redis-server

通過手動執行執行檔來啟動 redis-server 可以完美執行:

$ sudo /usr/bin/redis-server /etc/redis/redis.conf
$ sudo tail /var/log/redis/redis-server.log
...
* The server is now ready to accept connections on port 6379

如果您希望我提供任何其他資訊,請告訴我。

編輯:

我嘗試在文件中設置NoNewPrivileges兩者yes,重新載入並再次啟動它,但沒有運氣,同樣的錯誤。我確實發現執行顯示了另一條可能有用的消息:no``redis.service``journalctl -xe

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

我猜你遇到了systemd NoNewPrivileges=指令的這個結果。假設該redis-server軟體包通常適用於 Ubuntu 16.04 系統,這表明您的系統可能會自定義全域設置NoNewPrivileges=或導致 Redis 無法啟動的相關指令。

閱讀連結 about 的文件NoNewPrivileges=和相關指令,然後在您的/etc/systemd/目錄中搜尋以查看是否在您的系統上自定義了這些值。如果不是,請確認 redis您正在安裝的軟體包確實在您正在安裝的作業系統版本上受支持。

引用自:https://unix.stackexchange.com/questions/330637