> For the complete documentation index, see [llms.txt](https://docs.clore.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.clore.ai/guides/guides_v2-zh/qi-ta-gong-zuo-fu-zai/openclaw-on-clore.md).

# Clore 上的 OpenClaw

在 Clore.ai GPU 服务器上部署 OpenClaw AI 助手——始终在线、GPU 加速，支持 Telegram/Discord 集成、本地 LLM 推理和语音功能。

## 概览

[OpenClaw](https://openclaw.ai) 是一个开源 AI 代理平台，可连接 Claude、GPT、Gemini 和本地模型——作为一个个人 AI 助手，覆盖 Telegram、Discord、WhatsApp 等更多平台。将其运行在 Clore.ai 服务器上可带来：

* **7×24 小时在线** —— 不会因笔记本休眠而中断，也不会断线
* **GPU 加速** —— 本地 LLM 推理（Ollama、vLLM）、Whisper STT、TTS、图像生成
* **低成本** —— 精确租用你需要的硬件，按小时付费
* **完全控制** —— root 访问、Docker 支持、任意软件栈

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

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

### 推荐硬件

| 使用场景                                    | GPU             | 显存       | 内存     | 估算成本                              |
| --------------------------------------- | --------------- | -------- | ------ | --------------------------------- |
| **基础助手** （仅 API，无本地模型）                  | 任意 / 仅 CPU      | —        | 8 GB+  | $0.05–0.15/小时                     |
| **本地 7–8B LLM** （Ollama + Llama 3.1 8B） | RTX 3060/3070   | 12 GB    | 16 GB+ | $0.03–0.07/小时                     |
| **本地 70B LLM** （vLLM + Llama 3.1 70B）   | RTX 4090 / A100 | 24–80 GB | 64 GB+ | [裸机](https://clore.ai/bare-metal) |
| **完整技术栈** （LLM + Whisper + TTS + 图像生成）  | RTX 4090        | 24 GB    | 32 GB+ | $0.14–0.42/小时                     |

> **提示：** 如果你只需要将 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. 选择 **按需** （按小时）或 **竞价** （更便宜，但可能会被更高出价抢走）
3. 选择 Docker 镜像： **`ubuntu:22.04`** 或 **`nvidia/cuda:12.8.1-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 网关
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.8.1-runtime-ubuntu22.04 重新创建订单
```

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

Clore 的抢占式实例可能会被回收。要实现持久运行：

* 使用 **按需** 计价（非抢占式）
* 设置 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. **生产环境使用按需实例** —— 抢占式更便宜，但可能会被中断。按需实例可保证在线时间。
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-zhi-nan/gpu-comparison.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
