安装yum install nfs-utils
配置文件
/etc/exports或/etc/exports.d/*
修改配置文件之后重载命令
exportfs -rav
-r:重新导出;
-a:所有文件系统;
-v:详细信息;
配置格式
/PATH/TO/SOME_DIR clients1(export_options, ...) clients2(export_options, ...)
例如:/data/uploads 192.168.1.101(rw,anonuid=1001,anongid=1001)
把/data/uploads 允许192.168.1.101的主机挂载 允许读写 并且指定用户为本地gid为1001的用户
clients 支持多种匹配方式
single host:ipv4, ipv6, FQDN;
network:address/netmask, 支持长短格式的掩码;
wildcards:主机名通配,例如:*.magedu.com;
anonymous:使用*通配所有主机;
General Options:
ro:只读
rw:读写;
sync:同步;
async:异步;
secure:客户端端口小于1024,否则就要使用insecure选项;
User ID Mapping:
root_squash:压缩root用户,一般指将其映射为nfsnobody;
no_root_squash:不压缩root用户; 不建议使用
all_squash:压缩所有用户
anonuid and anongid:将压缩的用户映射为此处指定的用户;
客户端命令
挂载
mount -t nfs servername:/path/to/share /path/to/mount_point [-rvVwfnsh ] [-o options]
卸载:umount /path/to/mount_point
查看指定服务器可挂载目录
showmount -e NFS_SERVER_IP: 查看指定的nfs server上导出的所有文件系统;