[root@localhost yum.repos.d]# rpm -q rpcbind
rpcbind-0.2.0-49.el7.x86_64
[root@localhost yum.repos.d]# rpm -q nfs-utils
nfs-utils-1.3.0-0.68.el7.x86_64
关闭selinux
关闭防火墙
创建共享文件夹
[root@localhost ~]# mkdir /nfs
[root@localhost ~]# mkdir -p /test/nfs
给共享文件夹w权限
[root@localhost nfs]# chmod o+w /nfs
[root@localhost nfs]# chmod o+w /test/nfs
[root@localhost ~]# man 5 exports
修改主配置文件
/nfs *(rw)
/test/nfs 192.168.93.0/24(ro)
重启服务
[root@localhost ~]# systemctl restart rpcbind
[root@localhost ~]# systemctl restart nfs
验证
A.查看共享文件夹
[root@localhost ~]# showmount -e 192.168.93.140
Export list for 192.168.93.140:
/nfs *
/test/nfs 192.168.93.0/24
B.挂载到本地
[root@localhost ~]# mount -t nfs 192.168.93.140:/nfs /opt
[root@localhost ~]# mount -t nfs 192.168.93.140:/test/nfs /tmp
C.验证挂载
[root@localhost opt]# df -h
Filesystem Size Used Avail Use% Mounted on
192.168.93.140:/nfs 598G 49G 550G 9% /opt
192.168.93.140:/test/nfs 598G 49G 550G 9% /tmp
D.验证权限
[root@localhost ~]# cd /opt
[root@localhost opt]# touch 10.txt
[root@localhost ~]# cd /tmp
[root@localhost tmp]# touch 10.txt
touch: cannot touch ‘10.txt’: Read-only file system