Centos 7 中无法启动 NFS:无法发出方法调用:没有这样的文件或目录

Centos 7 中无法启动 NFS:无法发出方法调用:没有这样的文件或目录

我无法在 CentOS7 中启动 NFS 服务器。

下载的包:

yum -y install nfs-utils
yum -y install nfs-utils-lib

启用/启动服务

systemctl enable/start rpcbind
systemctl enable/start nfs-server
systemctl enable/start nfs-lock
systemctl enable/start nfs-idmap

这导致 :

systemctl enable nfs-lock
Failed to issue method call: No such file or directory
systemctl enable nfs-idmap
Failed to issue method call: No such file or directory

创建共享:

mkdir -p /test
chmod 777 /test

出口罚款:

exportfs
/test           clientip/24

但是,在执行systemctlrestart时nfs-server,它失败并出现依赖错误,journalctl显示:

[user@server /]# journalctl -xn | grep failed
-- Subject: Unit proc-fs-nfsd.mount has failed
-- Unit proc-fs-nfsd.mount has failed.
-- The result is failed.
Jun 23 17:06:41 server systemd[1]: Dependency failed for NFS server and services.
-- Subject: Unit nfs-server.service has failed
-- Unit nfs-server.service has failed.
Jun 23 17:06:41 server systemd[1]: Dependency failed for NFS Mount Daemon.
-- Subject: Unit nfs-mountd.service has failed
-- Unit nfs-mountd.service has failed.
Jun 23 17:06:41 open

并且systemctl列表单位状态也显示失败

systemctl list-units | grep nfs
proc-fs-nfsd.mount                      loaded failed failed    NFSD configuration filesystem
var-lib-nfs-rpc_pipefs.mount            loaded failed failed    RPC Pipe File System
nfs-config.service                      loaded active exited    Preprocess NFS configuration
nfs-idmapd.service                      loaded failed failed    NFSv4 ID-name mapping service

/var/log/messages:

Jun 23 17:06:41 server systemd: Dependency failed for RPC security service for NFS server.
Jun 23 17:06:41 server systemd: Dependency failed for RPC security service for NFS client and server.
Jun 23 17:06:41 server systemd: Unit var-lib-nfs-rpc_pipefs.mount entered failed state.
Jun 23 17:06:41 server systemd: nfs-idmapd.service: control process exited, code=exited status=1
Jun 23 17:06:41 server systemd: Unit nfs-idmapd.service entered failed state.
Jun 23 17:06:41 server systemd: proc-fs-nfsd.mount mount process exited, code=exited status=32
Jun 23 17:06:41 server systemd: Dependency failed for NFS server and services.
Jun 23 17:06:41 server systemd: Dependency failed for NFS Mount Daemon.
Jun 23 17:06:41 server systemd: Unit proc-fs-nfsd.mount entered failed state.
Jun 23 17:12:53 server mount: mount: unknown filesystem type 'nfsd'
Jun 23 17:12:53 server systemd: proc-fs-nfsd.mount mount process exited, code=exited status=32
Jun 23 17:12:53 server rpc.idmapd[842]: main: open(/var/lib/nfs/rpc_pipefs//nfs): No such file or directory
Jun 23 17:12:53 server systemd: Dependency failed for NFS server and services.
Jun 23 17:12:53 server systemd: Dependency failed for NFSv4 ID-name mapping service.
Jun 23 17:12:53 server systemd: Dependency failed for NFS Mount Daemon.
Jun 23 17:12:53 server systemd: Unit proc-fs-nfsd.mount entered failed state.

客户反映,按照上面的错误,我认为是正常的:

RPC: Remote system errorRPC: Port mapper failure - RPC: Timed out.

答案1

我通过 @user136564 的帖子解决了这个问题。

这解决了我的问题https://www.centos.org/forums/viewtopic.php?f=47&t=53896

我发现我的问题是 rpcbind 不会在启动时启动,即使我在 systemd 中启用了它并且我可以手动启动它。

这些命令是我在 CentOS Linux 版本 7.2.1511(核心)上执行的操作

安装 nfs-utils

yum install -y nfs-utils

将文本附加到/etc/fstab

192.168.1.100:/mnt/nfs-server /mnt/nfs-client nfs defaults,nofail,x-systemd.automount 0 0

有些文章说noauto,x-systemd.automount更好,但noauto对我来说没有效果。

检查挂载是否有效

systemctl start rpcbind
systemctl enable rpcbind
mount -a

修复 CentOS 7 启动时无法自动挂载 NFS 的问题

将文本附加到 /usr/lib/systemd/system/nfs-idmap.service 的末尾
[Install]
WantedBy=multi-user.target
将文本附加到 /usr/lib/systemd/system/nfs-lock.service 的末尾
[Install]
WantedBy=nfs.target

启用相关服务

systemctl enable nfs-idmapd.service 
systemctl enable rpc-statd.service 

systemctl enable rpcbind.socket

systemctl status nfs-idmapd.service -l
systemctl status rpc-statd.service –l

然后重新启动操作系统,我明白了。

shutdown -r now

相关内容