1、开放/nfs/shared目录,供所有用户查询资料;
#服务端:
#1.创建目录
[root@server ~]# mkdir -p /nfs/shared
#2.配置文件
[root@server ~]# cat /etc/exports
/data 192.168.40.130(rw)
/nfs/shared *(ro)
/nfs/upload *(rw)
#3.重启服务端
[root@server ~]# systemctl restart nfs-server.service
#4.利用showmount -e查看信息
[root@server ~]# showmount -e localhost
Export list for localhost:
/nfs/shared *
/nfsdownload *
/data 192.168.40.130
#客户端:
[root@localhost ~]# showmount -e 192.168.40.120
Export list for 192.168.40.120:
/nfs/shared *
/nfsdownload *
/data 192.168.40.130
[root@localhost ~]# cd /nfsclient/
#创建挂载点目录
[root@localhost nfsclient]# mkdir shared
[root@localhost nfsclient]# ll
总用量 0
drwxr-xr-x. 2 root root 6 11月 15 16:52 client-data
drwxr-xr-x. 2 root root 6 11月 15 17:18 download
drwxr-xr-x. 2 root root 6 11月 15 18:42 shared
#挂载
[root@localhost nfsclient]# mount 192.168.40.120:/nfs/shared ./shared/
#查看挂载信息
[root@localhost nfsclient]# df -h
192.168.40.120:/nfs/shared 28G 8.1G 20G 29% /nfsclient/shared
#客户端测试:
[root@localhost nfsclient]# cd shared/
[root@localhost shared]# ll
总用量 0
[root@localhost shared]# touch file
touch: 无法创建 'file': 只读文件系统
#因此该目录只能查;
2、开放/nfs/upload目录,供所有用户上传下载资料;
#服务端:
#1.创建目录
[root@server ~]# mkdir -p /nfs/upload
#2.配置文件
[root@server ~]# cat /etc/exports
/data 192.168.40.130(rw)
/nfs/shared *(ro)
/nfs/upload *(rw)
#3.重启服务端
[root@server ~]# systemctl restart nfs-server.service
#4.利用showmount -e查看信息
[root@server ~]# showmount -e localhost
Export list for localhost:
/nfs/shared *
/nfsdownload *
/data 192.168.40.130
#查看权限
[root@server ~]# ll -d /nfs/upload/
drwxr-xr-x. 2 root root 6 Nov 15 18:33 /nfs/upload/
#配置权限(o+w)
[root@server ~]# chmod o+w /nfs/upload/
[root@server ~]# ll -d /nfs/upload/
drwxr-xrwx. 2 root root 18 Nov 15 18:52 /nfs/upload/
#客户端:
[root@localhost ~]# showmount -e 192.168.40.120
Export list for 192.168.40.120:
/nfs/shared *
/nfsdownload *
/data 192.168.40.130
[root@localhost ~]# cd /nfsclient/
#创建挂载点目录
[root@localhost nfsclient]# mkdir upload
[root@localhost nfsclient]# ll
总用量 0
drwxr-xr-x. 2 root root 6 11月 15 16:52 client-data
drwxr-xr-x. 2 root root 6 11月 15 17:18 download
drwxr-xr-x. 2 root root 6 11月 15 18:42 upload
#挂载
[root@localhost nfsclient]# mount 192.168.40.120:/nfs/upload ./upload/
#查看挂载信息
[root@localhost nfsclient]# df -h
192.168.40.120:/nfs/upload 28G 8.1G 20G 29% /nfsclient/upload
[root@localhost shared]# cd ../upload/
#客户端测试:
[root@localhost upload]# ll
总用量 0
[root@localhost upload]# touch file
touch: 无法创建 'file': 权限不够
#该目录权限需要在服务端进行配置(o+w);
[root@localhost upload]# touch file
[root@localhost upload]# ll
总用量 0
-rw-r--r--. 1 nobody nobody 0 11月 15 18:52 file
#因此该目录可以进行上下传资料