当前位置:网站首页>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
边栏推荐
- 代码规范 & 详细解释 husky、prettier、eslint、lint-staged 的作用和使用
- Laravel admin obtains non auto increment ID and submits hidden forms
- 19:第三章:开发通行证服务:2:在程序中,打通阿里云短信服务;(仅仅是打通阿里云短信服务器,不涉及具体的业务开发)
- Mqtt disconnect and reconnect
- laravel 写原生SQL语句
- TCP interview
- 修改calico网络模式为host-gw
- Is it safe to open an account in the top ten securities app rankings in China
- word中涂黑的方块
- [deep learning theory] (7) long and short term memory network LSTM
猜你喜欢

Easyx----- C language implementation 2048

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

FasterRCNN

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

机器学习深度神经网络——实验报告

利用 Repository 中的方法解决实际问题

Flannel's host GW and calico

【深度学习理论】(7) 长短时记忆网络 LSTM

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

量化初级 -- akshare获得股票代码,最简策略
随机推荐
Statistical genetics: Chapter 2, the concept of statistical analysis
代码规范 & 详细解释 husky、prettier、eslint、lint-staged 的作用和使用
中国十大证券app排名 开户安全吗
CEPH operation and maintenance common instructions
Re recognized! Know that Chuangyu has been selected as one of the first member units of the "business security promotion plan"
Laravel-admin 登录添加图形验证码
高并发下如何防重?
laravel-admin 非自增ID获取, 及提交隐藏表单
nacos2.x.x启动报错信息Error creating bean with name ‘grpcClusterServer‘;
02 linked list of redis data structure
一键部署ceph脚本
APICloud 实现文档下载和预览功能
19: Chapter 3: develop pass service: 2: get through Alibaba cloud SMS service in the program; (it only connects with Alibaba cloud SMS server, and does not involve specific business development)
JWT certification agreement -- I opened a Yihong hospital
机器学习PCA——实验报告
统计遗传学:第二章,统计分析概念
科技兴关,荣联与天津海关共建基因组数据库及分析平台
MySQL performance monitoring and SQL statements
滑动窗口
Recent work report