linux 7配置nfs共享
安装
yum install nfs-utils portmap nfs4-acl-tools
启动服务,并设置开机启动
systemctl start nfs
systemctl enable nfs
systemctl status nfs
systemctl start rpcbind
systemctl enable rpcbind
systemctl status rpcbind
修改服务端配置
创建共享文件夹
mkdir /u01/nfs/
chmod 777 /u01/nfs/
共享配置
vim /etc/exports
/u01/nfs *(rw,sync)
重启服务
systemctl restart rpcbind
systemctl restart nfs
查看NFS服务器上共享的目录
[root@localhost ~]# showmount -e localhost
Export list for localhost:
/u01/nfs (everyone)
客户端挂载
安装nfs
yum install nfs-utils
挂载
mount -t nfs 172.27.25.26:/u01/nfs /u01/nfs
测试
客户端写入
服务端查看
nfs能够正常写入和查看,这里显示用户是nfsnobody,如果要限制某个用户加上uid和gid,也可以直接配置root
/u01/nfs 172.27.25.28(rw,sync,anonuid=1000,anongid=1000) 172.27.25.29(rw,sync,anonuid=1000,anongid=1000) 172.27.25.30(rw,sync,anonuid=1000,anongid=1000) 172.27.25.3
1(rw,sync,anonuid=1000,anongid=1000)
参数
rw:是可读写
ro:是只读
sync:同步模式,表示内存中的数据时时刻刻写入磁盘(async:非同步模式,内存中数据定期存入磁盘)
all_squash:表示不管使用NFS的用户是谁,其身份都会被限定为一个指定的普通用户身份。
no_root_squash:其他客户端主机的root用户对该目录有至高权限控制。
root_squash:表示其他客户端主机的root用户对该目录有普通用户权限控制。
anonuid/anongid:要和root_squash或all_squash选项一同使用,表示指定使用NFS的用户被限定后的
uid和gid,前提是本图片服务器的/etc/passwd中存在这一的uid和gid。
no_subtree_check:不检查父目录的权限