透過 Systemd 安裝 Gluster

透過 Systemd 安裝 Gluster

我需要在啟動時安裝一個 gluster 磁碟區。將其放在 /etc/fstab 中不會產生可靠的結果。

我設定了以下 systemd 服務:

[Unit]
Description=Gluster Mount

[Service]
Type=oneshot
ExecStart=/bin/mount /data
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99

[Install]
WantedBy=multi-user.target

當此服務在啟動時運行時,它會傳回以下內容:

root@web1:~# systemctl status gluster-mount.service
â gluster-mount.service - Gluster Mount
   Loaded: loaded (/etc/systemd/system/gluster-mount.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Tue 2018-03-13 04:05:43 UTC; 3min 20s ago
  Process: 627 ExecStart=/bin/mount /data (code=exited, status=1/FAILURE)
 Main PID: 627 (code=exited, status=1/FAILURE)

Mar 13 04:05:39 web1 systemd[1]: Starting Gluster     Mount...
Mar 13 04:05:43 web1 systemd[1]: gluster-mount.service: Main process exited, code=exited, status=1/FAILURE
Mar 13 04:05:43 web1 systemd[1]: Failed to start Gluster Mount.
Mar 13 04:05:43 web1 systemd[1]: gluster-mount.service: Unit entered failed state.
Mar 13 04:05:43 web1 systemd[1]: gluster-mount.service: Failed with result 'exit-code'.

當我登入後對此服務發出“重新啟動”命令時,它工作正常。我缺什麼?

答案1

所以,改變類型即可idle解決問題。根據定義,該idle類型將等到其他所有內容都已分派後再處理該服務請求。我有一種預感,這與時間有關,這是唯一真正糾正問題的方法。

[Unit]
Description=Gluster Mount

[Service]
Type=idle
ExecStart=/bin/mount /data
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99

[Install]
WantedBy=multi-user.target

相關內容