两台实验主机
主机名称 | IP地址 |
---|---|
Server0 | 192.168.10.10 |
Client0 | 192.168.10.20 |
Server0:
注:RHEL7系统以及默认安装NFS
iptables -F # 配置之前,清空防火墙
service iptables save
vim /etc/exports #编辑nfs配置文件
- /nfsfile 192.168.10.0/24(rw,root_squash,sync)
Desktop0:
yum install -y autofs
vim /etc/auto.master
-按照 “挂载目录 子配置文件” 格式
-客户端指定监测目录**/nfsClient** 不需要预先新建,autofs会自动创建,子配置文件名称**/etc/auto.nfs**自定义
编辑子配置文件
vim /etc/auto.nfs
[本地端子目录] [-挂载参数] [服务器所提供目录]
test -fstype=nfs,rw 192.168.10.10:/nfsfile
或者使用通配符:
* -fstype=nfs,rw 192.168.10.10/&
这时cd /nfsClient/nfsfile 就会自动挂载上
(若*是"nfsfile",则&是"nfsfile")
使用showmount命令前,需要在服务端server0 firewall-cmd --add-service=mounted --permanent
当cd 客户端监测目录 /nfsClient/test 时,会自动挂载上
无法挂载的原因
试了几次,有时候忘了将某些服务开启,特别是rpcbind 就出现挂载不上,还有就是防火墙,nfs、mounted、rpcbind 用命令firewall-cmd --add-service=xx --permanent firewall-cmd --reload 重载一下就可以了