## Server:192.168.1.211
```
yum -y install nfs-utils
vim /etc/exports
/nfsfile 192.168.1.*(rw,sync,root_squash)
mkdir /nfsfile
chmod -Rf 777 /nfsfile
firewall-cmd --permanent --add-service=nfs
firewall-cmd --permanent --add-service=rpc-bind
firewall-cmd --permanent --add-service=mountd
firewall-cmd --reload
systemctl restart nfs-server
systemctl enable nfs-server
systemctl restart rpcbind
systemctl enable rpcbind
exportfs -arv //开启对外发布
exportfs -auv //关闭对外发布,关闭后客户端使用 showmount -e 无法查看
```
## Desktop:192.168.1.210
```
yum -y install nfs-utils
showmount -e 192.168.1.211
mkdir /nfsfile
mount -t nfs 192.168.1.211:/nfsfile /nfsfile //临时挂载
vim /etc/fstab
192.168.1.211:/nfsfile /nfsfile nfs defaults 0 0//持久挂载需要写入 fstab 文件
//defaults 可以修改为 rw,tcp,intr
```
## /etc/exports
| 参数 | 作用 |
| --- | --- |
| ro | 制度 |
| rw | 读写 |
| root_squash | 当NFS客户端以root管理员访问时,映射为NFS服务器的匿名用户 |
| no_root_squash | 当NFS客户端以root管理员访问时,映射为NFS服务器的root管理员 |
| all_squash | 无论NFS客户端使用什么账户访问,均映射为NFS服务器的匿名用户 |
| sync | 同时将数据同时写入内存与硬盘中,保证不丢失数据 |
| async | 优先将数据保存到内存,然后再写入硬盘;这样效率高,但可能会丢失数据 |
## NFS 仅能实现 linux 之间的文件共享