Ubuntu同时部署OpenClaw和Hermes Agent

适用系统: Ubuntu 22.04 / 24.04
最后更新: 2026-05-28


一、概述

OpenClawHermes Agent 都是开源的个人 AI 助手框架,可以在你的服务器或个人电脑上运行,通过 Telegram、Discord、WhatsApp、QQ 等消息平台进行交互。两者可以同时部署在同一台 Ubuntu 机器上,互不冲突。

对比维度 OpenClaw 🦞 Hermes Agent
语言/运行时 TypeScript, Node.js 24 Python 3.11+
安装方式 npm install -g openclaw@latest curl ... | bash 一键脚本
配置目录 ~/.openclaw/ ~/.hermes/
配置文件 openclaw.json (JSON) config.yaml (YAML) + .env
网关守护 systemd user service systemd user service
官方文档 https://docs.openclaw.ai https://hermes-agent.nousresearch.com/docs/
GitHub https://github.com/openclaw/openclaw https://github.com/NousResearch/hermes-agent

二、环境准备

2.1 系统依赖

1
2
3
4
5
# 更新系统
sudo apt update && sudo apt upgrade -y

# 安装基础依赖
sudo apt install -y curl git build-essential python3 python3-pip python3-venv

2.2 安装 Node.js(OpenClaw 需要)

OpenClaw 推荐 Node 24 或 **Node 22.19+**。

1
2
3
4
5
6
7
# 方法一:使用 NodeSource 安装 Node.js 22 LTS
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt install -y nodejs

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

💡 如果需要 Node 24,可使用 nvm 管理多版本:

1
2
3
4
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
source ~/.bashrc
nvm install 24
nvm use 24

2.3 验证 Python(Hermes 需要)

1
2
python3 --version   # 应显示 3.11+
pip3 --version

三、安装 OpenClaw

3.1 全局安装

1
2
3
4
npm install -g openclaw@latest

# 验证安装
openclaw --version

3.2 初始化配置

运行引导向导,会一步步配置网关、工作区、消息渠道和技能:

1
openclaw onboard --install-daemon

--install-daemon 会自动安装 systemd 用户服务,让网关开机自启并在后台持续运行。

3.3 配置文件位置

1
2
3
4
5
6
7
8
~/.openclaw/
├── openclaw.json # 主配置(模型、渠道、行为等)
├── .env # 环境变量 / API密钥
└── workspace/ # 工作区
├── SOUL.md # 人格定义
├── MEMORY.md # 长期记忆
├── AGENTS.md # 项目级指令
└── skills/ # 自定义技能

3.4 网关管理

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 查看状态
openclaw gateway status

# 启动(守护模式)
openclaw gateway start

# 停止
openclaw gateway stop

# 查看日志
journalctl --user -u openclaw-gateway -f

# 前台调试模式
openclaw gateway --port 18789 --verbose

四、安装 Hermes Agent

4.1 一键安装

1
curl -fsSL https://raw.githubusercontent.com/NousResearch/hermes-agent/main/scripts/install.sh | bash

安装完成后,激活虚拟环境或重新加载 shell:

1
2
3
source ~/.bashrc
# 或
export PATH="$HOME/.hermes/hermes-agent/venv/bin:$PATH"

4.2 初始化配置

1
2
3
4
5
# 运行设置向导(检测到 ~/.openclaw 时还会提示是否迁移)
hermes setup

# 快速选择模型
hermes model

4.3 配置文件位置

1
2
3
4
5
6
7
8
9
10
~/.hermes/
├── config.yaml # 主配置
├── .env # API 密钥(独立文件,不提交到 git)
├── state.db # 会话存储(SQLite)
├── skills/ # 已安装技能
├── logs/ # 日志
│ ├── agent.log
│ ├── errors.log
│ └── gateway.log
└── hermes-agent/ # 源代码(git 安装方式)

4.4 网关管理

1
2
3
4
5
6
7
8
9
10
11
12
13
# 安装为系统服务
hermes gateway install

# 查看状态
hermes gateway status

# 启动 / 停止 / 重启
hermes gateway start
hermes gateway stop
hermes gateway restart

# 查看日志
journalctl --user -u hermes-gateway -f

4.5 常用命令速查

1
2
3
4
5
6
7
8
9
10
hermes                        # 交互式聊天
hermes chat -q "问题" # 单次查询
hermes model # 切换模型
hermes config edit # 编辑配置
hermes tools # 管理工具集
hermes skills list # 列出技能
hermes sessions list # 查看历史会话
hermes cron list # 定时任务
hermes doctor # 诊断检查
hermes update # 更新到最新版

五、从 OpenClaw 迁移到 Hermes

如果你已在用 OpenClaw,Hermes 提供了一键迁移:

5.1 预览(推荐先预览)

1
hermes claw migrate --dry-run

这会显示哪些内容可以迁移、哪些会跳过、哪些会冲突。

5.2 执行迁移

1
2
3
4
5
# 仅迁移用户数据(不含 API 密钥)
hermes claw migrate --preset user-data

# 完整迁移(含 API 密钥)
hermes claw migrate --preset full --migrate-secrets

5.3 迁移内容包括

