实验准备
软件:VMware Workstation Pro
虚拟机:Red Hat Enterprise Linux 7 64 位 两台(一台服务器,一台客户端)

综合案例

某公司现需配置一台NFS服务器,NFS服务器的I地址为192.168.100.254。共享的要求如下所述:
(1)共享/mnt/share目录,允许192.168.100.0/24网段的计算机访问该共享目录,可进行读写操作。
(2)共享/mnt managerdata目录,允许公司zhang 用户利用P地址为192.168.100.10主机对该共享目录拥有读写权限
(3)共享/ mnt/upload目录,允许该目录作为192.168.100.0/24 网段主机利用该目录做为上传目录,其中/mnt/upload 的用户和所属组为nfsupload,UID 和GID均为123
(4)共享/home/ nfs目录,该目录允许192.168.100.0/24网段的用户访问,设置该目录为只读。

实例实现
1、在NFS服务器安装NFS服务软件包。
[root@localhost Desktop]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rhel-root 38G 2.9G 35G 8% /
devtmpfs 905M 0 905M 0% /dev
tmpfs 914M 140K 914M 1% /dev/shm
tmpfs 914M 8.9M 905M 1% /run
tmpfs 914M 0 914M 0% /sys/fs/cgroup
/dev/sda1 497M 119M 379M 24% /boot
/dev/sr0 3.5G 3.5G 0 100% /run/media/root/RHEL-7.0 Server.x86_64
[root@localhost Desktop]# mkdir /mnt/cdrom && mount /dev/sr0 /mnt/cdrom
mount: /dev/sr0 is write-protected, mounting read-only
[root@localhost Desktop]# vim /etc/yum.repos.d/a.repo
[a]
name=welcome to redhatroom
baseurl=file:///mnt/cdrom
enabled=1
gpgcheck=0
[root@localhost Desktop]# yum install -y rpcbind
[root@localhost Desktop]# yum install -y nfs-utils
2、创建相应目录和测试文件

   22  mkdir /mnt/share23  mkdir /mnt/managerdata24  mkdir /mnt/upload25  mkdir /mnt/nfs26  touch /mnt/share/test127  touch /mnt/share/test228  touch /mnt/managerdata/test329  touch /mnt/managerdata/test430  touch /mnt/upload/upload.txt31  touch /mnt/nfs/test532  touch /mnt/nfs/test6

3、设置共享目录的权限属性

   33  chmod 1777 /mnt/share34  ll -d /mnt/share/35  useradd zhang36  echo redhat | passwd --stdin zhang37  chmod 700 /mnt/managerdata39  chown -R zhang:zhang /mnt/managerdata/40  ll -d /mnt/managerdata/41  groupadd -g 123 nfsupload42  man groupadd43  useradd -g 123 -u 123 -M nfsupload44  tail -n1 /etc/group45  tail -n1 /etc/passwd46  cat /etc/passwd | grep nfs48  chown -R nfsupload:nfsupload /mnt/upload/49  ll -d /mnt/upload/50  ll -d /mnt/nfs/

4、编辑/etc/exports文件

[root@localhost 桌面]# vim /etc/exports
/mnt/share      192.168.100.0/24(rw,no_root_squash)
/mnt/managerdata        192.168.100.10(rw)
/mnt/upload     192.168.100.0/24(rw,all_squash,anonuid=123,anongid=123)
/mnt/nfs        192.168.100.0/24(ro)

注意,NFS客户端地址与权限之间没有空格。

参数 作用
ro 只读
rw 读写
root_squash 当NFS客户端以root管理员访问时,映射为NFS服务器的匿名用户
no_root_squash 当NFS客户端以root管理员访问时,映射为NFS服务器的root管理员
all_squash 无论NFS客户端使用什么账户访问,均映射为NFS服务器的匿名用户
sync 同时将数据写入到内存与硬盘中,保证不丢失数据
async 优先将数据保存到内存,然后再写入硬盘;这样效率更高,但可能会丢失数据

5、设置防火墙放行规则,启动服务

54 systemctl restart rpcbind.service
55 systemctl status rpcbind.service
63 systemctl start nfs-service
65 systemctl status nfs-server.service
6、在nfs客户端查看共享目录,建立目录执行挂载

