Linux   发布时间:2022-04-01  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了nfs – Systemd:在另一个单元真正启动后启动一个单元大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

在我的特殊情况下,我想在所有glusterfs完全启动后启动remote-fs单元. 我的systemd文件: glusterfs目标: node04:/usr/lib/systemd/system # cat glusterfsd.service [Unit] Description=GlusterFS brick processes (stopping only) After=network
在我的特殊情况下,我想在所有glusterfs完全启动后启动remote-fs单元.

我的systemd文件

glusterfs目标:

node04:/usr/lib/systemd/system # cat glusterfsd.service 
[Unit]
Description=GlusterFS brick processes (stopping only)
After=network.target glusterd.service

[service]
Type=oneshot
ExecStart=/bin/true
RemainAfterExit=yes
ExecStop=/bin/sh -c "/bin/killall --wait glusterfsd || /bin/true"
ExecReload=/bin/sh -c "/bin/killall -HUP glusterfsd || /bin/true"

[Install]
WantedBy=multi-user.target

remote-fs目标:

node04:/usr/lib/systemd/system # cat remote-fs.target 
[Unit]
Description=Remote File Systems
Documentation=man:systemd.special(7)
requires=glusterfsd.service
After=glusterfsd.service remote-fs-pre.target
DefaultDependencies=no
Conflicts=shutdown.target

[Install]
WantedBy=multi-user.target

好的,所有Gluster守护进程都开始成功,我想通过NFS挂载Gluster文件系统,但Gluster的NFS共享在glusterfs.service启动后没有立即准备就绪,但几秒钟之后,所以通常remote-fs无法挂载它甚至关于requires和指令后.

我们来看看日志:

Apr 14 16:16:22 node04 systemd[1]: Started GlusterFS,a clustered file-system server.
Apr 14 16:16:22 node04 systemd[1]: StarTing GlusterFS brick processes (stopping only)...
Apr 14 16:16:22 node04 systemd[1]: StarTing Network is Online.
Apr 14 16:16:22 node04 systemd[1]: Reached target Network is Online.
Apr 14 16:16:22 node04 systemd[1]: MounTing /stor...

这里一切正常,远程文件系统(/ stor)似乎是在glusterfs启动后挂载,因为它意味着要根据单元文件…但接下来的行是:

//...skipped.....
Apr 14 16:16:22 node04 systemd[1]: Started GlusterFS brick processes (stopping only).

什么? GlusterFS只为这一刻准备好了!然后我们看到:

//...skipped.....
Apr 14 16:16:23 node04 mount[2960]: mount.nfs: mounTing node04:/stor Failed,reason given by server: No such file or directory
Apr 14 16:16:23 node04 systemd[1]: stor.mount mount process exited,code=exited status=32
Apr 14 16:16:23 node04 systemd[1]: Failed to mount /stor.
Apr 14 16:16:23 node04 systemd[1]: Dependency Failed for Remote File Systems.
Apr 14 16:16:23 node04 systemd[1]: Unit stor.mount entered Failed state.

安装失败,因为当systemd尝试装入存储时NFS服务器未就绪.

由于systemd启动过程的非确定性,有时(大约10个引导中的1个)在启动时安装此文件系统成功.

如果onboot mount不成功,我可以登录到服务器并手动挂载/ stor目录,因此Gluster的NFS服务似乎工作正常.

那么如何在glusterfsd之后启动remote-fs,即在启动GlusterFS砖进程行之后出现在日志中?

remote-fs似乎是最后一个目标之一,所以我无法在另一个解决方法”目标之后启动它,而这个目标实际上并不是remote-fs所要求的.

解决方法

您可以@R_785_6749@分析systemd启动顺序.使用支持Web浏览器的SVG查看输出文件.
systemd-analyze plot > test.svg

该绘图将为您提供上次启动的时间统计信息,这将为您提供更明确的问题观点.

我通过在/etc/rc.local中@L_5_43@mount命令解决了我的NFS挂载问题.但是我不确定,它是否适用于glusterd集成,值得尝试快速修复.为了使systemd运行rc.local你应该满足以下条件:

# grep Condition /usr/lib/systemd/system/rc-local.service
ConditionFileIsExecutable=/etc/rc.d/rc.local

大佬总结

以上是大佬教程为你收集整理的nfs – Systemd:在另一个单元真正启动后启动一个单元全部内容,希望文章能够帮你解决nfs – Systemd:在另一个单元真正启动后启动一个单元所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。