在带有 systemd 的 centos 7 上,rpcbind 未在启动时启动

在带有 systemd 的 centos 7 上,rpcbind 未在启动时启动

我需要在启动后激活 rpcbind 服务,因此我使用 yum 安装它,然后通过以下方式启动它:

systemctl start rpcbind

它可以工作。但是重启后它没有启动。所以我用以下方法检查了一下:

systemctl is-enabled rpcbind

结果显示:静止的这意味着其他一些服务需要它来启动,该服务是 rpcbind.socket,所以我检查了它,rpcbind.socked 显示它已启用(systemctl is-enabled rpcbind.socket 返回已启用)但它没有按应有的方式工作

启动后执行:

systemctl status rpcbind

它显示:失败(死亡)

我已经搜索了一段时间但没有任何运气,如果有人知道解决这个问题的方法或者以前遇到过这个问题那么请帮忙。

我正在使用 centos 7.1

如果你需要更多信息,我明天上班时可以得到

答案1

我在 Debian 8 又名 Jessie 上遇到了同样的问题,尽管系统不同,此解决方案如果您不介意修改配置文件的话,这可能会有所帮助。

创建文件/etc/tmpfiles.d/rpcbind.conf

#Type Path        Mode UID  GID  Age Argument
d     /run/rpcbind 0755 root root - -
f     /run/rpcbind/rpcbind.xdr 0600 root root - -
f     /run/rpcbind/portmap.xdr 0600 root root - -

创造/etc/systemd/system/rpcbind.service

[Unit]
Description=RPC bind portmap service
After=systemd-tmpfiles-setup.service
Wants=remote-fs-pre.target
Before=remote-fs-pre.target
DefaultDependencies=no

[Service]
ExecStart=/sbin/rpcbind -f -w
KillMode=process
Restart=on-failure

[Install]
WantedBy=sysinit.target
Alias=portmap

并启用上述单位:

# systemctl enable rpcbind.service

创造/etc/systemd/system/nfs-common.service

[Unit]
Description=NFS Common daemons
Wants=remote-fs-pre.target
DefaultDependencies=no

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/etc/init.d/nfs-common start
ExecStop=/etc/init.d/nfs-common stop

[Install]
WantedBy=sysinit.target

使用以下命令启用它:

# systemctl enable nfs-common

据推测,这对 CentOS 也同样有效。

似乎还有一个较新版本的 rpcbind-0.2.3,它具有原生 systemd 支持,但还没试过...

答案2

在 centos 7.4 上,简单修复:

创建文件:/etc/systemd/system/nfs-client.target.d/10-rpcbind.conf内容如下:

[Unit]
Wants=rpcbind.service

禁用并重新启用 rpcbind

sudo systemctl disable rpcbind
sudo systemctl enable rpcbind

重新开始

相关内容