[root@localhost 桌面]# showmount -e 192.168.100.254
Export list for 192.168.100.254:
/mnt/nfs         192.168.100.0/24
/mnt/upload      192.168.100.0/24
/mnt/share       192.168.100.0/24
/mnt/managerdata 192.168.100.10
[root@localhost 桌面]# mkdir /mnt/clientnfs
[root@localhost 桌面]# mount -t nfs 192.168.100.254:/mnt/nfs /mnt/clientnfs/
[root@localhost 桌面]# df -h
文件系统                  容量  已用  可用 已用% 挂载点
/dev/mapper/rhel-root      18G  3.0G   15G   17% /
devtmpfs                  905M     0  905M    0% /dev
tmpfs                     914M  140K  914M    1% /dev/shm
tmpfs                     914M  8.9M  905M    1% /run
tmpfs                     914M     0  914M    0% /sys/fs/cgroup
/dev/sda1                 497M  119M  379M   24% /boot
/dev/sr0                  3.5G  3.5G     0  100% /mnt/cdrom
192.168.100.254:/mnt/nfs   18G  3.0G   15G   17% /mnt/clientnfs
[root@localhost 桌面]# cd /mnt/clientnfs/
[root@localhost clientnfs]# ls
test5  test6
[root@localhost clientnfs]# touch nfs3.txt
touch: 无法创建"nfs3.txt": 只读文件系统
[root@localhost clientnfs]# mkdir /mnt/clientupload
[root@localhost clientnfs]# mount -t nfs 192.168.100.254:/mnt/upload /mnt/clientupload/
[root@localhost clientnfs]# cd /mnt/clientupload/
[root@localhost clientupload]# ls
upload.txt
[root@localhost clientupload]# touch a
[root@localhost clientupload]# ls
a  upload.txt
[root@localhost clientupload]# ll
总用量 0
-rw-r--r--. 1 123 123 0 10月 30 15:12 a
-rw-r--r--. 1 123 123 0 10月 30 14:42 upload.txt
[root@localhost clientupload]# groupadd -g 123 nfsupload
[root@localhost clientupload]# useradd -g 123 -u 123 -M nfsupload
[root@localhost clientupload]# ll
总用量 0
-rw-r--r--. 1 nfsupload nfsupload 0 10月 30 15:12 a
-rw-r--r--. 1 nfsupload nfsupload 0 10月 30 14:42 upload.txt
可以看到root用户创建的文件属主仍是nfsupload
[root@localhost clientupload]# mkdir /mnt/share
[root@localhost clientupload]# mount -t nfs 192.168.100.254:/mnt/share/ /mnt/share/
[root@localhost clientupload]# df -h
文件系统                    容量  已用  可用 已用% 挂载点
/dev/mapper/rhel-root        18G  3.0G   15G   17% /
devtmpfs                    905M     0  905M    0% /dev
tmpfs                       914M  140K  914M    1% /dev/shm
tmpfs                       914M  8.9M  905M    1% /run
tmpfs                       914M     0  914M    0% /sys/fs/cgroup
/dev/sda1                   497M  119M  379M   24% /boot
/dev/sr0                    3.5G  3.5G     0  100% /mnt/cdrom
192.168.100.254:/mnt/share   18G  3.0G   15G   17% /mnt/share
[root@localhost clientupload]# cd /mnt/share/
[root@localhost share]# ls
test1  test2
[root@localhost share]# ll
总用量 0
-rw-r--r--. 1 root root 0 10月 30 14:41 test1
-rw-r--r--. 1 root root 0 10月 30 14:41 test2
[root@localhost share]# touch 1
[root@localhost share]# ll
总用量 0
-rw-r--r--. 1 root root 0 10月 30 15:33 1
-rw-r--r--. 1 root root 0 10月 30 14:41 test1
-rw-r--r--. 1 root root 0 10月 30 14:41 test2
[root@localhost share]# rm 1
rm:是否删除普通空文件 "1"?y
[root@localhost share]# su - student
上一次登录:日 9月 18 20:00:42 CST 2022从 192.168.150.138pts/1 上
[student@localhost ~]$ cd /mnt/share/
[student@localhost share]$ ls
test1  test2
[student@localhost share]$ ll
总用量 0
-rw-r--r--. 1 root root 0 10月 30 14:41 test1
-rw-r--r--. 1 root root 0 10月 30 14:41 test2
[student@localhost share]$ touch 1
[student@localhost share]$ ll
总用量 0
-rw-rw-r--. 1 student student 0 10月 30 15:33 1
-rw-r--r--. 1 root    root    0 10月 30 14:41 test1
-rw-r--r--. 1 root    root    0 10月 30 14:41 test2
[student@localhost share]$ rm test
rm: 无法删除"test": 没有那个文件或目录
[student@localhost share]$ rm test1
rm:是否删除有写保护的普通空文件 "test1"?y
rm: 无法删除"test1": 不允许的操作
[student@localhost share]$ rm 1
[student@localhost share]$ ls
test1  test2
[student@localhost share]$ cd ..
[student@localhost mnt]$ ll
总用量 4
dr-xr-xr-x. 10 root      root      4096 5月   7 2014 cdrom
drwxr-xr-x.  2 root      root        30 10月 30 14:42 clientnfs
drwxr-xr-x.  2 nfsupload nfsupload   31 10月 30 15:12 clientupload
drwxrwxrwt.  2 root      root        30 10月 30 15:33 share

