mount.nfs:资源暂时不可用:未安装在客户端计算机上

mount.nfs:资源暂时不可用:未安装在客户端计算机上

我遵循了这里概述的步骤:https://www.howtoforge.com/how-to-install-nfs-server-and-client-on-ubuntu-22-04/

在一台 Ubuntu 22.04 VPS (NFS 服务器)中:

已安装 nfs-kernel-server

root@k8s-eu-1-worker-1:~# sudo apt install nfs-kernel-server

并启用它

root@k8s-eu-1-worker-1:~# sudo systemctl is-enabled nfs-server
enabled

root@k8s-eu-1-worker-1:~# sudo systemctl status nfs-server
● nfs-server.service - NFS server and services
     Loaded: loaded (/lib/systemd/system/nfs-server.service; enabled; vendor preset: enabled)
     Active: active (exited) since Wed 2023-11-01 20:56:05 CET; 34s ago
   Main PID: 2098 (code=exited, status=0/SUCCESS)
        CPU: 13ms

Nov 01 20:56:05 k8s-eu-1-worker-1 systemd[1]: Starting NFS server and services...
Nov 01 20:56:05 k8s-eu-1-worker-1 exportfs[2097]: exportfs: can't open /etc/exports for reading
Nov 01 20:56:05 k8s-eu-1-worker-1 systemd[1]: Finished NFS server and services.

root@k8s-eu-1-worker-1:~# cat /proc/fs/nfsd/versions
-2 +3 +4 +4.1 +4.2

我已经设置了共享目录:

root@k8s-eu-1-worker-1:~# sudo mkdir -p /srv/backups /mnt/shared
root@k8s-eu-1-worker-1:~# sudo chown -R nobody:nogroup /srv/backups /mnt/shared
root@k8s-eu-1-worker-1:~# sudo chmod 777 /srv/backups /mnt/shared

root@k8s-eu-1-worker-1:~# cat /etc/exports 
# /etc/exports: the access control list for filesystems which may be exported
#       to NFS clients.  See exports(5).
#
# Example for NFSv2 and NFSv3:
# /srv/homes       hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check)
#
# Example for NFSv4:
# /srv/nfs4        gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check)
# /srv/nfs4/homes  gss/krb5i(rw,sync,no_subtree_check)
#
/srv/backups  192.168.5.100(rw,sync,no_subtree_check)
/mnt/shared 192.168.10.0/24(rw,sync,no_subtree_check)

重新启动 NFS 服务器

root@k8s-eu-1-worker-1:~# sudo systemctl restart nfs-server
root@k8s-eu-1-worker-1:~# sudo systemctl status nfs-server
● nfs-server.service - NFS server and services
     Loaded: loaded (/lib/systemd/system/nfs-server.service; enabled; vendor preset: enabled)
     Active: active (exited) since Wed 2023-11-01 21:05:28 CET; 12s ago
    Process: 2758 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=0/SUCCESS)
    Process: 2759 ExecStart=/usr/sbin/rpc.nfsd (code=exited, status=0/SUCCESS)
   Main PID: 2759 (code=exited, status=0/SUCCESS)
        CPU: 16ms

Nov 01 21:05:28 k8s-eu-1-worker-1 systemd[1]: Starting NFS server and services...
Nov 01 21:05:28 k8s-eu-1-worker-1 systemd[1]: Finished NFS server and services.

并检查 NFS 服务器上可用的共享目录:

root@k8s-eu-1-worker-1:~# sudo exportfs -v
/srv/backups    192.168.5.100(sync,wdelay,hide,no_subtree_check,sec=sys,rw,secure,root_squash,no_all_squash)
/mnt/shared     192.168.10.0/24(sync,wdelay,hide,no_subtree_check,sec=sys,rw,secure,root_squash,no_all_squash)

在另一个 Ubuntu 22.04 VPS (NFS 客户端) 中:

我安装了 nfs-common

root@k8s-eu-1-master:~# sudo apt install nfs-common

我已经设置了共享目录

