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

NFS服务器

(1)关闭防火墙和selinux 装软件
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0
[root@localhost ~]# mount /dev/sr0 /mnt
mount: /mnt: WARNING: source write-protected, mounted read-only.
[root@localhost ~]# dnf install nfs-utils -y
编辑主配置文件   创建目录和测试文件
[root@localhost ~]# vim /etc/exports/nfs/shared             *(ro)
[root@localhost ~]# mkdir -pv /nfs/shared
mkdir: created directory '/nfs'
mkdir: created directory '/nfs/shared'
[root@localhost ~]# touch /nfs/shared/test{a..k}
导出所有参数共享信息,立即生效
[root@localhost ~]# exportfs -ra
客户端 查看 挂载
[root@localhost ~]# showmount -e 192.168.160.129
Export list for 192.168.160.129:
/nfs/shared *
[root@localhost ~]# mount 192.168.160.129:/nfs/shared /media
访问共享目
[root@localhost ~]# ll /media/
total 0
-rw-r--r--. 1 root root 0 Nov 15 10:08 testa
-rw-r--r--. 1 root root 0 Nov 15 10:08 testb
-rw-r--r--. 1 root root 0 Nov 15 10:08 testc
-rw-r--r--. 1 root root 0 Nov 15 10:08 testd
-rw-r--r--. 1 root root 0 Nov 15 10:08 teste
-rw-r--r--. 1 root root 0 Nov 15 10:08 testf
-rw-r--r--. 1 root root 0 Nov 15 10:08 testg
-rw-r--r--. 1 root root 0 Nov 15 10:08 testh
-rw-r--r--. 1 root root 0 Nov 15 10:08 testi
-rw-r--r--. 1 root root 0 Nov 15 10:08 testj
-rw-r--r--. 1 root root 0 Nov 15 10:08 testk

2、开放/nfs/upload目录,为192.168.xxx.0/24网段主机可以上传目录,并将所有用户及所属的组映射为nfs-upload,其UID和GID均为210

编辑主配置文件  创建目录和测试文件  修改目录权限
[root@localhost ~]# vim /etc/exports/nfs/upload             192.168.160.0/24(rw,all_squash,anonuid=210,anongid=210)
[root@localhost ~]# mkdir -pv /nfs/upload
mkdir: created directory '/nfs/upload'
[root@localhost ~]# touch /nfs/upload/test{1..10}
[root@localhost ~]# chmod 777 /nfs/upload
导出所有参数共享信息,立即生效
[root@localhost ~]# exportfs -ra
客户端  添加用户  查看  挂载
[root@localhost ~]# useradd -r -u 210 nfs-upload
[root@localhost ~]# id nfs-upload
uid=210(nfs-upload) gid=210(nfs-upload) groups=210(nfs-upload)
[root@localhost ~]# showmount -e 192.168.160.129
Export list for 192.168.160.129:
/nfs/upload 192.168.160.0/24
[root@localhost ~]# mount 192.168.160.129:/nfs/upload /media
访问共享目录
[root@localhost ~]# ll /media
total 0
-rw-r--r--. 1 root root 0 Nov 15 11:03 test1
-rw-r--r--. 1 root root 0 Nov 15 11:03 test10
-rw-r--r--. 1 root root 0 Nov 15 11:03 test2
-rw-r--r--. 1 root root 0 Nov 15 11:03 test3
-rw-r--r--. 1 root root 0 Nov 15 11:03 test4
-rw-r--r--. 1 root root 0 Nov 15 11:03 test5
-rw-r--r--. 1 root root 0 Nov 15 11:03 test6
-rw-r--r--. 1 root root 0 Nov 15 11:03 test7
-rw-r--r--. 1 root root 0 Nov 15 11:03 test8
-rw-r--r--. 1 root root 0 Nov 15 11:03 test9

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

编辑主配置文件   创建目录和测试文件   修改用户权限目录权限
[root@localhost ~]# vim /etc/exports/home/tom  192.168.160.120(rw,root_squash,all_squash,anonuid=1111,anongid=1111)
[root@localhost ~]# mkdir -pv /home/tom
mkdir: created directory '/home/tom'
[root@localhost ~]# touch /home/tom/test{a..h}
[root@localhost ~]# chown tom:tom /home/tom/[root@localhost ~]# chmod 700 /home/tom/[root@localhost ~]# ll -d /home/tom
drwx------. 2 tom tom 110 Nov 15 05:49 /home/tom
导出所有参数共享信息,立即生效
[root@localhost ~]# exportfs -ra
客户端   添加用户  查看  挂载
[root@localhost ~]# useradd -u 1111 tom
[root@localhost ~]# id tom
uid=1111(tom) gid=1111(tom) groups=1111(tom)
[root@localhost ~]# showmount -e 192.168.160.128
Export list for 192.168.160.128:
/home/tom 192.168.160.120
[root@localhost ~]# mount 192.168.160.128:/home/tom /media
访问共享目录
[root@localhost ~]# su - tom
[tom@localhost ~]$ ll /media
total 0
-rw-r--r--. 1 root root 0 Nov 15 11:49 testa
-rw-r--r--. 1 root root 0 Nov 15 11:49 testb
-rw-r--r--. 1 root root 0 Nov 15 11:49 testc
-rw-r--r--. 1 root root 0 Nov 15 11:49 testd
-rw-r--r--. 1 root root 0 Nov 15 11:49 teste
-rw-r--r--. 1 root root 0 Nov 15 11:49 testf
-rw-r--r--. 1 root root 0 Nov 15 11:49 testg
-rw-r--r--. 1 root root 0 Nov 15 11:49 testh

http://www.dtcms.com/a/618524.html

相关文章:

  • MYSQL索引的底层数据结构
  • 进程等待
  • 【数学速通】初中高中数学完整内容体系总结
  • 哪个网站做推销产品oshin wordpress
  • 网站qq获取大连在哪个省
  • 高职图书馆网站建设大赛wordpress 图片 存储
  • jEasyUI 设置排序指南
  • IconCache文件
  • Linux进程读写管道的行为详解
  • 零基础学做网站视频上传网站如何做
  • 仿RabbitMQ实现消息队列(三)--muduo介绍与使用
  • 4-Linux驱动开发-字符设备驱动
  • 专业网站建设平台郑州房产网
  • 43 全选,单选
  • stm32f103c8t6寄存器点灯法
  • 【Linux】计算机如何管理软硬件
  • 利用DuckDB列表一句SQL输出乘法口诀表
  • 兴宁网站设计凡客的官网
  • 大模型-Vllm 启用多模态数据-3
  • 集团网站建设定制网站建设中企动力是怎么建设网站的
  • Shell脚本猜数字,使用判断提示用户比目标数字是大还是小
  • 【开题答辩全过程】以 基于安卓的校园二手物品为例,包含答辩的问题和答案
  • 内测检测vs第三方软件检测的差异解析
  • 【科研绘图系列】R语言绘制多组条形图图(barplot)
  • Linux-线程
  • 最专业网站建设公备案域名是什么意思
  • SQL 约束
  • 创立一个网站要多少钱上海公司做网站的
  • MoE算法深度解析:从理论架构到行业实践
  • 【2025CVPR 异常检测方向】DFM: Differentiable Feature Matching for Anomaly Detection