# 分布式部署指南 ## 架构 ``` 151 (主节点) 46 (算力节点) ├── PostgreSQL ├── SSH 服务 ├── 后端 API (8010) ├── NFS 挂载 151:/root/Fine-tuning/backend/data ├── 前端 (3000) ├── Python 训练环境 (transformers/peft/torch) └── data/(模型/数据集/adapter) └── 远程训练脚本 (app/engines/remote_train.py) ``` ## 151 部署步骤 ```bash cd /root/Fine-tuning git pull # 编辑 .env.docker 或 docker-compose.yml 设置算力节点 vi backend/.env.docker # 修改 COMPUTE_NODE_HOST=183.220.37.46 # 配置 SSH 免密登录到 253 ssh-copy-id root@183.220.37.46 # 启动 docker compose down -v docker compose up -d --build ``` ## 46 配置步骤 ### 1. 安装 NFS 客户端 ```bash # CentOS/RHEL yum install -y nfs-utils # Ubuntu/Debian apt install -y nfs-common ``` ### 2. 挂载 151 的数据目录 ```bash # 创建挂载点 mkdir -p /root/Fine-tuning/backend/data # 挂载 NFS (在 151 上需要先配置 NFS 导出) mount -t nfs 192.168.92.151:/root/Fine-tuning/backend/data /root/Fine-tuning/backend/data ``` ### 3. 安装 Python 训练依赖 ```bash # 在 46 上执行(确保代码路径一致) cd /root/Fine-tuning/backend pip install -r requirements.txt ``` ### 4. 创建应用目录结构 ```bash cd /root/Fine-tuning/backend mkdir -p app/engines app/core app/services app/config app/api # 从 151 同步代码 rsync -av 192.168.92.151:/root/Fine-tuning/backend/app/ ./app/ ``` ## 151 配置 NFS 导出(如需) ```bash # 编辑 /etc/exports echo "/root/Fine-tuning/backend/data *(rw,sync,no_root_squash,no_subtree_check)" >> /etc/exports # 重启 NFS systemctl restart nfs-server exportfs -ra ``` ## 验证 ```bash # 在 151 上测试 SSH 连接 ssh root@183.220.37.46 "python --version" # 测试远程命令 docker exec finetune-backend python -c "from app.config import get_settings; s=get_settings(); print(s.use_remote_compute)" ```