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

一、服务端配置

bash 复制代码
#软件包安装
[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为例:

bash 复制代码
#安装相关服务
[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

三、测试

bash 复制代码
#在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客户端的相关服务都是关闭的,也是可以正常获取到的

相关推荐
圆圆讲门店4 小时前
挑选同城获客服务机构时需要考量的核心因素都有哪些?
大数据·网络·人工智能·python
制造业的搬运工5 小时前
扫地机器人主板 PCB 选型:深圳线路板与普通板的 8 项工艺指标对比与参数清单
网络·科技·制造·科普·pcb工艺
顺顺 尼5 小时前
linux 进程信号(上)
linux·c++·算法
niuTaylor6 小时前
飞腾 FT-2000/4 Ubuntu 内存卡 / NVMe SSD 系统制作完整指南
linux·服务器·人工智能·驱动开发·单片机
傲世仙尊7 小时前
信号量环形队列与线程池起步-把临界资源拆成很多份
linux
Huangjin007_7 小时前
【Linux 系统篇(二十五)】文件(二) 系统文件I/O详解
linux·运维·服务器
XiaoMaqqqq7 小时前
目前知名的IP驱动产业新场景新工具有哪些
网络·python·网络协议·tcp/ip
李永奉7 小时前
中科蓝讯SDK开发-BT897X、BT891X、AB573X、AB572X 系列 触摸按键提示音功能实现
网络·单片机·嵌入式硬件·mcu·物联网
ShineWinsu7 小时前
对于ProtoBuffer:ProtoBuffer的介绍以及安装
linux·网络·google·协议·序列化·反序列化·protobuffer
Eddyp8 小时前
避开溢价!艾默生 TREX2 手操器省钱选型攻略
网络·其他·百度·微信·微信公众平台·新浪微博