当前位置: 首页 > news >正文

RECE-nfs共享文件

实验要求
架设一台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可以完全访问该目录

下载工具

[root@localhost ~]# yum install rpcbind
[root@localhost ~]# yum install nfs-utils

关闭防火墙并开启服务

[root@localhost zzy]# systemctl stop firewalld
[root@localhost zzy]# setenforce 0
[root@localhost zzy]# systemctl start nfs-server

服务机配置

[root@localhost zzy]# vim /etc/exports
[root@localhost zzy]# cat /etc/exports
/nfs/shared  *(ro,sync)
/nfs/upload 192.168.64.0/24(rw,anonuid=210,anongid=210,sync)
/home/tom   192.168.64.132(rw)[root@localhost zzy]# mkdir /nfs/shared -pv
mkdir: created directory '/nfs'
mkdir: created directory '/nfs/shared'
[root@localhost zzy]# touch /nfs/shared/{0..10}
[root@localhost zzy]# mkdir /nfs/upload
[root@localhost zzy]# chmod o+w /nfs/upload
[root@localhost zzy]# useradd -u 210 -r nfs-upload
[root@localhost zzy]# useradd tom
[root@localhost zzy]# id tom
uid=1001(tom) gid=1001(tom) groups=1001(tom)
[root@localhost zzy]# ll /home/tom/ -d
drwx------. 3 tom tom 78 Oct 29 10:02 /home/tom/
[root@localhost zzy]# exportfs -ra

客户机配置

[root@localhost zzy]# showmount -e 192.168.64.131
Export list for 192.168.64.131:
/nfs/shared *
/nfs/upload 192.168.64.0/24
/home/tom   192.168.64.132
[root@localhost zzy]# mkdir /test/{1..5} -pv
mkdir: created directory '/test'
mkdir: created directory '/test/1'
mkdir: created directory '/test/2'
mkdir: created directory '/test/3'
mkdir: created directory '/test/4'
mkdir: created directory '/test/5'
[root@localhost zzy]# mount  192.168.64.131:/nfs/shared  /test/1
[root@localhost zzy]# mount -o remount,ro 192.168.64.131:/nfs/shared  /test/1
[root@localhost zzy]# mount | grep /test/1
192.168.64.131:/nfs/shared on /test/1 type nfs4 (ro,relatime,vers=4.2,rsize=262144,wsize=262144,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=192.168.64.132,local_lock=none,addr=192.168.64.131)
[root@localhost zzy]# vim /etc/fstab
[root@localhost zzy]# mount -a
mount: (hint) your fstab has been modified, but systemd still usesthe old version; use 'systemctl daemon-reload' to reload.
[root@localhost zzy]# systemctl daemon-reload
[root@localhost zzy]# mount -a
[root@localhost zzy]# mount 192.168.64.131:/home/tom /test/3
[root@localhost zzy]# ll /test/3
ls: cannot open directory '/test/3': Permission denied
[root@localhost zzy]# useradd -u 1001 tom
[root@localhost zzy]# su - tom
[tom@localhost ~]$ ll /test/3
total 0
[tom@localhost ~]$ touch a
[tom@localhost ~]$ su
Password: 
[root@localhost tom]# mount
.....
192.168.64.131:/nfs/shared on /test/1 type nfs4 (ro,relatime,vers=4.2,rsize=262144,wsize=262144,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=192.168.64.132,local_lock=none,addr=192.168.64.131)
192.168.64.131:/nfs/upload on /test/2 type nfs4 (rw,relatime,vers=4.2,rsize=262144,wsize=262144,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=192.168.64.132,local_lock=none,addr=192.168.64.131)
192.168.64.131:/home/tom on /test/3 type nfs4 (rw,relatime,vers=4.2,rsize=262144,wsize=262144,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=192.168.64.132,local_lock=none,addr=192.168.64.131)
......
[root@localhost tom]# cat /etc/fstab
/dev/mapper/rhel-root   /                       xfs     defaults        0 0
UUID=c8ddc1a7-628f-4f9f-8b34-644ba3a8e92b /boot                   xfs     defaults        0 0
/dev/mapper/rhel-swap   none                    swap    defaults        0 0
192.168.64.131:/nfs/upload /test/2  nfs4 defaults 0 0
[root@localhost tom]# 

请添加图片描述
请添加图片描述


http://www.mrgr.cn/news/61016.html

相关文章:

  • 安信金业:18k和24k黄金的区别
  • MySQL数据库中的CURRENT_TIMESTAMP函数使用经验小结
  • 【亚马逊云科技】Amazon Bedrock搭建AI服务
  • 磁盘空间不足导致postgreSQL启动失败
  • flutter VideoPlayer适配:保持视频的原始宽高比,缩放视频使它完全覆盖父容器
  • 鸿蒙应用开发实战-常用组件-图片组件
  • .NET Core WebApi第7讲:项目的发布与部署
  • SpringBoot框架在商场应急管理中的实践
  • CRM客户关系管理系统:全方位功能模块助力企业高效运营与增长
  • 从理解路由到实现一套Router(路由)
  • 理解dbt Exposures及应用示例
  • Java:多线程(线程池,执行原理,优雅停止,延迟周期)
  • 管家婆财贸ERP BB055.销售检查可销库存+BB058.读取品牌销售数量
  • vue中elementUI的el-select下拉框的层级太高修改设置!
  • PFC前端电路
  • 基于centos7.9搭建MariaDB10.5高可用集群
  • 落地分享:来看 UFH AI 医疗大模型如何助力国际化诊疗场景
  • 推荐一款出色的图像查看器:Pineapple Pictures
  • 02 什么是Babel
  • 揭秘程序员薪资密码:10K 与 20K 的思维 “分水岭”