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

linux nfs+autofs

linux nfs+autofs

nfs网络文件系统

autofs自动挂载服务

nfs服务端部署:
1、需要安装nfs-utils rpcbind nfs-utils
yum -y install nfs-utils rpcbind nfs-utils

先查看有没有rpcbind

[root@ws ~]# rpm -q rpcbind 
rpcbind-0.2.0-47.el7.x86_64
[root@ws ~]# rpm -q nfs-utils 
nfs-utils-1.3.0-0.61.el7.x86_64

2.新建共享目录和文件

[root@ws ~]# mkdir /common
[root@ws ~]# cd /common/
[root@ws common]# ls
[root@ws common]# touch file1
[root@ws common]# ls
file1

3.编辑/etc/exports文件 配置共享目录

/common 192.168.110.0/24(rw)

[root@ws ~]# vim /etc/exports

在这里插入图片描述

4.重启服务

systemctl restart rpcbind

systemctl enable rpcbind

systemctl restart nfs-server

systemctl enable nfs-server

[root@ws ~]# systemctl restart rpcbind
[root@ws ~]# systemctl enable rpcbind
Created symlink from /etc/systemd/system/multi-user.target.wants/rpcbind.service to /usr/lib/systemd/system/rpcbind.service.
[root@ws ~]# systemctl restart nfs-server
[root@ws ~]# systemctl enable nfs-server
Created symlink from /etc/systemd/system/multi-user.target.wants/nfs-server.service to /usr/lib/systemd/system/nfs-server.service.

5.修改共享目录的访问权限,需要和共享权限保持一致

chmod o+w /common

[root@ws ~]# chmod o+w /common/

6.关闭防护墙

systemctl stop firewalld

systemctl disable firewalld

