title: “从零部署 agentmemory:含 5 个踩坑经验”
author: 攀岩者
date: 2026-05-24
series: AI 记忆革命
part: 2
template: standard
tags: AI学习, agentmemory, 部署教程, 踩坑指南
上一篇我们对比了 7 种 AI 记忆方案,今天手把手教你部署 agentmemory。
10 分钟搞定,含 5 个踩坑经验。
一、为什么选 agentmemory?
上篇说了,agentmemory 有三个核心优势:
- MCP 原生 — 跟 Hermes、OpenClaw 天然集成
- 一键部署 —
agentmemory up就完事 - REST API — 非 MCP 客户端也能用
二、环境准备
系统要求
- Python 3.11+
- pip 或 uv
- 512MB+ 内存
安装
`bash
python -m venv ~/.hermes/tools/agentmemory
source ~/.hermes/tools/agentmemory/bin/activate
# 安装 agentmemory
pip install iii[agentmemory]
`
踩坑 1: 必须用 iii[agentmemory],不是 agentmemory。直接 pip install agentmemory 会装错包。
三、启动服务
`bash
# 激活虚拟环境
source ~/.hermes/tools/agentmemory/bin/activate
# 启动 agentmemory
agentmemory up –port 3111
`
踩坑 2: 默认端口是 3111,不是 8080。如果你的 3111 被占用,用 --port 指定其他端口。
启动后会看到:
`
INFO: Started server process [12345]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://0.0.0.0:3111
`
四、验证安装
`bash
# 测试 API
curl http://localhost:3111/health
`
返回 {"status": "healthy"} 就成功了。
踩坑 3: 如果返回 Connection refused,检查端口是否被占用:
`bash
lsof -i :3111
`
五、配置 MCP
配置文件位置
`bash
~/.hermes/config.yaml
`
添加 MCP 配置
`yaml
mcp:
servers:
agentmemory:
url: http://localhost:3111
transport: http
`
踩坑 4: transport 必须是 http,不是 stdio。agentmemory 是 HTTP 服务,不是本地进程。
六、连接 OpenClaw
在 OpenClaw 设置中添加 MCP:
`json
{
“mcpServers”: {
“agentmemory”: {
“url”: “http://localhost:3111”,
“transport”: “http”
}
}
}
`
踩坑 5: OpenClaw 和 Hermes 共享同一个 agentmemory 实例,记忆数据自动同步。
七、测试记忆功能
添加记忆
`bash
curl -X POST http://localhost:3111/memories
-H “Content-Type: application/json”
-d ‘{“content”: “用户喜欢简洁的回答”, “type”: “preference”}’
`
搜索记忆
`bash
curl http://localhost:3111/memories/search?q=简洁
`
八、systemd 自启动
`bash
# 创建服务文件
sudo tee /etc/systemd/system/agentmemory.service > /dev/null <<EOF
[Unit]
Description=Agent Memory Service
After=network.target
[Service]
Type=simple
User=climbing
ExecStart=/home/climbing/.hermes/tools/agentmemory/bin/agentmemory up –port 3111
Restart=always
[Install]
WantedBy=multi-user.target
EOF
# 启用并启动
sudo systemctl enable agentmemory
sudo systemctl start agentmemory
`
九、踩坑总结
| 编号 | 问题 | 解决方案 |
|---|
|:—-:|——|———-|
| 1 | 安装命令错误 | 用 iii[agentmemory] 不是 agentmemory |
|---|---|---|
| 2 | 端口不对 | 默认 3111,用 --port 修改 |
| 3 | 连接被拒 | 检查端口占用 lsof -i :3111 |
| 4 | MCP 配置错误 | transport 用 http 不是 stdio |
| 5 | 数据不同步 | 多客户端共享同一实例即可 |
十、下一步
agentmemory 部署好了,怎么跟 Hermes、OpenClaw 打通?
明天第三篇,手把手教你实现跨平台记忆共享。
*作者:攀岩者,技术总监,19年 IT 全栈实战。精通网络、安全、云计算、容器、数据库、超算,持证 PMP、ITIL、CKA、网络工程师、信息安全等级保护、AIX 天工计划。主导过多个千万级政务与智慧城市项目,从售前到交付全流程打通。热衷开源,日拱一卒,每天分享 AI 学习笔记,陪你从零基础到 AI 达人。*
*本文同步发布于攀岩者的博客和微信公众号”攀岩者”。*
发表回复