003 NFS服务安装

本文介绍如何在Linux系统上安装和配置NFS服务,包括安装NFS包、设置NFS根目录、导出文件系统及挂载操作等步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

安装NFS服务

# 安装nfs
[root@k8s-master01 nfs]# dnf install nfs-utils

Repository extras is listed more than once in the configuration
Last metadata expiration check: 3:24:27 ago on Wed 19 May 2021 10:33:02 AM CST.
Package nfs-utils-1:2.3.3-41.el8.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!

# 启动nfs服务
[root@k8s-master01 nfs]# systemctl enable --now nfs-server

Created symlink /etc/systemd/system/multi-user.target.wants/nfs-server.service → /usr/lib/systemd/system/nfs-server.service.

# 查看可用版本
[root@k8s-master01 nfs]# cat /proc/fs/nfsd/versions

-2 +3 +4 +4.1 +4.2

创建文件系统(根据实际使用配置)

# 创建全局NFS根目录
[root@k8s-master01 /]# mkdir -p /data/nfs

# 将分享目录(share)绑定至NFS根目录(share)中
[root@k8s-master01 /]# mkdir -p /data/nfs/share
[root@k8s-master01 share]# sudo mount --bind /home/share /data/nfs/share

# 挂载持久化(按需配置)
[root@k8s-master01 share]# vim /etc/fstab 

# 末尾添加 
/home/share /data/nfs/share      none   bind   0   0

导出文件系统

说明: 配置导出文件夹的权限

[root@k8s-master01 share]# vim /etc/exports

# 添加
/data/nfs/ 192.168.100.0/24(rw,sync,no_subtree_check,crossmnt,fsid=0)

# fsid=0 定义了 NFS 根目录/data/nfs。
# 来自192.168.0.0/24网络的所有客户端被允许访问 NFS 卷。
# crossmnt选项是必要的,用来分享被导出目录的子目录。

# 导出分享
[root@k8s-master01 share]# exportfs -ra

挂载/取消挂载命令

# 挂载命令
[root@k8s-master02 ~]# mount -t nfs 192.168.100.12:/data/nfs/share /data/nfs/share

# 取消挂载命令
[root@k8s-master02 ~]# umount /data/nfs/share
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值