[root@ws ~]# systemctl stop firewalld
[root@ws ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

客户端

查看nfs服务器的信息

[root@ws2 ~]# vim /etc/nfs.conf 

查看有没有nfs

[root@ws2 ~]# rpm -q nfs-utils 
nfs-utils-1.3.0-0.61.el7.x86_64

新建挂载点 然后挂载 这个是临时挂载

[root@ws2 ~]# mkdir /abc
[root@ws2 ~]# mount -t nfs 192.168.110.10:/common /abc
[root@ws2 ~]# df -Th
文件系统               类型      容量  已用  可用 已用% 挂载点
/dev/sda2              xfs        50G  3.6G   47G    8% /
devtmpfs               devtmpfs  2.0G     0  2.0G    0% /dev
tmpfs                  tmpfs     2.0G     0  2.0G    0% /dev/shm
tmpfs                  tmpfs     2.0G   13M  2.0G    1% /run
tmpfs                  tmpfs     2.0G     0  2.0G    0% /sys/fs/cgroup
/dev/sda1              xfs      1014M  163M  852M   17% /boot
tmpfs                  tmpfs     394M   28K  394M    1% /run/user/0
/dev/sr0               iso9660   4.3G  4.3G     0  100% /run/media/root/CentOS 7 x86_64
192.168.110.10:/common nfs4       50G  3.5G   47G    7% /abc

查看服务器创建的目录中的文件客户端能否查看

[root@ws2 ~]#  cd /abc
[root@ws2 abc]# ls
file1
[root@ws2 abc]# touch file2
[root@ws2 abc]# ls
file1  file2
[root@ws ~]# cd /common/
[root@ws common]# ll
总用量 0
-rw-r--r--. 1 root      root      0 8月   5 16:58 file1
-rw-r--r--. 1 nfsnobody nfsnobody 0 8月   5 18:23 file2

永久挂载

 [root@ws2 ~]# umount /abc/
[root@ws2 ~]# vim /etc/fstab 
[root@ws2 ~]# mount -a
[root@ws2 ~]# df -Th
文件系统               类型      容量  已用  可用 已用% 挂载点
/dev/sda2              xfs        50G  3.6G   47G    8% /
devtmpfs               devtmpfs  2.0G     0  2.0G    0% /dev
tmpfs                  tmpfs     2.0G     0  2.0G    0% /dev/shm
tmpfs                  tmpfs     2.0G   13M  2.0G    1% /run
tmpfs                  tmpfs     2.0G     0  2.0G    0% /sys/fs/cgroup
/dev/sda1              xfs      1014M  163M  852M   17% /boot
tmpfs                  tmpfs     394M   28K  394M    1% /run/user/0
/dev/sr0               iso9660   4.3G  4.3G     0  100% /run/media/root/CentOS 7 x86_64
192.168.110.10:/common nfs4       50G  3.5G   47G    7% /abc

在这里插入图片描述

autofs自动挂载服务

1、安装autofs软件包
yum -y install autofs

[root@ws2 ~]# cd /etc/yum.repos.d/ 
[root@ws2 yum.repos.d]# rm -rf *
[root@ws2 yum.repos.d]# ll
总用量 0
[root@ws2 yum.repos.d]# vim server.repo
[root@ws2 yum.repos.d]# mount /dev/cdrom /mnt/
mount: /dev/sr0 写保护,将以只读方式挂载
[root@ws2 yum.repos.d]# yum -y install autofs
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
aa                                                                                             | 3.6 kB  00:00:00     
(1/2): aa/group_gz                                                                             | 166 kB  00:00:00     
(2/2): aa/primary_db                                                                           | 3.1 MB  00:00:00     
正在解决依赖关系
--> 正在检查事务
---> 软件包 autofs.x86_64.1.5.0.7-99.el7 将被 安装
--> 正在处理依赖关系 libhesiod.so.0()(64bit),它被软件包 1:autofs-5.0.7-99.el7.x86_64 需要
--> 正在检查事务
---> 软件包 hesiod.x86_64.0.3.2.1-3.el7 将被 安装
--> 解决依赖关系完成依赖关系解决======================================================================================================================Package                   架构                      版本                                 源                     大小
======================================================================================================================
正在安装:autofs                    x86_64                    1:5.0.7-99.el7                       aa                    814 k
为依赖而安装:hesiod                    x86_64                    3.2.1-3.el7                          aa                     30 k事务概要
======================================================================================================================
安装  1 软件包 (+1 依赖软件包)总下载量:843 k
安装大小:5.1 M
Downloading packages:
----------------------------------------------------------------------------------------------------------------------
总计                                                                                   54 MB/s | 843 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction正在安装    : hesiod-3.2.1-3.el7.x86_64                                                                         1/2 正在安装    : 1:autofs-5.0.7-99.el7.x86_64                                                                      2/2 验证中      : hesiod-3.2.1-3.el7.x86_64                                                                         1/2 验证中      : 1:autofs-5.0.7-99.el7.x86_64                                                                      2/2 已安装:autofs.x86_64 1:5.0.7-99.el7                                                                                        作为依赖被安装:hesiod.x86_64 0:3.2.1-3.el7                                                                                         完毕!

2、重启autofs服务并设置下次启动生效
systemctl restart autofs
systemctl enable autofs

[root@ws2 yum.repos.d]# systemctl restart autofs
[root@ws2 yum.repos.d]# systemctl enable autofs
Created symlink from /etc/systemd/system/multi-user.target.wants/autofs.service to /usr/lib/systemd/system/autofs.service.

3.新建挂载点的主目录
mkdir /luoqi/ws/aaa

4./etc/auto.master 定义挂载点组目录的位置,及具体挂载内容的文件名

[root@ws2 ~]# vim /etc/auto.master

5、将/etc/auto.misc模板内容复制到/etc/auto.nfs

[root@ws2 ~]# cp /etc/auto.misc /etc/auot.nfs

在这里插入图片描述

6./etc/auto.misc 定义具体挂载点内容的文件,及挂载点的子目录名称

编辑挂载内容的配置文件
vim /etc/auto.nfs
注释掉之前的挂载信息,然后在最后一行的下面写入如下信息

挂载点子目录 文件系统类型 设备地址

abc -fstype=nfs,vers=4,rw 192.168.110.10:/common

vim /etc/auto.nfs

在这里插入图片描述

7、重启autofs服务并设置下次启动生效
systemctl restart autofs
systemctl enable autofs

[root@ws2 ~]# systemctl restart autofs
[root@ws2 ~]# systemctl enable autofs

查看

[root@ws2 ~]# ls /
abc  boot  etc   lib    luoqi  misc  net  proc  run   srv  tmp  var
bin  dev   home  lib64  media  mnt   opt  root  sbin  sys  usr  ws
[root@ws2 ws]# ll
总用量 0
[root@ws2 ws]# cd abc
[root@ws2 abc]# df -Th
文件系统               类型      容量  已用  可用 已用% 挂载点
/dev/sda2              xfs        50G  3.6G   47G    8% /
devtmpfs               devtmpfs  2.0G     0  2.0G    0% /dev
tmpfs                  tmpfs     2.0G     0  2.0G    0% /dev/shm
tmpfs                  tmpfs     2.0G   13M  2.0G    1% /run
tmpfs                  tmpfs     2.0G     0  2.0G    0% /sys/fs/cgroup
/dev/sda1              xfs      1014M  163M  852M   17% /boot
tmpfs                  tmpfs     394M   28K  394M    1% /run/user/0
/dev/sr0               iso9660   4.3G  4.3G     0  100% /run/media/root/CentOS 7 x86_64
192.168.110.10:/common nfs4       50G  3.5G   47G    7% /luoqi/ws/abc
http://www.dtcms.com/a/316493.html

相关文章:

  • 并发 Vs 并行
  • 管式土壤墒情监测站在高标准农田的作用
  • 具身智能触觉传感器全景调研
  • HTML 如何转 Markdown
  • 【YOLO学习笔记】YOLOv1详解
  • 亚马逊标品与非标品广告运营:从架构搭建到策略优化的专业方法论
  • Could not load the Qt platform plugin “xcb“ in “无法调试与显示Opencv
  • Natural Language Processing in Computational Creativity: A Systematic Review
  • 2025年08月05日Github流行趋势
  • 3477. 水果成篮 II
  • 电子器械行业的主数据有哪些?
  • Linux NFS 服务部署、客户端配置及 autofs 自动挂载操作指南
  • Tinylog
  • 通俗版23种设计模式解析
  • 机械手的眼睛,视觉系统如何让机器人学会精准抓取
  • GaussDB 常见问题-集中式
  • 05-栈 stack
  • 机器学习算法系列专栏:决策树算法(初学者)
  • TCP如何实现可靠传输?实现细节?
  • 三坐标测量技术解析:从基础原理到斜孔测量难点突破
  • 重生之我在暑假学习微服务第十天《网关篇》
  • Mysql常用语句
  • 广州客户 戴尔R720服务器 liunx系统 RAID5无损升级扩容
  • CTF-XXE 漏洞解题思路总结
  • AI自主任务执行系统 AI Agent无限循环,发任务给AI,让生成脚本,运行执行任务,直到成功。
  • adjtimex系统调用及示例
  • 阿里招AI产品运营
  • 从数据洪流到智能决策:Apache IoTDB如何重塑工业物联网的DB+AI新范式
  • Java技术栈/面试题合集(12)-Maven篇
  • springboot + maven 使用资源占位符实现动态加载配置文件