Files
doc/nfs系统创建指南.md
2025-10-16 17:32:48 +08:00

54 lines
1004 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# nfs系统创建指南
意在创建一个可共享、跨节点可用的存储系统供k3s、kubernetes使用的文件系统
**安装nfs-kernel**
```
sudo apt update
sudo apt install -y nfs-kernel-server
```
**创建共享目录**
```
mkdir -p /data/nfs
//编辑权限测试使用777生产环境可以换成特定uid
chmod -R 777 /data/nfs
```
**编辑配置文件**
向/etc/exports文件中追加以下内容
```
/data/nfs 10.42.0.0/16(rw,sync,no_subtree_check,no_root_squash)
```
参数解释:
rw允许读写
sync数据同步写入磁盘
no_subtree_check关闭子树检查提高性能
no_root_squash允许 root 用户访问;
10.42.0.0/16 是 k3s 默认 Pod 网络(可按实际调整)。
tips: 10.42.0.0/16是k3s所有pod的内部所在网段对于集群所在宿主机而言
**应用配置并启动服务**
```
sudo exportfs -ra
sudo systemctl enable nfs-server --now
```
**确认服务状态**
```
sudo systemctl status nfs-server
```