nfs server:
安装:内核模块nfsd
用户空间的工具程序:nfs-utils
Unit File:/usr/lib/systemd/system/nfs.service
配置文件:/etc/exports, /etc/exports.d/*
管理共享的nfs文件系统:配置文件每一行定义一个共享文件系统
Each line contains an export point and a whitespace-separated list of clients allowed to mount the file system at that point.
/PATH/TO/SOME_DIR CLIENTS_1(export_options,...) CLIENTS_2(export_options,...)
CLIENTS:
single host: IPv4, IPv6, FQDN
IP networks:network/netmask,支持两种格式的掩码;
wildcards:在主机名字符串中使用通,*.magedu.com,
anonymous:*,表示所有的客户端主机;
General Options
ro:只读;
rw:读写;
sync:同步
async:异步
User ID Mapping:
远程客户端和服务端的用户映射是根据uid进行映射的,为了避免root权限过大的问题,默认限制了root用户的权限即默认就有root_squash
root_squash:压缩root用户的权限,默认行为;nfsnobody
no_root_squash:不压缩root用户的权限;
all_squash:压缩所有用户的权限; //默认是不压缩,以uid号进行映射
anonuid=uid,anongid=gid:将压缩的用户映射为此处指定的用户
NFS Client:
mount -t nfs NFS_SERVER:/PATH/TO/EXPORTED_DIR /MOUNT_POINT [-rvVwfnsh] [-o OPTIONS]
showmount - show mount information for an NFS server
-e or --exports
Show the NFS server's export list.
-d or --directories
List only the directories mounted by some client.
exportfs - maintain table of exported NFS file systems
-a Export or unexport all directories.
-r Reexport all directories, synchronizing /var/lib/nfs/etab with /etc/exports and files under /etc/exports.d.
-u Unexport one or more directories.