【Linux】NFS网络文件系统搭建

一、服务端配置

#软件包安装
[root@hadoop01 ~]# yum install rpcbind nfs-utils.x86_64 -y
[root@hadoop01 ~]# mkdir /share

#配置文件修改
#格式为    共享资源路径 [主机地址] [选项]
#
[root@hadoop01 ~]# vi /etc/exports
/share 192.168.10.0/24(rw,sync,no_root_squash)
#重新mount 文件/etc/exports中分享出来的目录
[root@hadoop01 ~]# exportfs -rv
exporting 192.168.10.0/24:/share

#启动相关服务
[root@hadoop01 ~]# systemctl start nfs
[root@hadoop01 ~]# systemctl start rpcbind
[root@hadoop01 ~]# systemctl start nfslock

#关闭防火墙,iptables
[root@hadoop01 ~]# iptables -F
#永久关闭selinux内核安全模块,需要重新服务器
[root@hadoop01 ~]# sed -i "s/^SELINUX=.*/SELINUX=disable/" /etc/selinux/config
#临时关闭,设置为宽容模式
[root@hadoop01 ~]# setenforce 0
[root@hadoop01 ~]# systemctl stop firewalld
[root@hadoop01 ~]# systemctl disable firewalld

二、客户端配置

以linux为例:

#安装相关服务
[root@hadoop02 ~]# yum install rpcbind nfs-utils.x86_64 -y


#查看nfs服务端可用的共享文件夹
[root@hadoop01 ~]# showmount -e 192.168.10.200
Export list for 192.168.10.200:
/share 192.168.10.0/24


#挂载nfs服务端的/share到/mnt
[root@hadoop02 ~]# mount -t nfs 192.168.10.200:/share /mnt
#查看挂载目录
[root@hadoop02 ~]# df -h


#自动挂载
[root@hadoop02 ~]# vi /etc/fstab
192.168.10.200:/share /mnt                      nfs     defaults        0 0
[root@hadoop02 ~]# mount -a

三、测试

#在nfs服务端创建目录和文件
[root@hadoop01 ~]# mkdir /share/a
[root@hadoop01 ~]# echo "123" > /share/a.txt

#客户端查看
[root@hadoop02 ~]# ll /mnt/
total 4
drwxr-xr-x 2 root root 6 Apr 21 00:11 a
-rw-r--r-- 1 root root 4 Apr 21 00:13 a.txt
[root@hadoop02 ~]# cat /mnt/a.txt
123

此时,我发现nfs客户端的相关服务都是关闭的,也是可以正常获取到的

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-04-22 06:56:04       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-04-22 06:56:04       101 阅读
  3. 在Django里面运行非项目文件

    2024-04-22 06:56:04       82 阅读
  4. Python语言-面向对象

    2024-04-22 06:56:04       91 阅读

热门阅读

  1. NPM 详解

    2024-04-22 06:56:04       39 阅读
  2. 开发语言漫谈-SQL

    2024-04-22 06:56:04       37 阅读
  3. 在 Apache Sedona 中处理空间栅格数据

    2024-04-22 06:56:04       35 阅读
  4. Qt查询mysql表的信息解释

    2024-04-22 06:56:04       37 阅读
  5. pyflink统计单词

    2024-04-22 06:56:04       39 阅读
  6. 20240420

    2024-04-22 06:56:04       39 阅读
  7. 【无标题】

    2024-04-22 06:56:04       34 阅读
  8. 前端nodead面试题

    2024-04-22 06:56:04       31 阅读
  9. 前端系列-2 模块化CommonJs+AMD+CMD+ES6

    2024-04-22 06:56:04       23 阅读
  10. ES6 import / export / export default type=module

    2024-04-22 06:56:04       36 阅读
  11. eCognition 分类

    2024-04-22 06:56:04       34 阅读
  12. 数据结构--双向链表

    2024-04-22 06:56:04       37 阅读