架设一台NFS服务器,并按照以下要求配置

1、开放/nfs/shared目录,供所有用户查询资料

2、开放/nfs/upload目录,为192.168.xxx.0/24网段主机可以上传目录,

并将所有用户及所属的组映射为nfs-upload,其UID和GID均为210

3、将/home/tom目录仅共享给192.168.xxx.xxx这台主机,并只有用户tom可以完全访问该目录

++服务器配置:++

1.所需包的安装

bash 复制代码
#安装nfs-utils,可以在Linux系统上配置和管理NFS服务器和客户端
[root@localhost ~]# yum install nfs-utils	

2.防火墙配置

bash 复制代码
[root@localhost ~]# firewall-cmd --permanent --add-service=nfs
[root@localhost ~]# firewall-cmd --permanent --add-service=rpc-bind
[root@localhost ~]# firewall-cmd --permanent --add-service=mountd

#配置完成之后查看是否成功
[root@localhost ~]# firewall-cmd --list-all

3.做相应配置

bash 复制代码
[root@localhost ~]# vim /etc/exports	--ntf配置文件路径
/nfs/shared     *(ro)
/nfs/upload     192.168.190.0/24(rw,all_squash,anonuid=210,anongid=210)
/home/tom       192.168.xxx.xxx(rw)
#配置内容 
#1.开放/nfs/shared目录,供所有用户查询资料	--*(ro)所有用户只读权限
#2.开放/nfs/upload目录,为192.168.xxx.0/24网段主机可以上传目录,	--/nfs/upload对于某个网段的主机
#并将所有用户及所属的组映射为nfs-upload,其UID和GID均为210	  --all_squash(映射所有身份)
#3.将/home/tom目录仅共享给192.168.xxx.xxx这台主机

#启动nfs--加载配置
[root@localhost ~]# systemctl restart nfs-serves

3.tom用户配置

bash 复制代码
[root@localhost ~]# useradd tom
[root@localhost ~]# ll /home/tom/ -d
drwx------. 2 tom tom 4096  1月 17 18:53 /home/tom/
#权限问题配置--若非上述权限,则要进行以下配置
[root@localhost ~]# chmod 700 /home/tom/

4.创建共享路径

bash 复制代码
[root@localhost ~]# mkdir /nfs/{shared,upload} -pv

5.创建测试文件

bash 复制代码
[root@localhost ~]# touch /nfs/{shared,upload}/{1..5}

6.权限设置和组别创建

bash 复制代码
#允许网段的其他用户对/nfs/upload目录有写权限
[root@localhost ~]# chmod o+w /nfs/upload

#创建用户组
[root@localhost ~]# useradd -r -u 210 nfs-upload

++客户端++

1.所需包的安装

bash 复制代码
#安装nfs-utils,可以在Linux系统上配置和管理NFS服务器和客户端
[root@localhost ~]# yum install nfs-utils	

2.创建挂载点并进行挂载

bash 复制代码
[root@localhost ~]# mkdir /1 /2 /3
[root@localhost ~]# mount 192.168.190.130:/nfs/shared /1
[root@localhost ~]# mount 192.168.190.130:/nfs/upload /2
[root@localhost ~]# mount 192.168.190.130:/home/tom /3

3.测试在服务端的配置效果

bash 复制代码
#1.供所有用户查询资料
[root@localhost 1]# touch a
touch: 无法创建 'a': Read-only file system

#2.可以上传目录
[root@localhost 1]# cd /2
[root@localhost 2]# touch a
[root@localhost 2]# ll
总用量 0
-rw-r--r--. 1 root root 0  1月 17 18:24 1
-rw-r--r--. 1 root root 0  1月 17 18:24 2
-rw-r--r--. 1 root root 0  1月 17 18:24 3
-rw-r--r--. 1 root root 0  1月 17 18:24 4
-rw-r--r--. 1 root root 0  1月 17 18:24 5
-rw-r--r--. 1  210  210 0  1月 17 18:46 a

#只有用户tom可以完全访问该目录
[root@localhost ~]# cd /3		--非tom用户访问
-bash: cd: /3: Permission denied
[root@localhost ~]# su - tom
[tom@localhost ~]$ cd /3
[tom@localhost 3]$ 
相关推荐
杨浦老苏20 小时前
家庭实验室监控仪表盘HomeLab-Monitor
运维·docker·监控·群晖
回忆2012初秋20 小时前
【Nginx】原理、配置与运维实战(2)
运维·nginx·策略模式
Urbano21 小时前
工装外套全制作流程、工序痛点及自动化设备升级方案
运维·自动化
映翰通朱工21 小时前
工业4G网关无公网IP远程运维实战(内网终端异地访问方案)
运维·服务器·网络·安全·智能路由器
洪晓露1 天前
将 rke2 集群证书延长至 10 年
运维·服务器·数据库
谢平康1 天前
解决用 rm 报bash: /usr/bin/rm: Argument list too long错
linux·运维·运维开发
IP老炮不瞎唠1 天前
Python 价格监控如何实现?思路与实用方法分享
运维·服务器·网络
GIS数据转换器1 天前
城市排水生命线安全运行监测平台深度解析
java·运维·人工智能·python·安全·数据挖掘·无人机
睡不醒男孩0308231 天前
CLup 6.x 版本中针对StarRocks 存算一体集群的完整操作手册
java·服务器·网络·clup
Tokai_Teio_11 天前
第四届黄河流域 misc
运维·服务器