计算资源整合设计
· 阅读需 11 分钟
这是一个非常完整的个人计算资源整合方案。我来帮你系统性地梳理和优化这个架构,并提供具体的实施配置。
🏗️ 整体架构图
┌─────────────────────────────────────────────────────────┐
│ 控制层 (OpenClaw) │
│ iPhone 12mini / 13 / 小米13 │
└─────────────────────────────────────────────────────────┘
│
┌───────────────┼───────────────┐
▼ ▼ ▼
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ 办公网 │ │ 家庭网 │ │ 移动办公 │
│ Mac mini │◄─┤ NUC Mint │ │ MacBook Pro │
│ (工作主力) │ │ (服务器/DB) │ │ (探索学习) │
└──────┬──────┘ └──────┬──────┘ └─────────────┘
│ │
└───────┬────────┘
▼
┌─────────────┐
│ Tailscale │
│ 虚拟局域网 │
└──────┬──────┘
│
┌─────────────┼─────────────┐
▼ ▼ ▼
┌────────┐ ┌──────────┐ ┌──────────┐
│ GitLab │ │ CSDM工时 │ │ Cloudflare│
│ 代码仓 │ │ 管理系统 │ │ 内网穿透 │
└────────┘ └──────────┘ └──────────┘
🖥️ 设备角色优化建议
1. NUC Linux Mint - 核心服务器 ⭐
角色定位: 家庭数据中心 + 备份中枢 + 开发测试环境
建议服务:
- Docker 容器编排 (Portainer 管理)
- PostgreSQL / MySQL 主数据库
- Redis 缓存 + 消息队列
- MinIO 对象存储 (S3兼容)
- Gitea 轻量代码托管 (GitLab镜像)
- Syncthing 文件同步核心节点
- 归档硬盘挂载点 (/mnt/archive)
2. Mac mini - 工作终端
角色定位: 开发主力机 + 办公网关
建议配置:
- 开发环境: VS Code / Cursor / Xcode
- 本地Docker Desktop (轻量容器)
- 连接到NUC的远程数据库/Redis
- Tailscale subnet router (如需访问公司网段)
3. MacBook Pro 2015 - 移动/实验环境
角色定位: 学习探索 + 应急办公 + 备用终端
建议用途:
- 新框架/语言实验 (避免污染主力机)
- 外出办公轻量使用
- 作为备用节点加入Tailscale
🔧 具体配置实施
Tailscale 网络配置
# 在所有设备安装后,设置标签和ACL
# 1. NUC 作为网络出口和文件服务器
sudo tailscale up --advertise-exit-node --advertise-routes=192.168.1.0/24
# 2. Mac mini 开启远程访问
sudo tailscale up --ssh
# 3. 启用 MagicDNS 和 HTTPS证书
# 在 Tailscale Admin Console 开启:
# - Magic DNS
# - HTTPS certificates
# - Tailscale SSH
ACL 配置示例 (huJSON 格式):
{
"acls": [
{"action": "accept", "src": ["group:mobile"], "dst": ["tag:server:*"]},
{"action": "accept", "src": ["tag:work"], "dst": ["tag:server:22,80,443,5432,6379"]},
{"action": "accept", "src": ["tag:work"], "dst": ["tag:work:*"]}
],
"tagOwners": {
"tag:server": ["autogroup:admin"],
"tag:work": ["autogroup:admin"]
}
}
开发环境国内化 - 完整配置
1. macOS (Mac mini & MacBook)
# Homebrew 清华镜像
export HOMEBREW_INSTALL_FROM_API=1
export HOMEBREW_API_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/api"
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles"
export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"
# 写入 ~/.zshrc
cat >> ~/.zshrc << 'EOF'
# Homebrew 国内镜像
export HOMEBREW_INSTALL_FROM_API=1
export HOMEBREW_API_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/api"
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles"
export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"
# Node.js 国内镜像
export NVM_NODEJS_ORG_MIRROR=https://npmmirror.com/mirrors/node
export NODE_MIRROR=https://npmmirror.com/mirrors/node
export ELECTRON_MIRROR=https://npmmirror.com/mirrors/electron/
export ELECTRON_BUILDER_BINARIES_MIRROR=https://npmmirror.com/mirrors/electron-builder-binaries/
# Python 国内镜像
export PIP_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple
export PIP_TRUSTED_HOST=pypi.tuna.tsinghua.edu.cn
# Ruby 国内镜像
export GEM_SOURCES=https://gems.ruby-china.com
# CocoaPods 清华镜像
export CP_HOME_DIR="$HOME/.cocoapods"
export COCOAPODS_SPECS_GIT_URL=https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git
# Golang 国内代理
export GOPROXY=https://goproxy.cn,direct
export GOSUMDB=sum.golang.google.cn
# Rust 国内镜像
export RUSTUP_DIST_SERVER=https://rsproxy.cn
export RUSTUP_UPDATE_ROOT=https://rsproxy.cn/rustup
EOF
# npm 使用淘宝镜像
npm config set registry https://registry.npmmirror.com
npm install -g pnpm yarn
pnpm config set registry https://registry.npmmirror.com
yarn config set registry https://registry.npmmirror.com
# CocoaPods 设置清华镜像
pod repo remove master
pod repo add master https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git
2. NUC Linux Mint
# 1. 更换 APT 源为阿里云
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
sudo tee /etc/apt/sources.list << 'EOF'
deb https://mirrors.aliyun.com/linuxmint zena main upstream import backport
deb https://mirrors.aliyun.com/ubuntu noble main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu noble-updates main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu noble-backports main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu noble-security main restricted universe multiverse
EOF
# 2. Docker 阿里云镜像加速器
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json << 'EOF'
{
"registry-mirrors": [
"https://<你的ID>.mirror.aliyuncs.com",
"https://docker.mirrors.ustc.edu.cn",
"https://hub-mirror.c.163.com"
],
"log-driver": "json-file",
"log-opts": {
"max-size": "10m",
"max-file": "3"
}
}
EOF
sudo systemctl restart docker
# 3. pip 清华镜像
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
# 4. npm 国内镜像 (同 macOS)
# 5. Golang 代理
echo 'export GOPROXY=https://goproxy.cn,direct' >> ~/.bashrc
归档备份系统架构
┌─────────────────────────────────────────────────────────┐
│ 数据分层策略 │
├─────────────────────────────────────────────────────────┤
│ 热数据 (SSD) │ 温数据 (外置HDD) │ 冷数据 (云端) │
│ ─────────── │ ─────────────── │ ───────────── │
│ • 当前项目 │ • 历史项目归档 │ • GitHub Releases│
│ • 活跃数据库 │ • 大文件/媒体 │ • Gitee 仓库 │
│ • 常用文档 │ • 备份镜像 │ • Cloudflare R2 │
│ • 开发环境 │ • 日志文件 │ • 网盘 (阿里云) │
└─────────────────────────────────────────────────────────┘
NUC 归档服务器配置
# 1. 挂载归档硬盘 (假设 /dev/sdb1)
sudo mkdir -p /mnt/archive
sudo blkid /dev/sdb1 # 获取UUID
echo 'UUID=xxxxx /mnt/archive ext4 defaults,noatime 0 2' | sudo tee -a /etc/fstab
sudo mount -a
# 2. 目录结构规划
sudo mkdir -p /mnt/archive/{backups,projects,media,logs,databases}
sudo chown -R $USER:$USER /mnt/archive
# 3. 安装 restic (现代化备份工具)
sudo apt install restic
# 初始化备份仓库
restic init --repo /mnt/archive/backups/restic-repo
# 设置密码环境变量
export RESTIC_PASSWORD="your-secure-password"
echo 'export RESTIC_PASSWORD="your-secure-password"' >> ~/.bashrc
自动化备份脚本 (/opt/scripts/backup.sh)
#!/bin/bash
# 每日自动备份脚本
DATE=$(date +%Y%m%d)
LOG_FILE="/var/log/backup-$DATE.log"
exec > >(tee -a "$LOG_FILE") 2>&1
echo "========== 备份开始: $(date) =========="
# 1. 数据库备份 (PostgreSQL示例)
echo ">>> 备份数据库..."
sudo -u postgres pg_dumpall | gzip > /mnt/archive/databases/postgres-full-$DATE.sql.gz
find /mnt/archive/databases -name "postgres-full-*.sql.gz" -mtime +30 -delete
# 2. Redis 持久化备份
echo ">>> 备份 Redis..."
redis-cli BGSAVE
sleep 5
cp /var/lib/redis/dump.rdb /mnt/archive/databases/redis-$DATE.rdb
find /mnt/archive/databases -name "redis-*.rdb" -mtime +30 -delete
# 3. 项目代码备份 (使用 restic)
echo ">>> 备份项目文件..."
restic -r /mnt/archive/backups/restic-repo backup \
/home/user/projects \
/home/user/documents \
--exclude-file=/opt/scripts/backup-exclude.txt \
--tag "daily,$DATE"
# 4. 清理旧备份 (保留最近30天,每月1号保留月度备份)
echo ">>> 清理旧备份..."
restic -r /mnt/archive/backups/restic-repo forget \
--keep-daily 7 \
--keep-weekly 4 \
--keep-monthly 12 \
--prune
# 5. 同步到云端 (Gitee/GitHub)
echo ">>> 同步到云端..."
cd /home/user/projects && ./sync-to-gitee.sh
echo "========== 备份完成: $(date) =========="
排除文件配置 (/opt/scripts/backup-exclude.txt)
# 依赖和缓存
node_modules
vendor
__pycache__
*.pyc
.pytest_cache
.mypy_cache
.ruff_cache
# 构建输出
dist
build
target
out
.next
.nuxt
# 日志和临时文件
*.log
*.tmp
.DS_Store
Thumbs.db
# 大型媒体文件 (单独处理)
*.mp4
*.mov
*.iso
*.dmg
# IDE
.idea
.vscode
*.swp
*.swo
Crontab 定时任务
# 编辑 crontab
crontab -e
# 每日凌晨2点执行备份
0 2 * * * /opt/scripts/backup.sh
# 每周日凌晨3点执行深度清理
0 3 * * 0 /opt/scripts/cleanup.sh
# 每小时同步代码到 Gitee
0 * * * * cd /home/user/projects && git push gitee main
文档搜索与知识管理
推荐方案:
方案A (轻量):
- 搜索: ripgrep + fzf (本地)
- 管理: Obsidian + Git同步
方案B (自托管):
- Meilisearch: 轻量级搜索引擎
- Outline: 团队Wiki (Docker部署)
- 索引 /mnt/archive/documents
方案C (混合):
- 本地: AnyTXT Searcher (全文检索)
- 云端: Notion / 飞书 (摘要同步)
Meilisearch 部署 (NUC Docker):
# docker-compose.yml
version: '3'
services:
meilisearch:
image: getmeili/meilisearch:latest
container_name: meilisearch
environment:
- MEILI_MASTER_KEY=your-master-key
- MEILI_NO_ANALYTICS=true
volumes:
- /mnt/archive/meili_data:/meili_data
ports:
- "7700:7700"
restart: unless-stopped
# 文档爬虫 (自动索引)
doc-indexer:
image: getmeili/docs-scraper:latest
environment:
- MEILISEARCH_HOST_URL=http://meilisearch:7700
- MEILISEARCH_API_KEY=your-master-key
volumes:
- /mnt/archive/documents:/docs:ro
depends_on:
- meilisearch
OpenClaw 远程控制集成
# 概念性架构:OpenClaw 控制端点设计
# 部署在 NUC 上的 FastAPI 服务,接收手机指令
from fastapi import FastAPI, HTTPException
import subprocess
import paramiko
app = FastAPI(title="OpenClaw Control API")
@app.post("/cmd/{device}")
async def remote_command(device: str, command: Command):
"""
设备控制端点:
- mac-mini: 工作机控制
- nuc: 服务器控制
- macbook: 备用机控制
"""
hosts = {
"mac-mini": "100.64.1.2",
"nuc": "127.0.0.1",
"macbook": "100.64.1.3"
}
if device not in hosts:
raise HTTPException(404, "Device not found")
# 通过 Tailscale IP 执行 SSH 命令
result = run_remote(hosts[device], command.script)
return {"status": "ok", "output": result}
@app.get("/status")
async def cluster_status():
"""获取所有设备状态"""
return {
"mac-mini": check_status("100.64.1.2"),
"nuc": get_local_status(),
"macbook": check_status("100.64.1.3"),
"storage": get_storage_stats()
}
@app.post("/backup/trigger")
async def trigger_backup():
"""手动触发备份"""
subprocess.run(["/opt/scripts/backup.sh"], check=True)
return {"message": "Backup started"}
Cloudflare 零成本部署方案
服务矩阵:
域名: autoclaude.cn
服务1 - 网站托管:
平台: Cloudflare Pages
源码: GitHub/GitLab -> 自动部署
用途: 个人主页 / 项目展示
服务2 - API/函数:
平台: Cloudflare Workers
用途: OpenClaw 公网入口 / Webhook接收
服务3 - 对象存储:
平台: Cloudflare R2 (10GB免费)
用途: 备份文件异地存储 / 图床
服务4 - 内网穿透:
平台: Cloudflare Tunnel
部署: NUC 上运行 cloudflared
用途: 无需公网IP访问家庭服务
服务5 - 邮件路由:
平台: Cloudflare Email Routing
用途: hi@autoclaude.cn 转发到个人邮箱
Cloudflare Tunnel 配置 (NUC):
# 安装 cloudflared
wget -q https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb
sudo dpkg -i cloudflared-linux-amd64.deb
# 登录并创建隧道
cloudflared tunnel login
cloudflared tunnel create home-nuc
# 配置 config.yml
mkdir -p ~/.cloudflared
cat > ~/.cloudflared/config.yml << EOF
tunnel: <your-tunnel-id>
credentials-file: /home/user/.cloudflared/<your-tunnel-id>.json
ingress:
- hostname: nuc.autoclaude.cn
service: http://localhost:8080
- hostname: files.autoclaude.cn
service: http://localhost:5244 # 文件管理器
- hostname: db.autoclaude.cn
service: http://localhost:8081 # 数据库管理
- service: http_status:404
EOF
# 安装为系统服务
sudo cloudflared service install
sudo systemctl start cloudflared
📱 移动端 OpenClaw 控制界面 (概念)
<!-- 简化版 PWA 控制面板,可部署到 Cloudflare Pages -->
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>OpenClaw Control</title>
<style>
:root { --primary: #007AFF; --bg: #f5f5f7; }
body { font-family: -apple-system, sans-serif; margin: 0; background: var(--bg); }
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; padding: 16px; }
.card { background: white; border-radius: 16px; padding: 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.online { background: #34C759; } .offline { background: #FF3B30; }
button { width: 100%; padding: 12px; border: none; border-radius: 10px; background: var(--primary); color: white; margin-top: 10px; }
.metric { font-size: 24px; font-weight: 600; color: #1c1c1e; }
.label { font-size: 12px; color: #8e8e93; text-transform: uppercase; }
</style>
</head>
<body>
<div class="grid">
<!-- 设备状态卡片 -->
<div class="card">
<div class="label">Mac Mini</div>
<span class="status-dot online"></span>在线
<div style="margin-top:8px; font-size:13px; color:#666;">
Load: 1.58 | 内存: 12/16GB
</div>
<button onclick="cmd('mac-mini', 'sleep')">睡眠</button>
</div>
<div class="card">
<div class="label">NUC Server</div>
<span class="status-dot online"></span>运行中
<div style="margin-top:8px; font-size:13px; color:#666;">
CPU: 23% | 存储: 83%
</div>
<button onclick="cmd('nuc', 'backup')">立即备份</button>
</div>
<!-- 存储概览 -->
<div class="card" style="grid-column: span 2;">
<div class="label">归档存储</div>
<div style="display:flex; justify-content:space-between; margin-top:8px;">
<div>
<div class="metric">767GB</div>
<div style="font-size:12px;color:#8e8e93;">已用 / 931GB</div>
</div>
<div style="text-align:right;">
<div class="metric">12天</div>
<div style="font-size:12px;color:#8e8e93;">上次备份</div>
</div>
</div>
<div style="height:4px;background:#e5e5ea;border-radius:2px;margin-top:12px;">
<div style="width:83%;height:100%;background:var(--primary);border-radius:2px;"></div>
</div>
</div>
<!-- 快捷操作 -->
<div class="card" style="grid-column: span 2;">
<div class="label">快捷操作</div>
<div style="display:grid; grid-template-columns: repeat(3, 1fr); gap:8px; margin-top:12px;">
<button onclick="openApp('gitlab')">GitLab</button>
<button onclick="openApp('csdm')">工时系统</button>
<button onclick="openApp('files')">文件管理</button>
</div>
</div>
</div>
<script>
// 调用 Cloudflare Worker API
async function cmd(device, action) {
await fetch(`https://api.autoclaude.cn/cmd/${device}`, {
method: 'POST',
body: JSON.stringify({action})
});
}
</script>
</body>
</html>
🚀 实施优先级建议
| 阶段 | 任务 | 预计时间 | 影响 |
|---|---|---|---|
| P0 | Tailscale 组网 + 设备互通 | 30分钟 | ⭐⭐⭐ 基础网络 |
| P0 | NUC Docker + 数据库部署 | 2小时 | ⭐⭐⭐ 核心服务 |
| P1 | 开发环境国内镜像配置 | 1小时 | ⭐⭐ 日常效率 |
| P1 | 归档硬盘挂载 + restic 备份 | 3小时 | ⭐⭐⭐ 数据安全 |
| P2 | Cloudflare Tunnel 内网穿透 | 1小时 | ⭐⭐ 远程访问 |
| P2 | 自动化脚本 + Crontab | 2小时 | ⭐⭐ 自动化 |
| P3 | OpenClaw API + 手机端界面 | 4小时 | ⭐ 便利性 |
| P3 | 文档搜索系统部署 | 3小时 | ⭐ 知识管理 |
这个方案充分利用了你现有的硬件资源,通过 Tailscale 实现安全组网,以 NUC 作为数据中心核心,配合 Cloudflare 的免费服务实现零成本运维。需要我详细展开任何部分的配置细节吗?
