架设一台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]$ 
相关推荐
一袋米扛几楼982 小时前
【密码学】CrypTool2 工具是什么?
服务器·网络·密码学
vin_zheng4 小时前
破解企业安全软件网络拦截实战记录
运维
林姜泽樾5 小时前
Linux入门第十二章,创建用户、用户组、主组附加组等相关知识详解
linux·运维·服务器·centos
xiaokangzhe6 小时前
Linux系统安全
linux·运维·系统安全
南棱笑笑生6 小时前
20260310在瑞芯微原厂RK3576的Android14查看系统休眠时间
服务器·网络·数据库·rockchip
xiaokangzhe6 小时前
Nginx核心功能
运维·nginx
松果1776 小时前
以本地时钟为源的时间服务器
运维·chrony·时间服务器
XDHCOM6 小时前
ORA-32152报错咋整啊,数据库操作遇到null number问题远程帮忙修复
服务器·数据库·oracle
Highcharts.js7 小时前
Highcharts React v4.2.1 正式发布:更自然的React开发体验,更清晰的数据处理
linux·运维·javascript·ubuntu·react.js·数据可视化·highcharts
ayaya_mana7 小时前
快速安装Nginx-UI:让Nginx管理可视化的高效方案
运维·nginx·ui