> ## Documentation Index
> Fetch the complete documentation index at: https://docs.akria.net/llms.txt
> Use this file to discover all available pages before exploring further.

# 存储持久化 | Storage

> K3s 本地路径供应器与持久化卷管理

## 💾 存储方案 | Storage Strategy

集群在基础阶段采用 **K3s Local Path Provisioner**。虽然这是本地磁盘挂载，但我们通过节点亲和性（Node Affinity）实现了核心数据的定向持久化。

### 核心物理路径

所有持久化数据（PVC）均存储在节点的以下物理路径：
`/var/lib/rancher/k3s/storage/`

### 服务与挂载对应表

| 命名空间         | 服务名称            | 物理节点        | 存储用途                 |
| :----------- | :-------------- | :---------- | :------------------- |
| `infra`      | **PostgreSQL**  | `worker-03` | Metabase & n8n 结构化数据 |
| `apps`       | **Rocket.Chat** | `worker-03` | MongoDB 聊天记录与附件      |
| `infra`      | **NocoDB**      | `worker-03` | 无代码数据库配置             |
| `monitoring` | **Grafana**     | `worker-03` | 监控指标与看板配置            |

***

## 🛠️ 数据搬迁与节点漂移

当节点需要维护或磁盘爆满时，我们采用“冷迁移”方案进行数据搬迁。

### 典型迁移工作流 (rsync)

```bash theme={null}
# 1. 停止原节点应用，确保文件不被占用
kubectl scale deployment <app-name> --replicas=0

# 2. 从源节点执行物理同步
rsync -avz --progress /var/lib/rancher/k3s/storage/<pvc-dir> root@target-node:/var/lib/rancher/k3s/storage/

# 3. 修改 PV 内容，更新节点亲和性 (NodeAffinity)
# 4. 恢复应用副本数
kubectl scale deployment <app-name> --replicas=1
```

## ⚠️ 风险提示 | Storage Risks

<Warning>
  **本地路径供应器的局限性**：
  由于数据绑定在物理磁盘上，若 `worker-03` 硬件故障且无备份，数据将无法恢复。

  **应对方案**：请务必参考 [备份策略](/technical/infra-deploy/backup-strategy) 章节进行每日异地备份。
</Warning>
