服务器的配置:
[root@classroom Desktop]# yum -y install nfs-utils rpcbind #安装NFS服务
[root@classroom Desktop]# rpm -qa | grep nfs
libnfsidmap-0.25-9.el7.x86_64
nfs-utils-1.3.0-0.el7.x86_64
[root@classroom Desktop]# rpm -qa | grep rpcbind
rpcbind-0.2.0-23.el7.x86_64
创建共享目录,并给予权限:
[root@classroom Desktop]# mkdir /var/web
[root@classroom Desktop]# chmod a+w /var/web/
[root@classroom Desktop]# cd /var/web/
[root@classroom web]# touch test.txt
编辑NFS主配置文件:
[root@classroom web]# vim /etc/exports
#文件格式:共享路径 客户端主机(选项)
/var/web/ 172.25.0.11(rw)
重启下服务:
[root@classroom web]# systemctl restart nfs
[root@classroom web]# systemctl restart rpcbind
客户端的配置:
显示NFS服务器的输出
[root@server0 var]# showmount -e classroom.example.com
Export list for classroom.example.com:
/var/web 172.25.0.11
创建共享目录,并实施挂载:
[root@server0 Desktop]# mkdir /var/web
[root@server0 Desktop]# mount classroom.example.com:/var/web /var/web
设置开启自启动:
[root@server0 /]# echo "classroom.example.com:/var/web /var/web nfs defaults 0 0" >>/etc/fstab
测试是否共享成功:
[root@server0 /]# ll /var/web/
-rw-r--r-- 1 root root 14 Oct 30 10:22 test.txt