# Clore 上的 OpenClaw

## 概览

[OpenClaw](https://openclaw.ai) 是一个开源的 AI 代理平台，可连接到 Claude、GPT、Gemini 与本地模型——在 Telegram、Discord、WhatsApp 等平台上担任个人 AI 助手。在 Clore.ai 服务器上运行它为您提供：

* **全天候运行** — 无笔记本休眠，无断线
* **GPU 加速** — 本地 LLM 推理（Ollama、vLLM）、Whisper 语音转录、TTS、图像生成
* **低成本** — 按需租用所需硬件，按小时付费
* **完全控制** — root 访问、支持 Docker、任意软件栈

### 为什么选择 Clore + OpenClaw？

| 特性              | 笔记本电脑 | 传统 VPS  | Clore.ai 服务器   |
| --------------- | ----- | ------- | -------------- |
| 始终在线            | ❌     | ✅       | ✅              |
| 可用 GPU          | 有限    | ❌ 或 $$$ | ✅ 从 $0.10/小时 起 |
| 本地 LLM 推理       | 慢     | 仅 CPU   | 全 GPU 速度       |
| 语音（Whisper/TTS） | ✅     | 慢（CPU）  | ✅ 实时           |
| Root + Docker   | ✅     | ✅       | ✅              |
| 按小时计费           | 不适用   | 按月      | ✅ 按小时          |

### 推荐硬件

| 使用场景                                    | GPU             | 显存（VRAM） | 内存（RAM） | 预计成本          |
| --------------------------------------- | --------------- | -------- | ------- | ------------- |
| **基础助理** （仅 API，不使用本地模型）                | 任意 / 仅 CPU      | —        | 8 GB+   | $0.05–0.15/小时 |
| **本地 7–8B LLM** （Ollama + Llama 3.1 8B） | RTX 3060/3070   | 12 GB    | 16 GB+  | $0.10–0.25/小时 |
| **本地 70B LLM** （vLLM + Llama 3.1 70B）   | RTX 4090 / A100 | 24–80 GB | 64 GB+  | $0.30–1.00/小时 |
| **完整栈** （LLM + Whisper + TTS + 图像生成）    | RTX 4090        | 24 GB    | 32 GB+  | $0.25–0.50/小时 |

> **提示：** 如果您只需要将 OpenClaw 作为基于云的助手并使用 API 模型（Claude、GPT），根本不需要 GPU——廉价的 CPU 服务器就足够。只有在需要本地推理时再添加 GPU。

***

## 步骤 1：在 Clore.ai 上租用服务器

### 1.1 浏览市场

前往 [clore.ai/marketplace](https://clore.ai/marketplace) 并按您的需求筛选：

* **对于基础助理**：按价格排序，选择任何廉价的 Ubuntu 服务器
* **对于本地 LLM**：按 GPU 筛选（例如 RTX 4090），确保显存 ≥24 GB
* **操作系统**：选择 **Ubuntu 22.04** 或 **Ubuntu 24.04** （兼容性最佳）

### 1.2 创建订单

1. 选择服务器 → **租用**
2. 选择 **按需** （按小时）或 **竞价实例（Spot）** （更便宜但可能被抢占）
3. 选择 Docker 镜像： **`ubuntu:22.04`** 或 **`nvidia/cuda:12.4.0-runtime-ubuntu22.04`** （如果您需要 GPU）
4. 设置 SSH 公钥（或使用密码——建议使用 SSH 密钥）
5. 确认订单

### 1.3 通过 SSH 连接

服务器运行后，可在您的 [订单](https://clore.ai/my-orders) 页面中找到 SSH 连接信息：

```bash
ssh root@<server-ip> -p <port>
```

> **注意：** Clore 服务器使用 Docker 容器，因此您在容器内也可以获得 root 访问。SSH 端口可能不是标准端口（例如 50022）——请查看您的订单详情。

***

## 步骤 2：安装 OpenClaw

### 2.1 安装 Node.js 22+

```bash
# 更新系统软件包
apt update && apt upgrade -y

# 通过 NodeSource 安装 Node.js 22
curl -fsSL https://deb.nodesource.com/setup_22.x | bash -
apt install -y nodejs

# 验证
node --version   # 应显示 v22.x.x
npm --version
```

### 2.2 安装 OpenClaw

**选项 A：安装脚本（推荐）**

```bash
curl -fsSL https://openclaw.ai/install.sh | bash
```

该脚本会安装 CLI、运行引导并启动网关。

**选项 B：手动 npm 安装**

```bash
npm install -g openclaw@latest
openclaw onboard --install-daemon
```

### 2.3 运行引导向导

如果您使用了安装脚本，引导会自动运行。否则：

```bash
openclaw onboard --install-daemon
```

向导会要求您：

1. **设置认证** — 粘贴您的 Anthropic API 密钥或通过 OAuth 连接
2. **选择一个频道** — Telegram 机器人令牌、Discord、WhatsApp 等
3. **配置网关** — 端口、绑定、安全性

> **对于 Telegram：** 通过 [@BotFather](https://t.me/BotFather)创建一个机器人，复制令牌并在引导时粘贴。

***

## 步骤 3：配置始终在线运行

### 3.1 将网关作为服务启动

```bash
# 检查网关是否正在运行
openclaw gateway status

# 启动它（如果尚未运行）
openclaw gateway start

# 验证其健康状态
openclaw status
```

### 3.2 使用 systemd 保持运行（推荐）

如果 OpenClaw 未自动安装 systemd 服务：

```bash
# 创建 systemd 服务文件
cat > /etc/systemd/system/openclaw.service << 'EOF'
[Unit]
Description=OpenClaw Gateway
After=network.target

[Service]
Type=simple
ExecStart=/usr/bin/openclaw gateway --port 18789
Restart=always
RestartSec=10
Environment=NODE_ENV=production
WorkingDirectory=/root

[Install]
WantedBy=multi-user.target
EOF

# 启用并启动
systemctl daemon-reload
systemctl enable openclaw
systemctl start openclaw

# 检查状态
systemctl status openclaw
```

### 3.3 备选：screen/tmux（快速且简单）

```bash
# 安装 screen
apt install -y screen

# 在一个分离的 screen 会话中启动 OpenClaw
screen -dmS openclaw openclaw gateway --port 18789

# 稍后重新附加
screen -r openclaw
```

***

## 步骤 4：GPU 设置（可选——用于本地模型）

如果您仅使用基于 API 的模型（Claude、GPT 等），可跳过本节。

### 4.1 验证 GPU 访问

```bash
# 检查 NVIDIA 驱动是否可用
nvidia-smi
```

如果 `nvidia-smi` 可用，则您的 GPU 已准备好。大多数 Clore CUDA 镜像已预配置。

### 4.2 安装 Ollama（本地 LLM 推理）

```bash
curl -fsSL https://ollama.com/install.sh | sh

# 启动 Ollama
ollama serve &

# 拉取一个模型
ollama pull llama3.1:8b        # 8B — 可在 12GB 显存中运行
# ollama pull llama3.1:70b     # 70B — 需要 48GB+ 显存
# ollama pull qwen2.5:32b      # 32B — 需要 24GB 显存
```

将 OpenClaw 配置为使用 Ollama 作为提供者——详情见 [Ollama 指南](/guides/guides_v2-zh/yu-yan-mo-xing/ollama.md) 。

### 4.3 安装 Whisper（语音转录）

用于 GPU 加速的语音到文本：

```bash
pip install faster-whisper

# 或使用 WhisperX 以获得更好的准确性
pip install whisperx
```

请参阅 [WhisperX 指南](/guides/guides_v2-zh/yin-pin-yu-yu-yin/whisperx.md) 以获取完整设置。

***

## 步骤 5：安全与远程访问

### 5.1 保护网关

默认情况下，网关绑定到回环地址（127.0.0.1）。如需远程访问：

**选项 A：SSH 隧道（最安全）**

从您的笔记本：

```bash
ssh -N -L 18789:127.0.0.1:18789 root@<server-ip> -p <port>
```

然后在浏览器中打开 `http://127.0.0.1:18789/` 。

**选项 B：令牌保护的直接访问**

编辑 `~/.openclaw/config.json5`:

```json5
{
  gateway: {
    bind: "lan",       // 监听所有接口
    port: 18789,
    auth: {
      token: "your-secret-token-here"  // 远程访问必需！
    }
  }
}
```

> ⚠️ **如果绑定到** lan `，请务必设置令牌`。否则任何人都可以访问您的网关。

### 5.2 防火墙设置

```bash
# 安装 UFW
apt install -y ufw

# 允许 SSH（使用您的 Clore SSH 端口）
ufw allow <ssh-port>/tcp

# 允许 OpenClaw 网关（仅当使用直接访问时）
ufw allow 18789/tcp

# 启用防火墙
ufw enable
```

***

## 步骤 6：持久化与备份

### 6.1 重要目录

| 路径                       | 内容                   |
| ------------------------ | -------------------- |
| `~/.openclaw/`           | 配置、认证、状态、代理配置文件      |
| `~/.openclaw/workspace/` | MEMORY.md、每日笔记、技能、工具 |
| `~/.openclaw/agents/`    | 多代理配置（如果使用团队）        |

### 6.2 备份脚本

创建一个简单的备份以保护您的配置：

```bash
cat > /root/backup-openclaw.sh << 'EOF'
#!/bin/bash
BACKUP_DIR="/root/openclaw-backups"
mkdir -p "$BACKUP_DIR"
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
tar czf "$BACKUP_DIR/openclaw-$TIMESTAMP.tar.gz" \
  ~/.openclaw/config.json5 \
  ~/.openclaw/workspace/ \
  ~/.openclaw/agents/ \
  ~/.openclaw/identity/
echo "备份已保存： $BACKUP_DIR/openclaw-$TIMESTAMP.tar.gz"
EOF
chmod +x /root/backup-openclaw.sh

# 通过 cron 每日运行
(crontab -l 2>/dev/null; echo "0 4 * * * /root/backup-openclaw.sh") | crontab -
```

### 6.3 在服务器之间迁移

如果您需要切换到不同的 Clore 服务器：

```bash
# 在旧服务器上 — 导出
tar czf /tmp/openclaw-migration.tar.gz ~/.openclaw/

# 传输到新服务器
scp -P <port> /tmp/openclaw-migration.tar.gz root@<new-server-ip>:/tmp/

# 在新服务器上 — 导入
tar xzf /tmp/openclaw-migration.tar.gz -C /
openclaw gateway start
```

***

## 示例配置

### 基础 Telegram 机器人（无 GPU）

最便宜的配置——仅基于 API 的助理：

```
服务器：任意 Ubuntu，无需 GPU
费用：~$0.05–0.15/小时（$3–10/月）
配置：Anthropic API 密钥 + Telegram 机器人令牌
```

### AI 工作站（GPU）

具备本地模型的全功能配置：

```
服务器：RTX 4090，24GB 显存，32GB 内存
费用：~$0.25–0.50/小时
堆栈：OpenClaw + Ollama（Llama 3.1 70B）+ WhisperX + Coqui TTS
```

### 多代理团队

运行一组专业化的 AI 代理：

```
服务器：RTX 4090 或 双 GPU
费用：~$0.30–0.60/小时
堆栈：OpenClaw 多代理（5+ 代理）+ Ollama + 共享技能
```

***

## 故障排查

### 网关无法启动

```bash
# 查看日志
openclaw gateway status
journalctl -u openclaw -n 50

# 常见修复：端口已被占用
lsof -i :18789
kill <pid>
openclaw gateway start
```

### 未检测到 GPU

```bash
# 检查 NVIDIA 驱动
nvidia-smi

# 如果未找到，您可能需要使用 CUDA Docker 镜像
# 重新创建订单并使用 nvidia/cuda:12.4.0-runtime-ubuntu22.04
```

### 服务器重启时连接断开

Clore 的竞价实例（spot）可能会被回收。为实现持久运行：

* 使用 **按需** 定价（不要使用竞价实例）
* 设置 systemd 服务（自动重启）
* 保持备份（见上面的备份脚本）
* 为关键工作负载考虑专用/保留服务器

### Node.js 版本问题

```bash
# 检查版本
node --version

# 如果低于 v22，请重新安装
curl -fsSL https://deb.nodesource.com/setup_22.x | bash -
apt install -y nodejs
```

***

## 提示与最佳实践

1. **从便宜的开始** — 先使用基础 CPU 服务器。需要本地推理时再添加 GPU。
2. **生产环境使用按需（on-demand）** — 竞价实例更便宜但可能被中断。按需保证正常运行时间。
3. **定期备份** — 您的 `~/.openclaw/workspace/` 包含所有记忆和配置。
4. **监控成本** — 定期检查您的 Clore 仪表板。如有可用，请设置支出提醒。
5. **使用控制界面** — 通过 SSH 隧道访问 `http://127.0.0.1:18789/` 以进行基于网页的管理。
6. **与 API 模型结合使用** — 即使使用 GPU 服务器，也可通过 API 使用 Claude/GPT 作为主代理，并将本地模型用于特定任务（嵌入、转录）。

***

## 延伸阅读

* [OpenClaw 入门](https://docs.openclaw.ai/start/getting-started)
* [OpenClaw VPS 托管指南](https://docs.openclaw.ai/install/vps)
* [OpenClaw Docker 设置](https://docs.openclaw.ai/install/docker)
* [Clore 上的 Ollama](/guides/guides_v2-zh/yu-yan-mo-xing/ollama.md)
* [Clore 上的 vLLM](/guides/guides_v2-zh/yu-yan-mo-xing/vllm.md)
* [GPU 比较与定价](/guides/guides_v2-zh/ru-men/gpu-comparison.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.clore.ai/guides/guides_v2-zh/qi-ta-gong-zuo-fu-zai/openclaw-on-clore.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