内容 OpenClaw 来源 Hermes 目标
人格定义 workspace/SOUL.md ~/.hermes/SOUL.md
长期记忆 workspace/MEMORY.md ~/.hermes/memories/MEMORY.md
用户档案 workspace/USER.md ~/.hermes/memories/USER.md
自定义技能 workspace/skills/ ~/.hermes/skills/openclaw-imports/
模型/提供商 openclaw.json → models.providers config.yaml → custom_providers
消息平台令牌 openclaw.json → channels .env → 对应变量
命令审批 exec-approvals.json config.yaml → command_allowlist

5.4 迁移后清理

1
2
# 确认一切正常后,归档旧的 OpenClaw 目录
hermes claw cleanup

六、同时运行两个 Agent

两个 Agent 互不冲突,因为它们使用完全独立的数据目录和服务名:

6.1 服务隔离

1
2
3
4
5
# OpenClaw 网关服务
systemctl --user status openclaw-gateway

# Hermes 网关服务
systemctl --user status hermes-gateway

6.2 利用 Hermes 的 profiles 隔离

如果你想让 Hermes 有多个独立实例(例如一个用于工作,一个用于个人),可以用 profiles:

1
2
3
4
5
hermes profile create work
hermes profile create personal

# 以指定 profile 启动
hermes --profile work

6.3 频道分配策略

如果你在不同平台上使用不同 Agent,可以在各自的配置中指定不同的 token:

1
2
OpenClaw → Telegram Bot A, Discord Server A
Hermes → Telegram Bot B, Discord Server B, QQ

也可以让两者共用同一个平台的不同 Bot/账号。

6.4 资源占用参考

组件 内存占用(大致) 说明
OpenClaw Gateway ~200-400 MB Node.js 进程
Hermes Gateway ~100-300 MB Python 进程
模型调用 外部 API(无本地开销) 除非使用本地模型

💡 建议:至少 2GB 可用内存。如果使用本地模型(vLLM / llama.cpp),需要额外的 GPU 或内存。


七、systemd 开机自启

确保两个网关都在用户级 systemd 下运行:

1
2
3
4
5
6
7
8
9
10
# 启用 linger(防止 SSH 退出后用户服务被杀死)
sudo loginctl enable-linger $USER

# 检查两者都在运行
systemctl --user is-active openclaw-gateway
systemctl --user is-active hermes-gateway

# 配置开机自启
systemctl --user enable openclaw-gateway
systemctl --user enable hermes-gateway

八、常见问题

Q1: 两个 Agent 能否绑定同一个 Telegram Bot?

不能。Telegram Bot Token 只能被一个服务使用。需要创建两个不同的 Bot。

Q2: 端口冲突怎么办?

OpenClaw 默认使用 18789 端口,Hermes 默认使用随机端口(由 systemd socket activation 管理)。一般不会冲突。如需自定义:

1
2
3
4
5
# OpenClaw
openclaw gateway --port 18888

# Hermes
hermes config set gateway.port 18999

Q3: 如何查看日志排查问题?

1
2
3
4
5
6
# OpenClaw
journalctl --user -u openclaw-gateway -f --since "10 min ago"

# Hermes
journalctl --user -u hermes-gateway -f
cat ~/.hermes/logs/gateway.log | tail -100

Q4: 系统更新后网关挂了?

1
2
3
4
# 重新加载 systemd 并重启
systemctl --user daemon-reload
systemctl --user restart openclaw-gateway
systemctl --user restart hermes-gateway

Q5: WSL2 用户注意

1
2
3
4
5
6
# 需要在 /etc/wsl.conf 中启用 systemd
# 编辑 /etc/wsl.conf,添加:
[boot]
systemd=true

# 然后在 Windows 终端运行 wsl --shutdown 再重启

Q6: OpenClaw 迁移后技能不生效?

迁移后的技能在 ~/.hermes/skills/openclaw-imports/,启动新会话后才会加载。使用 /reset 或开启新对话即可。


九、端口与路径速查表

项目 路径/值
OpenClaw 配置 ~/.openclaw/openclaw.json
OpenClaw 工作区 ~/.openclaw/workspace/
OpenClaw 守护服务 systemctl --user ... openclaw-gateway
OpenClaw 默认端口 18789
Hermes 配置 ~/.hermes/config.yaml
Hermes 密钥 ~/.hermes/.env
Hermes 技能 ~/.hermes/skills/
Hermes 守护服务 systemctl --user ... hermes-gateway
Hermes 安装目录 ~/.hermes/hermes-agent/
Hermes 日志 ~/.hermes/logs/

十、总结

在 Ubuntu 上同时运行 OpenClaw 和 Hermes Agent 是完全可行的:

  1. ✅ 数据目录独立(~/.openclaw/ vs ~/.hermes/
  2. ✅ 服务名独立(两个 systemd user service)
  3. ✅ 运行时无冲突(Node.js vs Python)
  4. ✅ Hermes 提供一键迁移,可无缝过渡
  5. ✅ 可通过 profiles 进一步隔离不同的 Hermes 实例

两个 Agent 各有所长,可以同时运行、互补使用。迁移路径也很顺畅,随时可以逐步将 OpenClaw 的配置和记忆迁移到 Hermes。


📚 参考资料: