安装
sudo yum install nfs-server
启动
sudo systemctl start nfs
sudo systemctl enable nfs
配置防火墙
sudo firewall-cmd –add-service=nfs –permanent # may not need
sudo firewall-cmd –add-service=rpc-bind –permanent
sudo firewall-cmd –add-service=mountd –permanent
sudo firewall-cmd –reload
配置要共享的目录
sudo vim /etc/exports/path/to/share 172.17.0.0/16(rw,sync,all_squash,insecure,anonuid=0,anongid=0,no_subtree_check)
参数含义secure/insecure: 是否允许发起请求的端口大于1024,即不使用特权端口(普通用户也可以挂载)
rw/ro: 读写/只读
async/sync: 异步/同步, 异步性能好,但是服务端重启时会有数据丢失
root_squash/no_root_squash: 是否将挂载方的root用户映射为匿名用户
all_squash: 将所有用户都映射为匿名用户
anonuid/anongid: 设置匿名用户的uid/gid,将所有挂载此共享目录的用户都视为同一个用户
在不设置anonuid/anongid值时,匿名用户在linux上对应了使用人的uid/gid, 在windows上则要看客户端软件如何处理了.
subtree_check/no_subtree_check: 是否使用subtree_check, 一般来说对于只读的挂载,启用subtree_check, 对于频繁读写重命名的盘,禁用subtree_check.