陈佳浩
陈佳浩
发布于 2024-08-13 / 52 阅读
0
0

NFS挂载报错

今天在使用nfs作为存储时,手动挂载一直报错

[root@localhost ~]# mount -t nfs -o nfsvers=4 10.0.0.4:/data/test /mnt
mount.nfs: mounting 10.0.0.4:/data/test failed, reason given by server: No such file or directory

但是不指定nfsvers或者设置nfsvers=3时,则可以挂载成功

[root@localhost ~]# ls /mnt
[root@localhost ~]# mount -t nfs -o hard,nfsvers=3 10.0.0.4:/data/test /mnt
[root@localhost ~]# ls /mnt
qqq  test

查询ChatGPT也未得到有用的信息,经过反复测试发现,与 /etc/exports中的配置有关

[root@localhost ~]# cat /etc/exports
/data/lnmp/wordpress 10.0.0.0/24(rw,sync,no_root_squash)
/data/lnmp/mysql 10.0.0.0/24(rw,sync,no_root_squash,fsid=0,anonuid=999,anongid=999)
/data/jumpserver 10.0.0.0/24(rw,sync,no_root_squash)
/data/test 10.0.0.0/24(rw,sync,no_root_squash)

上面的配置文件中,注意关于mysql的一行,这一行配置了 fsid=0它将 /data/lnmp/mysql设置为了根目录,所以我指定挂载 /data/lnmp/mysql是找不到这个路径的,删除这个配置就OK了

[root@localhost ~]# umount /mnt
[root@localhost ~]# ls /mnt
[root@localhost ~]# mount -t nfs -o hard,nfsvers=4.1 10.0.0.4:/data/test /mnt
[root@localhost ~]# ls /mnt
qqq  test

评论