通过 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

相关内容