当前位置:网站首页>NFS共享存储服务安装
NFS共享存储服务安装
2022-06-26 10:45:00 【huryer】
NFS共享存储服务安装
一.NFS概述
1.概述
NFS是一种基于TCP/IP 传输的网络文件系统协议。通过使用NFS协议,客户机可以像访问本地目录一样访问远程服务器中的共享资源
NAS存储: NFS服务的实现依赖于RPC (Remote Process Call,远端过程调用)机制,以完成远程到本地的映射过程。
在Centos 7系统中,需要安装nfs-utils、 rpcbind 软件包来提供NFS共享服务,前者用于NFS共享发布和访问,后者用于RPC支持。
手动加载NFS共享服务时,应该先启动rpcbind, 再启动nfs。
nfs端口:2049
RPC端口:111
2.特点
采用TCP/IP传输网络文件
安全性低
简单易操作
适合局域网环境
二.NFS工作原理
NFS服务器可以让PC将网络中的NFS服务器共享的目录挂载到本地端的文件系统中,而在本地端的系统中来看,那个远程主机的目录就好像是自己的一个磁盘分区一样,在使用上相当便利;
2.1NFS工作流程
1.首先服务器端启动RPC服务,并开启111端口
2.服务器端启动NFS服务,并向RPC注册端口信息
3.客户端启动RPC(portmap服务),向服务端的RPC(portmap)服务请求服务端的NFS端口
4.服务端的RPC(portmap)服务反馈NFS端口信息给客户端。
5.客户端通过获取的NFS端口来建立和服务端的NFS连接并进行数据的传输。
2.2挂载原理
当我们在NFS服务器设置好一个共享目录后,其他的有权访问NFS服务器的NFS客户端就可以将这个目录挂载到自己文件系统的某个挂载点,这个挂载点可以自己定义。
并且挂载好后我们在本地能够看到服务端的所有数据。
三.NFS服务部署
3.1服务器端配置
# 1.检查并安装软件
rpm -q rpcbind nfs-utils
yum install -y rpcbind nfs-utils
# 2.创建共享目录
# NFS的配置文件,默认文件内容为空(无任何共享)
vi /etc/exports
# 设置/share/data为共享目录,允许192.168.10.0网段的IP地址主机访问
/share/data 192.168.10.0/24(rw,sync,no_root_squash)
# 配置参数
常用选项 描述
rw 允许读写
ro 只读
sync 同步写入
async 先写入缓冲区,必要时才写入磁盘,速度快,但会丢数据
subtree_check 若输出一个子目录,则nfs服务将检查其父目录权限
no_subtree_check 若输出一个字目录,不检查父目录,提高效率
no_root_squash 客户端以root登录时,赋予其本地root权限
oot_squash 客户端以root登录时,将其映射为匿名用户
all_squash 将所有用户映射为匿名用户
# 3.启动服务
# 一定要先开启rpcbind服务
systemctl start rpcbind
# 如服务已启动,更改完配置信息后需要重启服务
systemctl start nfs
# 查看详细的nfs信息
exportfs -v
# 重读配置文件
exportfs -r
# 查看本机发布的NFS共享目录
showmount -e
# 查看端口监听情况
# netstat -ntlp|grep -E '^Proto|111|2049'
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:2049 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 4600/rpcbind
tcp6 0 0 :::2049 :::* LISTEN -
tcp6 0 0 :::111 :::* LISTEN 4600/rpcbind
# 添加防火墙
firewall-cmd --add-service rpc-bind --permanent
firewall-cmd --add-service mountd --permanent
firewall-cmd --add-service nfs --permanent
firewall-cmd --add-service nfs3 --permanent
# 如果需要取消开放服务,执行命令:
firewall-cmd --remove-service=rpc-bind --permanent
firewall-cmd --remove-service=mountd --permanent
firewall-cmd --remove-service=nfs --permanent
firewall-cmd --remove-service=nfs3 --permanent
# 重启防火墙
firewall-cmd --reload
# 查看开放服务列表
firewall-cmd --zone=public --list-service
3.2客户端配置
1.检查并安装软件
# 客户端安装nfs,用于验证共享目录是否可用,但不需要启动服务
rpm -q rpcbind nfs-utils
yum install -y rpcbind nfs-utils
2.将共享目录挂载到本地
# 查看IP地址发布的NFS共享目录
showmount -e +IP
showmount -e 192.168.10.6
# 查看rpc注册的端口信息
rpcinfo -p ip
showmount -e 192.168.10.6
# 将NFS服务端192.168.10.6下的/share/data挂载到/data下
mkdir /data
mount -t nfs 192.168.10.6:/share/data /data
# 查看挂载情况
df -Th
# 去除挂载
umount /data
# 启动时自动挂载
vi /etc/fstab
192.168.10.6:/share/data /data nfs defaults 0 2
3.3服务测试
# 文件测试,在客户端创建的文件,在服务端可以看到,部署成功。
vi 1.txt
# 性能测试
dd if=/dev/zero of=test bs=1M count=1000
边栏推荐
- dd命令测试华为鲲鹏&宏衫固态存储磁盘读写速度
- nacos2.x.x启动报错信息Error creating bean with name ‘grpcClusterServer‘;
- JWT certification agreement -- I opened a Yihong hospital
- Detailed explanation of MySQL fuzzy query
- 基于slate构建文档编辑器
- Nacos2.x.x start error creating bean with name 'grpcclusterserver';
- Machine learning SVM - Experimental Report
- Excel operation of manual moving average method and exponential smoothing method for time series prediction
- 量化初级 -- akshare获得股票代码,最简策略
- FasterRCNN
猜你喜欢

Unity使用SteamVRPlugin时如何不让其他Camera位置和旋转收到SteamVRPlugin控制

Machine learning LDA - Experimental Report

(Typora图床)阿里云oss搭建图床+Picgo上传图片详细教程

代码规范 & 详细解释 husky、prettier、eslint、lint-staged 的作用和使用

FastRCNN

机器学习SVM——实验报告

FastRCNN

02 linked list of redis data structure

QT connection MySQL data query failed

再获认可!知道创宇入选“业务安全推进计划”首批成员单位
随机推荐
Wangeditor uploading local video modification
How to calculate flops and params in deep learning
DD command tests the read and write speed of Huawei Kunpeng & Hongshan solid state storage disk
Code specification & explain in detail the functions and uses of husky, prettier, eslint and lint staged
【深度学习理论】(7) 长短时记忆网络 LSTM
Mqtt disconnect and reconnect
TCP面试
Grain Mall - High Availability Cluster
(typora picture bed) Alibaba cloud OSS building picture bed +picgo uploading picture detailed tutorial
机器学习SVM——实验报告
Using baijiafan to automatically generate API calls: progress in JS (II)
Splicing full paths and uploading multiple pictures of laravel admin when laravel uses OSS
nacos2.x.x启动报错信息Error creating bean with name ‘grpcClusterServer‘;
Machine learning LDA - Experimental Report
matlab 编程实例: 如何统计元胞数组中元素的数量
【Redis 系列】redis 学习十六,redis 字典(map) 及其核心编码结构
Statistical genetics: Chapter 1, basic concepts of genome
量化初级 -- akshare获得股票代码,最简策略
Server single and two-way adjustable one key mutual trust script!
统计遗传学:第二章,统计分析概念