NFS

简介: NFS

NFS

一、基础配置:

1、主机清单:

image.png2、网络配置:

nfs-server

[root@nfs-server ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE="Ethernet"
BOOTPROTO="static"
NAME="ens33"
DEVICE="ens33"
ONBOOT="yes"
IPADDR="192.168.10.10"
PREFIX="24"
GATEWAY="192.168.10.254"
DNS1="114.114.114.114"

重启网络:

[root@nfs-server ~]# systemctl restart network
[root@nfs-server ~]# hostname -I
192.168.10.10

nfs-client1:

[root@nfs-client1 ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE="Ethernet"
BOOTPROTO="static"
NAME="ens33"
DEVICE="ens33"
ONBOOT="yes"
IPADDR="192.168.10.20"
PREFIX="24"
GATEWAY="192.168.10.254"
DNS1="114.114.114.114"

重启网络:

[root@nfs-client1 ~]# systemctl restart network
[root@nfs-client1 ~]# hostname -I
192.168.10.20

二、搭建NFS服务:

1、关闭防火墙:

[root@nfs-server ~]# systemctl stop firewalld
[root@nfs-server ~]# systemctl disable firewalld

2、安装NFS

[root@nfs-server ~]# yum -y install rpcbind nfs-utils

3、启动NFS

[root@nfs-server ~]# systemctl start rpcbind nfs-server
[root@nfs-server ~]# systemctl enable rpcbind nfs-server

4、配置挂载目录:

[root@nfs-server ~]# vi /etc/exports
/mnt 192.168.10.0/24(rw,async)
/opt *(rw,async)

5、验证NFS

[root@nfs-server ~]# systemctl restart rpcbind nfs-server
[root@nfs-server ~]# showmount -e 127.0.0.1
Export list for 192.168.10.10:
/opt *
/mnt 192.168.10.0/24

三、客户端挂载:

1、安装NFS

[root@nfs-client1 ~]# yum -y install rpcbind nfs-utils

2、验证NFS:

[root@nfs-client1 ~]# showmount -e 192.168.10.10
Export list for 192.168.10.10:
/opt *
/mnt 192.168.10.0/24

3、挂载NFS:

[root@nfs-client1 ~]# mount -t nfs 192.168.10.10:/mnt /mnt
[root@nfs-client1 ~]# mount -t nfs 192.168.10.10:/opt /opt
[root@nfs-client1 ~]# df -Th
文件系统 类型 容量 已用 可用 已用% 挂载点
# 省略输出
192.168.10.10:/mnt nfs4 17G 1.5G 16G 9% /mnt
192.168.10.10:/opt nfs4 17G 1.5G 16G 9% /opt

四、补充部分

1、关于放行防火墙:

查询NFS需要端口:

[root@nfs-server ~]# rpcinfo -p 127.0.0.1
program vers proto port service
100000 4 tcp 111 portmapper
100000 3 tcp 111 portmapper
100000 2 tcp 111 portmapper
100000 4 udp 111 portmapper
100000 3 udp 111 portmapper
100000 2 udp 111 portmapper
100005 1 udp 20048 mountd
100005 1 tcp 20048 mountd
100005 2 udp 20048 mountd
100005 2 tcp 20048 mountd
100005 3 udp 20048 mountd
100005 3 tcp 20048 mountd
100003 3 tcp 2049 nfs
100003 4 tcp 2049 nfs
100227 3 tcp 2049 nfs_acl
100003 3 udp 2049 nfs
100003 4 udp 2049 nfs
100227 3 udp 2049 nfs_acl
100021 1 udp 52794 nlockmgr
100021 3 udp 52794 nlockmgr
100021 4 udp 52794 nlockmgr
100021 1 tcp 37951 nlockmgr
100021 3 tcp 37951 nlockmgr
100021 4 tcp 37951 nlockmgr

放行TCP端口:

[root@nfs-server ~]# firewall-cmd --permanent --add-port=111/tcp --permanent
[root@nfs-server ~]# firewall-cmd --permanent --add-port=20048/tcp --permanent
[root@nfs-server ~]# firewall-cmd --permanent --add-port=2049/tcp --permanent
[root@nfs-server ~]# firewall-cmd --permanent --add-port=52795/tcp --permanent
[root@nfs-server ~]# firewall-cmd --permanent --add-port=37951/tcp --permanent
[root@nfs-server ~]# firewall-cmd --reload

放行UDP端口:

[root@nfs-server ~]# firewall-cmd --permanent --add-port=111/udp --permanent
[root@nfs-server ~]# firewall-cmd --permanent --add-port=20048/udp --permanent
[root@nfs-server ~]# firewall-cmd --permanent --add-port=2049/udp --permanent
[root@nfs-server ~]# firewall-cmd --permanent --add-port=52795/udp --permanent
[root@nfs-server ~]# firewall-cmd --reload

查看放行端口:

[root@nfs-server ~]# firewall-cmd --list-ports

如何清空防火墙规则?

[root@nfs-server ~]# rm -rf /etc/firewalld/zones
[root@nfs-server ~]# systemctl restart firewalld

2NFS参数介绍:

ro #只读访问。
rw #读写访问。
sync #资料同步写入到内存与硬盘当中。
async #资料会先暂存于内存当中,而非直接写入硬盘。
secure #NFS通过1024以下的安全TCP/IP端口发送。
insecure #NFS通过1024以上的端口发送。
wdelay #如果多个用户要写入NFS目录,则归组写入(默认)。
no_wdelay #如果多个用户要写入NFS目录,则立即写入,当使用async时,无需此设置。
hide #在NFS共享目录中不共享其子目录。
no_hide #共享NFS目录的子目录。
subtree_check #如果共享/usr/bin之类的子目录时,强制NFS检查父目录的权限(默认)。
no_subtree_check #和上面相对,不检查父目录权限。
all_squash #共享文件的UID和GID映射匿名用户anonymous,适合公用目录。
no_all_squash #保留共享文件的UID和GID(默认)。
root_squash #root用户的所有请求映射成如anonymous用户一样的权限(默认)。
no_root_squash #root用户具有根目录的完全管理访问权限。

3、客户端参数优化:

mount挂载:

NFS高并发环境下的服务端重要优化(mount-o参数)。
async:异步同步,此参数会提高I/O性能,但会降低数据安全(除非对性能要求很高,对数据可靠性不要求
的场合。一般生产环境,不推荐使用)。
noatime:取消更新文件系统上的inode访问时间,提升I/O性能,优化I/O目的,推荐使用。
nodiratime:取消更新文件系统上的directoryinode访问时间,高并发环境,推荐显式应用该选项,提高
系统性能。
intr:可以中断不成功的挂载。
rsize/wsize:读取(rsize)/写入(wsize)的区块大小(blocksize),这个设置值可以影响客户端与
服务端传输数据的缓冲存储量。一般来说,如果在局域网内,并且客户端与服务端都具有足够的内存,这个值
可以设置大一点,比如说32768(bytes),提升缓冲区块将可提升NFS文件系统的传输能力。但设置的值也不
要太大,最好是实现网络能够传输的最大值为限。

内核优化:

[root@nfs-client1 ~]# vi /etc/sysctl.d/nfs.conf
net.core.wmem_default=8388608
net.core.rmem_default=8388608
net.core.rmem_max=16777216
net.core.wmem_max=16777216
[root@nfs-client1 ~]# sysctl -p /etc/sysctl.d/nfs.conf
net.core.wmem_default = 8388608
net.core.rmem_default = 8388608
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216


相关文章
|
关系型数据库 MySQL 网络安全
|
Linux
nfs client高性能参数设置
linux kernel中sunrpc的实现是单连接和长链接的,为了提高并发性能,在单连接的基础上提供多个slot,通过tcp_slot_table_entries参数设置。slot个数越多,nfs请求并发处理能力越强,如果slot个数很小,而nfs请求又很多,就会在client排队等待。
9244 0
|
缓存 JavaScript API
深入解析API调用:构建现代应用的数据连接纽带
在今天的应用开发中,API调用是构建现代应用的关键组成部分之一。通过API调用,应用程序可以与外部服务通信,获取数据、发送请求并实现各种功能。本博客将深入研究API调用的核心概念、最佳实践以及如何在应用程序中创建强大的数据连接。
611 0
|
Shell Linux
Linux——ifconfig中没有ens33 连接不上Xshell
Linux——ifconfig中没有ens33 连接不上Xshell
508 0
|
存储 安全 Unix
网络文件系统 (NFS)
【10月更文挑战第12天】
469 5
|
9月前
|
存储 人工智能 测试技术
跨模态大升级!少量数据高效微调,LLM教会CLIP玩转复杂文本
LLM2CLIP是一种创新方法,旨在通过利用大型语言模型(LLM)的能力来改进CLIP多模态模型。该方法通过对比学习微调LLM,增强其文本判别性,并将其作为CLIP的强教师,从而显著提升CLIP处理长复杂文本和跨语言任务的能力。实验表明,LLM2CLIP在多个基准测试中优于现有模型,特别是在长文本检索任务上性能提升了16.5%。尽管如此,该方法在实际应用中的鲁棒性和资源需求仍需进一步验证。论文链接:https://arxiv.org/pdf/2411.04997。
332 70
|
8月前
|
缓存 NoSQL Java
Redis应用—8.相关的缓存框架
本文介绍了Ehcache和Guava Cache两个缓存框架及其使用方法,以及如何自定义缓存。主要内容包括:Ehcache缓存框架、Guava Cache缓存框架、自定义缓存。总结:Ehcache适合用作本地缓存或与Redis结合使用,Guava Cache则提供了更灵活的缓存管理和更高的并发性能。自定义缓存可以根据具体需求选择不同的数据结构和引用类型来实现特定的缓存策略。
460 16
Redis应用—8.相关的缓存框架
|
存储 监控 安全
计算机硬件日常维护
【7月更文挑战第28天】
269 4
|
12月前
|
缓存 监控 安全
检测 Webpack 5 持久化缓存是否存在安全漏洞
【10月更文挑战第23天】通过全面、系统地检测和评估,能够及时发现 Webpack 5 持久化缓存的安全漏洞,并采取有效的措施进行修复,保障项目的安全稳定运行。同时,要持续关注安全技术的发展和变化,不断提升安全检测能力,以应对日益复杂的安全挑战。
|
12月前
|
传感器 监控 物联网
新兴技术发展趋势与应用场景###
本文探讨了物联网(IoT)和虚拟现实(VR)这两项新兴技术的发展趋势及其在各行业的广泛应用。物联网通过智能设备互联实现实时数据监控与管理,广泛应用于智能家居、智慧城市和工业自动化领域。虚拟现实提供沉浸式体验,已深入游戏、教育、医疗等行业,显著提升互动性和效率。随着5G普及和技术融合,未来这些技术将进一步推动智能化发展,改变生活和工作方式。 ###
下一篇
开通oss服务