当前位置:网站首页>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
边栏推荐
- Laravel admin login add graphic verification code
- Laravel writes native SQL statements
- Machine learning PCA - Experimental Report
- 有手就行的移动平均法、指数平滑法的Excel操作,用来时间序列预测
- Detailed explanation of MySQL fuzzy query
- QT connection MySQL data query failed
- Sqli-labs靶场1-5
- 请指教同花顺开户选选择哪家券商比较好?手机开户安全么?
- Laravel admin uses native JS to realize sound prompt and automatic playback
- 18:第三章:开发通行证服务:1:短信登录&注册流程,简介;(这儿使用短信验证码)
猜你喜欢

深度理解STM32的串口實驗(寄存器)【保姆級教程】

How to prevent weight loss under Gao Bingfa?

机器学习SVM——实验报告

Nacos2.x.x start error creating bean with name 'grpcclusterserver';

Quantitative elementary -- akshare obtains stock code, the simplest strategy

matlab 编程实例: 如何统计元胞数组中元素的数量

Machine learning LDA - Experimental Report

How does unity prevent other camera positions and rotations from being controlled by steamvrplugin when using steamvrplugin

Machine learning PCA - Experimental Report

Fabric. JS upper dash, middle dash (strikethrough), underline
随机推荐
Laravel admin uses native JS to realize sound prompt and automatic playback
PC QQ大厅 上传更新 修改versionInfo
机器学习SVM——实验报告
Excel operation of manual moving average method and exponential smoothing method for time series prediction
Grain Mall - distributed Foundation
I want to know how the top ten securities firms open accounts? Is online account opening safe?
机器学习PCA——实验报告
PC QQ大廳 上傳更新 修改versionInfo
携程机票 App KMM 跨端 KV 存储库 MMKV-Kotlin | 开源
How to prevent weight loss under Gao Bingfa?
机器学习LDA——实验报告
统计遗传学:第一章,基因组基础概念
That is to say, "live broadcast" is launched! One stop live broadcast service with full link upgrade
10 years' experience in programmer career - for you who are confused
Sqli-labs靶场1-5
Easyx-----c语言实现2048
2、 Linear table
代码规范 & 详细解释 husky、prettier、eslint、lint-staged 的作用和使用
Consumer microservice Governance Center stepping on the pit
Laravel admin hidden button, and set button display, default sequence, form form form non modifiable value