1.手动搭建一个nfs服务器
开放/nfs/shared目录,供所有用户查阅资料
服务端
[root@hanyuce ~]# vim /etc/exports
[root@hanyuce ~]# systemctl stop firewalld
[root@hanyuce ~]# systemctl disable firewalld
[root@hanyuce ~]# setenforce 0
setenforce: SELinux is disabled
[root@hanyuce ~]# vi /etc/selinux/config
[root@hanyuce ~]# systemctl restart nfs-server
[root@hanyuce ~]# mkdir nfs
[root@hanyuce ~]# cd nfs
[root@hanyuce nfs]# mkdir shared
客户端
[root@hyc ~]# systemctl stop firewalld
[root@hyc ~]# systemctl disable firewalld
[root@hyc ~]# vi /etc/selinux/config
[root@hyc ~]# showmount -e 192.168.30.131
Export list for 192.168.30.131:
/nfs/shared *
开放/nfs/upload目录为192.168.30.0/24网段的数据上传目录,并将所有用户及所属的用户组都映射为nfs-upload,其UID与GID均为300
服务端
[root@hanyuce ~]# useradd -r -u 300 nfs-upload
[root@hanyuce ~]# id nfs-upload
uid=300(nfs-upload) gid=300(nfs-upload) 组=300(nfs-upload)
[root@hanyuce ~]# cat /etc/exports
/nfs/shared *(rw)
/nfs/upload 192.168.30.0/24(rw,anonuid=300,anongid=300)
[root@hanyuce ~]# mkdir /nfs/upload
[root@hanyuce ~]# chmod 777 /nfs/upload
客户端
[root@hyc ~]# mount -t nfs 192.168.30.131:/nfs/upload /gege
[root@hyc ~]# cd /gege
[root@hyc gege]# touch 1
[root@hyc gege]# ll
总用量 0
-rw-r--r-- 1 300 300 0 7月 2 16:58 1
服务端
[root@hanyuce ~]# cd /nfs/upload/
[root@hanyuce upload]# ll
总用量 0
-rw-r--r-- 1 nfs-upload nfs-upload 0 7月 2 16:58 1