1、开放/nfs/shared目录,供所有用户查询资料
2、开放/nfs/upload目录,为192.168.xxx.0/24网段主机可以上传目录, 并将所有用户及所属的组映射为nfs-upload,其UID和GID均为210
3、将/home/tom目录仅共享给192.168.xxx.xxx这台主机,并只有用户tom对该目录有读写权限
server
[root@server ~]# yum install nfs-utils -y #下载 nfs
[root@server ~]# vim /etc/exports #配置
[root@server ~]# mkdir /nfs/shared -pv
[root@server ~]# mkdir /nfs/upload -pv
[root@server ~]# useradd tom #创建文件
[root@server ~]# id tom
uid=1001(tom) gid=1001(tom) groups=1001(tom)
[root@server ~]# useradd -r -u 210 nfs-upload #所有用户及所属的组映射为nfs-upload,其UID和GID均为210
[root@server ~]# chmod o+w /nfs/upload #给予权限
[root@server ~]# exprtfs -ra #启动
[root@server ~]# systemctl start rpcbind
[root@server ~]# systemctl start nfs-server #启动服务
client
[root@localhost ~]# mount /dev/sr0 /mnt
mount: /mnt: WARNING: source write-protected, mounted read-only.
[root@localhost ~]# yum install nfs-utils -y #挂载和下载nfs
[root@localhost ~]# systemctl start rpcbind
[root@localhost ~]# systemctl start nfs-server #启动服务
[root@localhost ~]# mkdir /test{1..3}#创建文件
[root@localhost ~]# mount 192.168.23.129:/nfs/shared /test1
[root@localhost ~]# mount 192.168.23.129:/nfs/upload /test2
[root@localhost ~]# mount 192.168.23.129:/home/tom /test3 #挂载共享文件
root@localhost test2]# useradd tom
[root@localhost test2]# id tom
uid=1001(tom) gid=1001(tom) groups=1001(tom)
[root@localhost test2]# su - tom
[root@localhost test2]# id tom
uid=1001(tom) gid=1001(tom) groups=1001(tom)
[root@localhost ~]# vim /etc/fstab
验证