世界上有一种部署,叫做"我想让Agent在全球各地为我工作"。如果你的Agent需要24/7运行、处理不同地区的任务、或者只是想让它们"分布式生存",远程节点部署就是你的答案。
一、什么是 OpenClaw 节点系统
OpenClaw的节点(Node)系统允许你在多个服务器上部署Agent实例,并通过中央Gateway统一管理:
核心概念:
- Gateway:中央控制节点,管理所有连接
- Worker Node:执行任务的远程节点
- Node Controller:节点控制器,处理远程指令
二、部署架构选择
| 架构类型 | 适用场景 | 复杂度 |
|---|---|---|
| 单节点 | 个人使用、开发测试 | ⭐ 简单 |
| 主从模式 | 小规模团队、多任务处理 | ⭐⭐ 中等 |
| 分布式集群 | 企业级、高可用需求 | ⭐⭐⭐ 复杂 |
三、远程节点部署步骤
3.1 准备远程服务器
选择你的远程服务器(可以是VPS、云服务器、甚至家里的树莓派):
# 系统要求
- Linux (Ubuntu 22.04+ 推荐)
- Node.js 22+
- 至少 2GB RAM
- 稳定的网络连接
# 推荐云服务商
- Hetzner: €4.51/月 (性价比之王)
- DigitalOcean: $6/月
- AWS Lightsail: $5/月
3.2 在远程服务器安装 OpenClaw
# 1. 连接到远程服务器
ssh root@your-remote-server-ip
# 2. 安装 Node.js 22
curl -fsSL https://deb.nodesource.com/setup_22.x | bash -
apt-get install -y nodejs
# 3. 安装 OpenClaw
npm install -g openclaw
# 4. 初始化配置
openclaw init
openclaw config
3.3 配置节点模式
编辑远程服务器的配置文件:
# ~/.openclaw/config.yaml
node:
enabled: true
mode: worker # 设置为工作节点模式
gatewayUrl: "wss://your-gateway-server.com/gateway"
token: "your-secure-token"
# 节点标识
name: "tokyo-worker-1"
region: "asia-east"
capabilities:
- web_search
- web_fetch
- browser
- exec
# 资源限制
limits:
maxConcurrentTasks: 5
maxMemoryMB: 2048
maxCpuPercent: 80
3.4 配置 Gateway 接受连接
在主服务器的 Gateway 配置中添加节点授权:
# Gateway 配置
gateway:
nodeController:
enabled: true
port: 8080
authorizedNodes:
- name: "tokyo-worker-1"
token: "your-secure-token"
allowedCapabilities: ["*"]
- name: "singapore-worker-1"
token: "another-secure-token"
allowedCapabilities: ["web_search", "web_fetch"]
四、远程控制与管理
4.1 查看节点状态
# 列出所有连接的节点
nodes({ action: "status" })
# 返回示例
{
"nodes": [
{
"id": "tokyo-worker-1",
"status": "online",
"region": "asia-east",
"uptime": "3d 12h",
"activeTasks": 2,
"capabilities": ["web_search", "web_fetch", "browser"]
}
]
}
4.2 远程执行命令
# 在特定节点上执行命令
exec({
command: "df -h",
node: "tokyo-worker-1"
})
4.3 指定节点运行任务
# 在特定节点上运行Agent
sessions_spawn({
task: "搜索日本市场的AI工具趋势",
runtime: "subagent",
node: "tokyo-worker-1" # 指定日本节点
})
五、高级部署场景
5.1 多区域部署
为不同区域部署节点,优化访问速度:
# 节点配置示例
nodes:
- name: "us-west-1"
region: "us-west"
gatewayUrl: "wss://gateway.miaoquai.com"
- name: "eu-central-1"
region: "eu-central"
gatewayUrl: "wss://gateway.miaoquai.com"
- name: "asia-east-1"
region: "asia-east"
gatewayUrl: "wss://gateway.miaoquai.com"
5.2 使用 Docker 部署
# Dockerfile
FROM node:22-alpine
RUN npm install -g openclaw
COPY config.yaml /root/.openclaw/
CMD ["openclaw", "node", "start"]
# docker-compose.yml
version: '3.8'
services:
openclaw-node:
image: openclaw-node:latest
environment:
- GATEWAY_URL=wss://gateway.example.com
- NODE_TOKEN=${NODE_TOKEN}
restart: unless-stopped
5.3 Kubernetes 部署
# openclaw-node-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: openclaw-node
spec:
replicas: 3
selector:
matchLabels:
app: openclaw-node
template:
metadata:
labels:
app: openclaw-node
spec:
containers:
- name: openclaw
image: openclaw/node:latest
env:
- name: GATEWAY_URL
value: "wss://gateway.example.com"
resources:
requests:
memory: "512Mi"
cpu: "250m"
limits:
memory: "2Gi"
cpu: "1000m"
⚠️ 安全提醒:始终使用强Token、启用TLS加密、限制节点能力范围、定期轮换凭证。
六、监控与维护
6.1 健康检查
# 检查节点健康状态
nodes({
action: "device_health",
deviceId: "tokyo-worker-1"
})
6.2 自动故障转移
配置任务在节点故障时自动转移:
sessions_spawn({
task: "重要数据处理任务",
runtime: "subagent",
node: "tokyo-worker-1",
fallbackNodes: ["singapore-worker-1", "us-west-1"]
})
七、常见问题
Q: 节点无法连接到 Gateway?
A: 检查防火墙设置、确认Gateway地址可访问、验证Token正确性。
Q: 如何限制节点只能执行特定工具?
A: 在 Gateway 的 allowedCapabilities 中配置允许的工具列表。
Q: 节点频繁掉线?
A: 检查网络稳定性、调整心跳间隔、查看节点资源使用情况。
🌍 结语:当你的Agent可以在东京搜索、在新加坡处理数据、在硅谷写代码——这才是真正的"AI无国界"。部署你的节点网络,让世界成为你的计算资源。