root@k8s-eu-1-master:~# sudo mkdir -p /mnt/data

但是我收到此错误:mount.nfs: Resource temporarily unavailable 当我尝试将共享目录“/srv/backups”挂载到目标目录“/mnt/data”时:

root@k8s-eu-1-master:~# sudo mount nfs_server_ip:/srv/backups /mnt/data
mount.nfs: Resource temporarily unavailable

已完成检查(根据此处的迹象:无法在 Ubuntu 22.04 上挂载 nfs):

从“服务器” ping“客户端” 和反之亦然

/etc/fstabCLIENTVPS 中:

root@k8s-eu-1-master:~# cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda2 during installation
UUID=4f2f752a-bc7e-405f-8dbd-919cee645fab /               ext4    errors=remount-ro 0       0
# /boot was on /dev/sda1 during installation
UUID=6ff53e6c-17f5-48a4-bb01-44851a39fa1e /boot           ext4    defaults,noatime        0       0

nfs_server_ip:/srv/backups    /mnt/data   nfs auto,ext4,nofail,noatime,nolock,intr,tcp,actimeo=1800 0 0

尝试了不同版本的“sudo mount”命令:

root@k8s-eu-1-master:~# sudo mount -t nfs -o mouuntvers=4.0 nfs_server_ip:/srv/backups /mnt/data
mount.nfs: Resource temporarily unavailable



root@k8s-eu-1-master:~# sudo mount -t nfs  -o mountvers=3  nfs_server_ip:/srv/backups /mnt/data
mount.nfs: Resource temporarily unavailable



root@k8s-eu-1-master:~# sudo mount -t nfs  -o mountvers=4.0  nfs_server_ip:/srv/backups /mnt/data
mount.nfs: Resource temporarily unavailable

ufw 状态:

client:

    root@k8s-eu-1-master:~# sudo ufw status
    Status: inactive

server:

root@k8s-eu-1-worker-1:~# sudo ufw status
Status: inactive

/etc/fstab改变 :

#nfs_server_ip:/srv/backups    /mnt/data   nfs auto,ext4,nofail,noatime,nolock,intr,tcp,actimeo=1800 0 0 mountvers=4.0

192.168.1.10:/srv/backups /mnt/data nfs4 auto,mountvers=4 0 0

root@k8s-eu-1-master:~# sudo mount nfs_server_ip:/srv/backups /mnt/data
mount.nfs: Resource temporarily unavailable

rpcinfo -p一边server

root@k8s-eu-1-worker-1:~# rpcinfo -p
   program vers proto   port  service
    100000    4   tcp    111  portmapper
    100000    3   tcp    111  portmapper
    100000    2   tcp    111  portmapper
    100000    4   udp    111  portmapper
    100000    3   udp    111  portmapper
    100000    2   udp    111  portmapper
    100005    1   udp  43114  mountd
    100005    1   tcp  32905  mountd
    100005    2   udp  51857  mountd
    100005    2   tcp  58259  mountd
    100005    3   udp  36062  mountd
    100005    3   tcp  41271  mountd
    100024    1   udp  60988  status
    100024    1   tcp  44101  status
    100003    3   tcp   2049  nfs
    100003    4   tcp   2049  nfs
    100227    3   tcp   2049
    100021    1   udp  43294  nlockmgr
    100021    3   udp  43294  nlockmgr
    100021    4   udp  43294  nlockmgr
    100021    1   tcp  44757  nlockmgr
    100021    3   tcp  44757  nlockmgr
    100021    4   tcp  44757  nlockmgr

如何让它工作?

答案1

感谢此处发现的迹象:https://www.digitalocean.com/community/tutorials/how-to-set-up-an-nfs-mount-on-ubuntu-22-04

/etc/exports在SERVER机器上修改了:

/srv/backups  yy.yyy.yyy.yy(rw,sync,no_subtree_check)
/mnt/shared yy.yyy.yyy.yy/24(rw,sync,no_subtree_check)

其中 yy.yyy.yyy.yy 是实际客户端机器的 IP 地址

问题就解决了

相关内容