redhat 7 中NFS服务器配置与管理相关推荐

  1. NFS服务器配置与管理笔记

    目录 1.概述 1.1)NFS简介 1.2)NFS工作机制 2.NFS的安装与启动 3.配置NFS服务 1.概述 1.1)NFS简介 NFS是Network File System的缩写,及网络文件系 ...

  2. redhat 7中DNS 服务器配置与测试

    实例: 假设某单位所在的域"gztzy. org"内有三台主机,主机名分别为:jwc. gztzy.org,yds. gztzy.org和 cys.gztzy.org.其中 DNS ...

  3. windows修改dns服务器,windowns中dns服务器配置与管理详解(多图)

    安装DNS服务器 在"服务器管理器"-"角色"-"添加角色"中安装DNS服务器. 选择DNS服务器 点下一步安装,然后安装 固定服务器IP地 ...

  4. 新书推荐——Windows Server 2019 网络服务器配置与管理

    新书推荐--Windows Server 2019 网络服务器配置与管理 近日,正月十六工作室组编的<Windows Server 2019 网络服务器配置与管理>在电子工业出版社正式出版 ...

  5. linux中nfs存储权限,NFS权限管理 - 麦苗的个人空间 - OSCHINA - 中文开源技术交流社区...

    对于NFS中权限管理的理解,首先需要熟悉Linux中关于文件或文件夹的访问控制策略,其次要认识NFS中服务器如何控制客户端的访问. 默认情况下,Linux对于文件或文件夹的权限管理分为所属者(ownu ...

  6. CentOS下NFS服务器配置实例

    LINUX下NFS的配置与安全设置 Redhat Linux NFS配置     NFS简介:     NFS是网络文件系统的简写(network file system),主要用在linux或uni ...

  7. RHEL5下NFS服务器配置与应用

    RHEL5下NFS服务器配置与应用 试验环境 1.一台安装有RHEL5的计算机: 2.系统安装盘: 试验内容 1.安装nfs软件包 2.配置nfs服务器 3.nfs服务器管理 4.客户端测试 试验步骤 ...

  8. Linux服务器配置和管理:虚拟机安装CentOS6.7

    2019独角兽企业重金招聘Python工程师标准>>> 原文地址:http://lawlietfans.coding.me/blog/2016/02/29/introduction- ...

  9. Linux服务器配置与管理项目教程(CentOS7 /RHEL 7)(第三版)题库带答案

    Linux服务器配置与管理项目教程 (CentOS7 /RHEL 7)(第三版)微课版 第1篇   系统安装与网络配置 项目1  安装CentOS 服务器 项目2  配置Linux基础网络 不积跬步, ...

最新文章

  1. 光纤交换机如何划分zone
  2. 01,完全,多重,分组
  3. Sping-Spring表达式语言SpEL
  4. scheduledexecutorservice 的使用_使用J.U.C实现定时任务
  5. mask rcnn属于dnn么_基于OpenCV DNN的 MaskRCNN 目标检测与实例分割
  6. Algorithm:贪心策略之区间选点问题
  7. 不合群的人,经常习惯一个人独来独往,这样的人有出息吗?
  8. 用代码排出自己的名字
  9. Python学生管理系统(web网页版)
  10. 亚马逊大赛:AI与人聊天20分钟就能赢百万美元 | 揭秘
  11. 怎样帮宝宝起个好名字?起名必备的五大招在这里了
  12. 文本搜索引擎lucene
  13. html5图片做成简单拼图,html5版canvas自由拼图实例_html5教程技巧
  14. Unix的学习(一)
  15. 计算机基础题选择题,计算机基础知识题库选择题.doc
  16. oracle-12514,Oracle错误 ORA-12514 解决方法
  17. html网站一行代码改变灰黑色哀悼日风格
  18. ]许多代码段,没准儿有你需要的 C++ Builder
  19. 最详解决:jupyter notebook不会自动打开浏览器问题
  20. project server 2007 安装说明(有截图)

热门文章

  1. 大华网络摄像头,查看视频闪烁严重
  2. 五年级上册计算机教案闽教版,闽教版五年级上册信息技术教案
  3. Java码农进阶之路~面向对象之对象和类
  4. java 开源网盘_现在的开源网盘还有哪些推荐?
  5. [翻译] 第一章 是时候进行远程工作了 (Remote)
  6. 【啊哈算法学习笔记】2.栈
  7. arduino pwm电机调速程序
  8. 【毕业设计】基于红外热释电的房间人数计数系统 - 单片机 物联网嵌入式
  9. Linux下的SQLite数据库的基本使用
  10. 【论文笔记】GRU4Rec基于session的推荐系统