假定你已经安装了NFS必需的软件,如果没有安装,请参考https://jingyan.baidu.com/article/59a015e30215a5f7948865f1.html
或者其他网页。这里只介绍搭建NFS过程中必需的步骤:
服务器端:
1. mkdir /目录 (创建共享目录,可以任意设定)
2. chmod 777 /目录 (改变文件夹的权限)
3.sudo vim /etc/exports
最后一行添加(注意:行首没有 #)
/.. /目录(最好绝对目录) *(insecure,rw,sync,no_root_squash,no_subtree_check)
4.exportfs -rv
5.sudo mount -t nfs localhost:/../目录(绝对目录) /mnt (/mnt为例,可以任意选择)(localhost 为本机IP,也可以用ip地址代替,这里在本机挂载验证)
6. showmount -e (查看挂载情况)
7.umount -v /mnt
客户端:
1.安装必要的软件,请参考其他网页。https://blog.youkuaiyun.com/wangzhen209/article/details/46802587
2.ping serverip(保证两者之间都能ping通)
3.sudo mount (依上述,/mnt为例)
4.showmount -e
5.在server端中 /目录下 touch a.txt
6. 在客户端 /mnt 下 ls 会出现 a.txt
done!