synchronization
Some checks failed
continuous-integration/drone Build is failing

This commit is contained in:
2025-08-25 15:57:40 +08:00
commit cee91802b3
106 changed files with 9124 additions and 0 deletions

View File

@@ -0,0 +1,123 @@
> 本文作者:丁辉
# Linux部署NFS存储
[官方](https://nfs.sourceforge.net/)
| 节点 | IP |
| :--: | :----------: |
| NFS | 192.168.1.10 |
1. 部署 Nfs 程序
- Centos部署
```bash
yum install nfs-utils rpcbind -y
```
- Ubuntu部署
```bash
apt install nfs-kernel-server -y
```
>客户端部署 `apt install nfs-common -y` 正常情况下安装 `nfs-kernel-server` 会自动安装客户端
2. 创建共享目录
```bash
mkdir /data
chmod -R 777 /data
```
3. 添加配置文件
```bash
echo "/data 192.168.1.0/24(rw,sync,insecure,no_subtree_check,no_root_squash)" >> /etc/exports
```
> 允许所有(不建议在生产使用)
>
> ```bash
> echo "/data *(rw,sync,insecure,no_subtree_check,no_root_squash)" >> /etc/exports
> ```
4. 启动 Nfs
```
systemctl start rpcbind
systemctl start nfs-server
systemctl enable rpcbind
systemctl enable nfs-server
```
5. 查看
```bash
showmount -e 127.0.0.1
```
## 其它节点挂载 Nfs 存储到本地
> NFS 节点开放端口
>
> - NFS服务端口(Mountd)
>
> ```bash
> iptables -A INPUT -p tcp --dport 2049 -j ACCEPT
> iptables -A INPUT -p udp --dport 2049 -j ACCEPT
> ```
>
> - Portmapper(端口映射程序)
>
> ```bash
> iptables -A INPUT -p tcp --dport 111 -j ACCEPT
> iptables -A INPUT -p udp --dport 111 -j ACCEPT
> ```
- 手动挂载
```bash
mount.nfs 192.168.1.10:/data /data
```
- 开机自动挂载
```bash
echo "192.168.1.10:/data /data nfs defaults 0 0" >> /etc/fstab
```
## Nfs 参数解释
参考 man 文档配置参数
```bash
man exports
```
**参数解释**
| 参数 | 解释 |
| ---------------- | ------------------------------------------------------------ |
| rw | 允许客户端对共享的文件系统进行读写操作。 |
| sync | 所有对共享文件系统的写操作都会同步到存储设备上。 |
| insecure | 允许不安全的客户端访问共享的文件系统。 |
| no_subtree_check | 禁止对子目录进行共享级别的访问控制检查。 |
| no_root_squash | 不对远程 root 用户进行权限限制,允许其以 root 身份访问共享。 |
## Exportfs参数解释
修改 exportfs 后重新加载配置
```bash
exportfs -arv
```
**参数解释**
| 选项 | 解释 |
| ---- | ------------------------------------------------------ |
| -a | 导出或取消导出 /etc/exports 文件中列出的所有文件系统。 |
| -r | 刷新 /etc/exports 文件并重新加载 NFS 导出。 |
| -v | 输出详细的日志信息,包括正在进行的操作和任何错误消息。 |