[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0
#关闭防火墙,设置为permissive状态[root@localhost ~]# yum install nfs-utils -y
[root@localhost ~]# service nfs restart
[root@localhost ~]# ps aux|grep nfs
安装nfs,启动并查看。
[root@localhost ~]# mkdir /public
[root@localhost ~]# touch /public/{1..10}
[root@localhost ~]# vim /etc/exports
创建共享目录,并且配置文件,映射的uid、gid都为210。
也可以使用完整的IP或者网络号:/web 192.168.160.131/24(ro,all_squash,sync)
客户端:
[root@client ~]# showmount -e 192.168.168.131
Export list for 192.168.168.131:
/data 192.168.168.132
[root@client ~]# mkdir -p /nfsclient/client-data/
[root@client ~]# mount 192.168.168.131:/data /nfsclient/client-data/
[root@client ~]# df -h
autofs这个服务是在客户端的上面,它会持续的检测某个指定的目录,并预先设置当使用到该目录的某个子目录时,将会取得来自服务器端的NFS文件系统资源,并进行自动挂载的操作。
#查看配置是否有问题,并重启
[root@localhost ~]# mount -a
[root@localhost ~]# reboot
客户端配置autofs
[root@client ~]# yum install autofs -y
[root@client ~]# grep suibian /etc/auto.master
/client /etc/auto.suibian
[root@client ~]# cat /etc/auto.suibian
upload 192.168.168.131:/nfs/upload
[root@client ~]# systemctl restart autofs
启动自动挂载
[root@client ~]# cd /client
[root@client ~]# cd upload