NFS 服务器未在启动时启动(可以手动启动)

NFS 服务器未在启动时启动(可以手动启动)

问题:我的 NFS 服务器在启动时无法导出目录。启动后,我可以 ssh 登录并手动启动服务器。我已将所有所有者:组和权限设置为非常“宽松”,以避免任何权限问题,这些问题将在问题解决后锁定。

注意:我的局域网外部无法访问此服务器。

systemctl status nfs-kernel-server.service 的输出

● nfs-server.service - NFS server and services
   Loaded: loaded (/lib/systemd/system/nfs-server.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Mon 2023-02-20 10:22:36 GMT; 27min ago
  Process: 303 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=1/FAILURE)

Feb 20 10:22:36 file-server systemd[1]: Starting NFS server and services...
Feb 20 10:22:36 file-server exportfs[303]: exportfs: Failed to stat /shared/Documents: No such file or directory
Feb 20 10:22:36 file-server exportfs[303]: exportfs: Failed to stat /shared/Downloads: No such file or directory
Feb 20 10:22:36 file-server exportfs[303]: exportfs: Failed to stat /shared/Video: No such file or directory
Feb 20 10:22:36 file-server systemd[1]: nfs-server.service: Control process exited, code=exited status=1
Feb 20 10:22:36 file-server systemd[1]: Failed to start NFS server and services.
Feb 20 10:22:36 file-server systemd[1]: nfs-server.service: Unit entered failed state.
Feb 20 10:22:36 file-server systemd[1]: nfs-server.service: Failed with result 'exit-code'.

运行 systemctl start nfs-kernel-server.service 后

systemctl status nfs-kernel-server.service 的输出

● nfs-server.service - NFS server and services
   Loaded: loaded (/lib/systemd/system/nfs-server.service; enabled; vendor preset: enabled)
   Active: active (exited) since Mon 2023-02-20 10:51:34 GMT; 1min 4s ago
  Process: 735 ExecStart=/usr/sbin/rpc.nfsd $RPCNFSDARGS (code=exited, status=0/SUCCESS)
  Process: 732 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=0/SUCCESS)
 Main PID: 735 (code=exited, status=0/SUCCESS)

Feb 20 10:51:33 file-server systemd[1]: Starting NFS server and services...
Feb 20 10:51:34 file-server systemd[1]: Started NFS server and services.

因此我可以手动启动该服务,但它不会在启动时启动。

服务器信息:

IP 地址 - 192.168.1.200(由 DHCP 分配,路由器上保留的 IP)

sda ext4 在启动时安装为 / 和 swap

sdb ext4 在启动时作为 /shared 安装

/etc/fstab

#sda1
UUID=4c5189b4-6ed8-416a-9b45-d7a8cb7d1f76 /               ext4    errors=remount-ro 0       1
#sda2
UUID=85704cdf-46ff-4a71-83a0-deebf37f9f82 none            swap    sw              0       0

#sdb1
UUID=98c91985-fe1b-43d0-8c62-a6edb9184a35 /shared ext4 nofail,sync,auto,noexec,nosuid,rw,nouser 1 2

/etc/exports

/shared/Video 192.168.1.0/24(rw,sync,no_subtree_check)
/shared/Downloads 192.168.1.0/24(rw,sync,no_subtree_check)
/shared/Documents 192.168.1.0/24(rw,sync,no_subtree_check)

挂载点 (/shared) 的所有者/权限

drwxrwxrwx 7 nobody nogroup 4096 Aug 18  2022 /shared/

/shared/* 的所有者/权限

drwxrwxrwx  27 nobody nogroup 12288 Jan 26 19:45 /shared/Documents/
drwxrwxrwx  25 nobody nogroup  4096 Aug 18  2022 /shared/Downloads/
drwx------   2 root   root    16384 Aug 18  2022 /shared/lost+found/
drwxrwxrwx 162 nobody nogroup 12288 Feb  4 15:03 /shared/Video/

(显然 lost+found 不是共享的。所有者:组和权限是递归设置的)

我可以提供任何所需的额外信息。

答案1

看起来您的 nfs 服务器在安装/shared文件系统之前启动。您应该更改.service文件。例如,您可以检查或者答案,或者阅读systemd 文档

相关内容