本指南记录了如何在低配服务器上部署 OpenClaw,通过内网穿透调用本地电脑的 GLM-4.7-Flash 模型,并连接飞书机器人的完整过程。
┌──────────────────────────────────────────────────────────────────────┐
│ 飞书云端 │
│ │ │
│ ▼ WebSocket 长连接 │
│ ┌────────────────────────────────────────────────────────────────┐ │
│ │ 云服务器 (3核 4.5GB Ubuntu 20.04) │ │
│ │ ┌──────────┐ ┌─────────────────────────────────────────┐ │ │
│ │ │ 1Panel │ │ OpenClaw │ │ │
│ │ │(可视化) │ │ 配置 Ollama API → frp 隧道地址 │ │ │
│ │ └──────────┘ └─────────────────┬───────────────────────┘ │ │
│ │ frps 服务端 (端口 7100, 11434) │ │
│ └───────────────────────────────────┼────────────────────────────┘ │
│ │ frp 内网穿透 │
│ ▼ │
│ ┌────────────────────────────────────────────────────────────────┐ │
│ │ 本地电脑 (Win11 + RTX 4070 Super 16GB) │ │
│ │ frpc 客户端 │ │
│ │ ┌───────────────────────┐ │ │
│ │ │ Ollama │ │ │
│ │ │ GLM-4.7-Flash-16K │ │ │
│ │ │ (Q4_K_M 量化) │ │ │
│ │ │ 监听 127.0.0.1:11434 │ │ │
│ │ └───────────────────────┘ │ │
│ └────────────────────────────────────────────────────────────────┘ │
└──────────────────────────────────────────────────────────────────────┘
| 设备 | 配置 | 用途 |
|---|---|---|
| 云服务器 | 3核 CPU, 4.5GB RAM, Ubuntu 20.04 | 运行 OpenClaw, frp 服务端 |
| 本地电脑 | Win11, RTX 4070 Super 16GB | 运行 Ollama + GLM-4.7-Flash |
| 软件 | 版本 |
|---|---|
| Ollama | 0.15.4 |
| OpenClaw | 2026.1.30 |
| frp | 0.61.1 |
| Node.js | 22.x |
| GLM-4.7-Flash | Q4_K_M 量化版 |
从官网下载安装:https://ollama.com/download
验证安装:
ollama --version
# 输出: ollama version is 0.15.4ollama pull glm-4.7-flash:q4_k_m
⚠️ 关键点:OpenClaw 要求最小上下文窗口为 16000 tokens,不能设置太小!
# 创建 Modelfile
@"
FROM glm-4.7-flash:q4_k_m
PARAMETER num_ctx 16384
"@ | Out-File -FilePath "Modelfile" -Encoding ASCII
# 创建自定义模型
ollama create glm-4.7-flash-16k -f Modelfile
# 验证
ollama list# 创建目录并下载
mkdir C:\frp -Force
cd C:\frp
Invoke-WebRequest -Uri "https://github.com/fatedier/frp/releases/download/v0.61.1/frp_0.61.1_windows_amd64.zip" -OutFile "frp.zip"
Expand-Archive -Path "frp.zip" -DestinationPath "." -Force
cd frp_0.61.1_windows_amd64创建 frpc.toml:
Set-Content -Path "frpc.toml" -Value @"
serverAddr = "你的服务器公网IP"
serverPort = 7100
auth.token = "ollama_frp_token_2026"
[[proxies]]
name = "ollama-api"
type = "tcp"
localIP = "127.0.0.1"
localPort = 11434
remotePort = 11434
"@.\frpc.exe -c frpc.toml看到以下输出表示成功:
[I] login to server success
[I] [ollama-api] start proxy success
mkdir -p ~/frp && cd ~/frp
wget https://github.com/fatedier/frp/releases/download/v0.61.1/frp_0.61.1_linux_amd64.tar.gz
tar -xzf frp_0.61.1_linux_amd64.tar.gz
cd frp_0.61.1_linux_amd64创建配置 frps.toml:
cat > frps.toml << 'EOF'
bindPort = 7100
webServer.addr = "0.0.0.0"
webServer.port = 7600
webServer.user = "admin"
webServer.password = "Ollama@2026"
auth.token = "ollama_frp_token_2026"
EOF启动服务端:
nohup ./frps -c frps.toml > frps.log 2>&1 &开放防火墙:
sudo ufw allow 7100/tcp
sudo ufw allow 7600/tcp
sudo ufw allow 11434/tcpcurl http://127.0.0.1:11434
# 应返回: Ollama is runningcurl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt-get install -y nodejsnpm install -g pnpm
pnpm setup
source ~/.bashrc
pnpm add -g openclaw@latest --ignore-scriptsopenclaw onboard配置过程中:
- Model/auth provider: 选择 Skip for now
- Default model: 选择 Enter model manually,输入
ollama/glm-4.7-flash-16k:latest - Install missing skill dependencies: 选择 Skip for now
- Enable hooks: 选择 Skip for now
编辑配置文件:
nano ~/.openclaw/openclaw.json完整配置:
{
"models": {
"providers": {
"ollama": {
"baseUrl": "http://127.0.0.1:11434/v1",
"apiKey": "ollama",
"api": "openai-completions",
"models": [
{
"id": "glm-4.7-flash-16k:latest",
"name": "GLM 4.7 Flash 16K",
"reasoning": false,
"input": ["text"],
"cost": {
"input": 0,
"output": 0,
"cacheRead": 0,
"cacheWrite": 0
},
"contextWindow": 16384,
"maxTokens": 8192
}
]
}
}
},
"messages": {
"ackReactionScope": "group-mentions"
},
"agents": {
"defaults": {
"maxConcurrent": 1,
"subagents": {
"maxConcurrent": 2
},
"compaction": {
"mode": "safeguard"
},
"workspace": "/root/.openclaw/workspace",
"model": {
"primary": "ollama/glm-4.7-flash-16k:latest"
},
"models": {
"ollama/glm-4.7-flash-16k:latest": {
"alias": "glm"
}
}
}
},
"gateway": {
"mode": "local",
"auth": {
"mode": "token",
"token": "你的token"
},
"port": 18789,
"bind": "lan",
"tailscale": {
"mode": "off",
"resetOnExit": false
}
},
"skills": {
"install": {
"nodeManager": "pnpm"
}
}
}重启服务:
openclaw gateway restartopenclaw plugins install @openclaw-china/feishuopenclaw config set channels.feishu.appId "你的飞书AppID"
openclaw config set channels.feishu.appSecret "你的飞书AppSecret"
openclaw config set channels.feishu.enabled true
openclaw config set channels.feishu.connectionMode websocket
openclaw gateway restart- 登录 https://open.feishu.cn
- 创建企业自建应用
- 添加机器人能力
- 获取 App ID 和 App Secret
- 配置事件订阅:选择"长连接"模式
- 添加权限:消息与群组 → 接收消息
- 发布应用
| 服务 | 端口 | 说明 |
|---|---|---|
| frp 通信 | 7100 | frpc 与 frps 通信 |
| frp Dashboard | 7600 | Web 监控面板 |
| Ollama API | 11434 | 模型 API |
| OpenClaw Gateway | 18789 | Web UI 和 API |
# 启动 frp 客户端
cd C:\frp\frp_0.61.1_windows_amd64
.\frpc.exe -c frpc.toml
# 查看 Ollama 模型
ollama list
# 查看显存占用
nvidia-smi# 启动 frp 服务端
cd ~/frp/frp_0.61.1_linux_amd64
nohup ./frps -c frps.toml > frps.log 2>&1 &
# OpenClaw 管理
openclaw gateway restart
openclaw gateway status
# 查看日志
tail -f /tmp/openclaw/openclaw-$(date +%Y-%m-%d).log
# 测试 Ollama 连接
curl http://127.0.0.1:11434/v1/models问题:Ubuntu 20.04 默认 cmake 版本是 3.16,OpenClaw 需要 3.19+
解决:
sudo apt remove cmake -y
pip install cmake --upgrade问题:设置 contextWindow=4096 时报错 Model context window too small (4096 tokens). Minimum is 16000.
解决:OpenClaw 要求最小上下文 16000 tokens,需要创建 num_ctx=16384 的自定义模型
问题:配置的模型 ID 与 Ollama 实际模型 ID 不一致导致找不到模型
解决:使用 ollama list 查看完整模型 ID(包括 :latest 后缀),确保配置完全一致
问题:配置飞书时报错 unknown channel id: feishu
解决:需要先安装飞书插件
openclaw plugins install @openclaw-china/feishu问题:gateway.bind 设置为 "0.0.0.0" 或 "all" 报错
解决:有效值为 "loopback"|"lan"|"tailnet"|"auto"|"custom",使用 "lan" 允许局域网访问
问题:GLM-4.7-Flash 默认占用约 15.6GB 显存,接近 16GB 显卡满载
解决:创建限制上下文的自定义模型,使用 PARAMETER num_ctx 16384
文档版本:v1.0
完成日期:2026年2月2日