html 如何在 Oracle VM 免费部署 Hermes Agent · Nous Research
← 返回主页
🌐 繁體中文 English 简体中文 العربية
Nous Research · MIT 开源 · 2026

如何在 Oracle VM 免费部署 Hermes Agent

OCI Free Tier ARM 实战 · Always Free 2 vCPU / 12GB RAM 永久免费(2026-06-15 起)· PAYG 4 OCPU / 24GB 不受减半影响(见 §15)· systemd 24/7 运行
零成本的云端 AI Agent,所有踩坑已经替你踩平

⚡ 本指南持续更新(最新实测 2026-09)。所有资源必须维持在「Always Free」额度内,超出会收费;PAYG 账户不受 2026-06-15 减半影响(见 §15)。
目录
0%
Nous Research · MIT 开源

Oracle 免费 VM 部署
Hermes Agent

Always Free ARM · 零成本 24/7 AI Agent

2vCPU
12GB 内存
200GB 磁盘
0每月($)
24/7运行
📝
注册 OCI
🖥
创建 ARM VM
️
SSH 初始化
🔑
安装 Hermes
📦
接入模型 API
🧠
systemd 上线
✅
部署完成
24/7 免费运行 · 断线自动重启
HERMES AGENT · ORACLE FREE TIER
起步 · 0–4 0 架构 1 注册帐号 2 建立 VM 3 SSH 初始化 4 安装 Hermes
部署 · 5–10 5 初始化设定 6 模型 API Key 7 systemd Gateway 8 Telegram Bot 9 中文回覆 10 防火墙
进阶与运维 · 11–16 11 命令速查 12 踩坑合集 13 WebUI 14 备份维护 15 免费额度减半 16 免费额度监控 附录
0. 架构

0为什么要这样部署(架构概览)

Hermes Agent 系 Nous Research 开发的开源 AI Agent 框架(MIT 协议)——在终端里读文件、写代码、执行命令、操控浏览器,不绑定任何模型厂商,还内置 Telegram Gateway。放在 Oracle 永久免费 VM 上,就变成 24/7 不断线的云端 AI Agent。

Telegram 讯息→ Hermes Gateway→ DeepSeek API→ AI 回覆→ Telegram 聊天

systemd 服务管理:开机自启、崩溃自动重启、断开 SSH 都照常运行。

💰

永久免费

ARM 2 vCPU + 12GB RAM + 200GB 磁碟(Always Free,2026-06-15 起);PAYG 可续用 4 OCPU / 24GB(见 §15)

🔄

模型自由

DeepSeek / OpenAI / Anthropic / Google 任拣,换供应商改 config 就得

💬

Telegram 原生

内建 Gateway,一条 systemd 服务即 24/7 自动回覆

🖥️

零运维焦虑

崩溃自动重启 + journald 日志 + 远端备份,睡觉都不用管

1. 注册

1注册 Oracle Cloud Free Tier 帐号

前往注册页面

https://signup.cloud.oracle.com/

填姓名、电邮、国家/地区。

拣 Home Region关键

务必选择支援 Ampere ARM 实例的区域(Home Region 之后不可更改):
Osaka / Tokyo / Paris / Frankfurt / Ashburn / Phoenix 都支援。

Home Region 选错了就没有 ARM 实例 — 这决定了你之后有没有 2 vCPU 免费机可用。

信用卡验证

要提供有效信用卡或扣帐卡。 Oracle 会暂时扣约$1 美元验证,几日后退还。不接受虚拟卡或预付卡。

等启用

通常几分钟至几小时。收到启用邮件即可登入cloud.oracle.com。

⚠️ 免费不等于无限:资源超出「Always Free」限制会产生费用。建议升级做 Pay-As-You-Go(仍 $0,但容量不足时可以解决,也是免费 ARM 抢不到容量的解法)。
2. 建立 VM

2建立 OCI 运算实例(VM)

开建立页面

OCI Console →Compute → Instances → Create Instance。区域应显示「Always Free-eligible」标签。

拣映像档

Change image → 拣Ubuntu 22.04 LTS 或 24.04 LTS。

拣实例规格ARM Ampere 推荐

方案规格建议
ARM Ampere A1VM.Standard.A1.Flex— 2 OCPU + 12GB RAM(2026-06-15 前系 4/24)✅ 主力(免费额度内最大配置)
x86 MicroVM.Standard.E2.1.Micro— 1/8 OCPU + 1GB❌ 太细,仅适合测试

网络 + SSH 金钥

用预设 VCN/子网,勾选「Assign a public IPv4 address」。 SSH 拣「Paste public keys」,贴上你的公钥(本地未有就先产生):

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

加大开机磁碟到 200GB免费上限

Show advanced options → Boot volume → 自订大小 → 输入200(GB)。默认只有 50GB,以后再扩充没那么方便。

Create 并记低 Public IP

等状态变「Running」,记低 Public IP(例如130.123.45.67)。

3. SSH

3连线 VM 与系统初始化

SSH 连线

ssh -i ~/.ssh/id_rsa ubuntu@<你的Public IP>

Ubuntu 预设用户系ubuntu;Oracle Linux 先系opc。

更新系统

sudo apt update && sudo apt upgrade -y

装基本工具 + 设时区

sudo apt install -y curl git wget nano vim ufw build-essential sudo timedatectl set-timezone Asia/Hong_Kong

开 UFW 防火墙(第一层)

sudo ufw default deny incoming sudo ufw default allow outgoing sudo ufw allow ssh sudo ufw allow 80/tcp sudo ufw allow 443/tcp sudo ufw enable

⚠️ 记住:Oracle 有两层防火墙— VM 入面的 UFW/iptables 之外,仲有 OCI VCN 的 Security List(第 10 节会讲)。两层都要开先通。

4. 安装

4安装 Hermes Agent

一键安装

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

自动完成:安装 uv → 建 Python 3.11 venv → 装 100+ 依赖 → 装 Node.js → 装 cua-driver。

重新载入 + 验证

source ~/.bashrc hermes --version

出到版本号(例如hermes 0.14.0)即成功。安装路径在~/.local/bin/hermes,设置在~/.hermes/。

⚠️ ARM 实测坑:HTTP/2 下载失败。安装脚本在下载 Node.js 时可能报curl: (92) HTTP/2 stream error。解法:Ctrl+C终止 → 手动用 HTTP/1.1 下载 ARM 版 Node.js:
curl --http1.1 -L "https://nodejs.org/dist/v22.11.0/node-v22.11.0-linux-arm64.tar.gz" -o /tmp/node.tar.gz mkdir -p ~/.hermes/node tar -xzf /tmp/node.tar.gz -C ~/.hermes/node --strip-components=1 rm /tmp/node.tar.gz
再重新执行安装脚本,会跳过已下载的 Node.js。
5. setup

5初始化设定(setup 向导)

启动向导

hermes setup

选项一览

  • 设定模式:Quick setup(快速)或 Custom setup(详细)
  • 终端后端:local backend
  • 讯息平台:拣「Skip — set up later」,Telegram 之后单独设(第 7-8 节)

完成

设定写入~/.hermes/config.yaml,密钥写入~/.hermes/.env。

6. API Key

6设定模型供应商与 API Key

Hermes 支援任意供应商。以下用 DeepSeek 做例(性价比高、无需海外支付)。

获取 DeepSeek API Key

platform.deepseek.com→ 注册/登入 → API Keys → 建立 Key(sk-开头)。新用户有免费额度。

确认 config.yaml

nano ~/.hermes/config.yaml
provider: deepseek model: deepseek-v4-pro base_url: https://api.deepseek.com/v1

写入 .env

DEEPSEEK_API_KEY=sk-你的deepseek密钥

验证连线

hermes chat

输入「你好」收到回覆即成功,Ctrl+C退出。

⚠️ 踩坑:DeepSeek Key 有两种!用过 Claude Code + DeepSeek 的人可能拿错 — 一个是 Claude Code 用的ANTHROPIC_AUTH_TOKEN,一个是 DeepSeek 平台原生 Key,两者格式相同但值不同。用平台原始 Key;报 401 就是 Key 错。快速测试:
curl https://api.deepseek.com/v1/chat/completions \ -H "Authorization: Bearer sk-你的key" \ -H "Content-Type: application/json" \ -d '{"model":"deepseek-v4-pro","messages":[{"role":"user","content":"hi"}]}'
200 = 有效,401 = 无效。
7. Gateway systemd

7安装 Hermes Gateway(systemd 服务)

在 Linux 服务器上,Gateway 必须用 systemd 才能做到:开机自启、崩溃自动重启、24/7 不断线、断开 SSH 照样运行。

安装 Gateway

hermes gateway install

手动建立 systemd 服务档核心步骤

⚠️最容易踩的坑:systemd 不会读 .env 文件!环境变数必须直接写入服务档,否则 Bot 会话「No messaging platforms enabled」。

sudo nano /etc/systemd/system/hermes-gateway.service
[Unit] Description=Hermes Gateway Service After=network.target [Service] Type=simple User=ubuntu WorkingDirectory=/home/ubuntu ExecStart=/home/ubuntu/.local/bin/hermes gateway Restart=always RestartSec=10 Environment=PATH=/home/ubuntu/.local/bin:/usr/local/bin:/usr/bin:/bin # 关键:systemd 不读 .env,环境变量必须直接写在这里! Environment=DEEPSEEK_API_KEY=sk-你的deepseek密钥 Environment=TELEGRAM_BOT_TOKEN=你的Bot Token Environment=TELEGRAM_ALLOWED_USERS=你的Telegram数字ID Environment=TELEGRAM_HOME_CHANNEL=你的Telegram数字ID Environment=GATEWAY_ALLOW_ALL_USERS=true [Install] WantedBy=multi-user.target

修改重点:User/WorkingDirectory/ExecStart按实际路径改;五个Environment=全部要填真值。

启动 + 开机自启

sudo systemctl daemon-reload sudo systemctl enable hermes-gateway sudo systemctl start hermes-gateway

验证 + 看日志

sudo systemctl status hermes-gateway sudo journalctl -u hermes-gateway -f

状态显示active (running),日志见到✓ telegram connected即成功。

设日志轮替(防磁碟爆)

sudo nano /etc/systemd/journald.conf
SystemMaxUse=200M SystemKeepFree=500M RuntimeMaxUse=100M
sudo systemctl restart systemd-journald
实测教训(我们的机器):改服务档可以在本地写好再上传 —sudo cp入/etc/systemd/system/再daemon-reload即可。另外Bot 上 systemd 之前一定要 pkill 旧的 polling 进程,否则 Telegram 会报 409 Conflict(两个 getUpdates 同时争同一个 Bot)。最后hermes git pull --rebase更新完记得重启服务。
8. Telegram

8接入 Telegram Bot

用 @BotFather 建 Bot

Telegram 搜寻@BotFather→/newbot→ 设名称/用户名 → 获取Bot Token(格式123456:ABC-DEF1234ghiJKL)。妥善保存,不要泄露。

获取你的 Telegram 数字 ID

搜寻@userinfobot→/start→ 获取数字 ID(例如123456789)。

更新 systemd 服务档

sudo nano /etc/systemd/system/hermes-gateway.service
Environment=TELEGRAM_BOT_TOKEN=123456:ABC-DEF1234ghiJKL Environment=TELEGRAM_ALLOWED_USERS=123456789 Environment=TELEGRAM_HOME_CHANNEL=123456789 Environment=GATEWAY_ALLOW_ALL_USERS=true
sudo systemctl daemon-reload sudo systemctl restart hermes-gateway

验证

日志见到✓ telegram connected,然后在 Telegram 与你的 Bot 对话,有回复即成。

故障排查口诀:Bot 没反应 → ①sudo systemctl status hermes-gateway是不是 running → ② 日志journalctl -u hermes-gateway -f→ ③ 见到No messaging platforms enabled= Token 没读到 → ④ 检查服务档 Environment → ⑤daemon-reload+restart→ ⑥ 再验证。
9. SOUL.md

9设定中文回覆(SOUL.md)

编辑 SOUL.md

cp ~/.hermes/SOUL.md ~/.hermes/SOUL.md.backup nano ~/.hermes/SOUL.md

在顶部加入语言规则:

CRITICAL LANGUAGE RULE: You MUST reply in Chinese (繁体中文) at all times. The user speaks Chinese. Never use English unless the user explicitly asks.

(可选)注入项目知识

SOUL.md 可以写入身份、技能、项目结构、程式码规范、常用命令 — 成为 Hermes 的「长期记忆」,每次对话都引用。

重启生效

sudo systemctl restart hermes-gateway

改完 SOUL.md 必须重启 Gateway 先生效。

10. 防火墙

10防火墙与安全规则(两层都要开)

Oracle VM 有两层防火墙:OCI VCN 的 Security List(云端层)+ 实例内的 UFW(系统层)。两层都放行才会通。

▎10.1 OCI Security List(云端层)

开入站规则

OCI Console → Networking → Virtual Cloud Networks → 拣 VCN → Subnets → Security Lists → 预设安全清单 → Add Ingress Rules:

来源类型来源 CIDR连接埠用途
CIDR0.0.0.0/022SSH
CIDR0.0.0.0/080HTTP
CIDR0.0.0.0/0443HTTPS

若安装 WebUI 仲要开对应连接埠(如 8787)。

▎10.2 实例防火墙(系统层)

sudo ufw status verbose

应见到22 / 80 / 443 ALLOW IN。 Oracle Linux 用户如果 UFW 没反应,可能要直接改 iptables。

⚠️ 实测教训:OCI 的「NSG ≠ iptables」。如果在 Console 开了安全清单但仍然连不上,不要只在 VM 里查 iptables — 先确认 OCI 那一层(Security List / NSG)有没放行。两层是独立的,任何一层挡住都是失败。还有:443 很多时候已经被其他服务(例如 sing-box 代理)占用,开 port 前先ss -tlnp看下边个在度用紧。
11. 命令速查

11常用指令速查表

指令作用
hermes chat启动终端对话模式
hermes --tui启动 TUI 介面
hermes setup重新执行设定向导
hermes update更新 Hermes Agent(源码版用git pull --rebase)
hermes gateway install / status / restartGateway 安装 / 状态 / 重启
hermes cron list / status列出 / 查看排程任务
sudo systemctl status hermes-gateway查看服务状态
sudo systemctl enable hermes-gateway开机自动启动
sudo journalctl -u hermes-gateway -f实时看服务日志
tail -f ~/.hermes/logs/gateway.log实时看 Hermes 日志
df -h / free -h磁碟 / 记忆体使用
12. 踩坑

12踩坑合集(全部亲测)

Q:Bot 上 systemd 后报 409 Conflict?

原因:旧的 polling 进程还在和 Gateway 争同一个 Bot Token。
解决:起服务前先pkill -f "hermes"或直接pkill -f polling,再systemctl start hermes-gateway。

Q:Gateway 启动了但 Bot 完全没反应?

原因:9 成是 systemd 没读到环境变量。日志出现No messaging platforms enabled即是 Token 未载入。
解决:确认服务档的Environment=五个变数全部填了 →daemon-reload+restart→ 再看日志。

Q:DeepSeek API 报 401 Authentication Fails?

原因:用错 Key(Claude Code 那个)或者 Key 过期。
解决:用 curl 测 Key(见 §6)→ 去平台重建 → 更新服务档DEEPSEEK_API_KEY→daemon-reload+restart。

Q:SSH 连不上/超时?

检查顺序:① OCI Security List 有没有开 22 → ② Public IP 是否正确 → ③ 密钥权限chmod 400 ~/.ssh/id_rsa→ ④ 用户名(Ubuntu 用ubuntu)。

Q:记忆体不足(OOM)?

用 ARM 2 vCPU / 12GB 实例基本上不会遇到。 x86 micro 才需要加 Swap:
sudo fallocate -l 4G /swapfile && sudo chmod 600 /swapfile && sudo mkswap /swapfile && sudo swapon /swapfile
再加入/etc/fstab永久生效。

Q:Oracle 会不会回收我的机器?

Oracle 会回收长期低活动的免费实例。 Gateway 24/7 运行本身就系持续活动;想更稳阵可以加 keepalive:
crontab -e→ 加入*/30 * * * * echo "keepalive $(date)" >> ~/keepalive.log

Q:更新完要重启吗?

apt upgrade更新了 kernel 之后要sudo reboot才生效;hermes git pull --rebase更新源码之后要sudo systemctl restart hermes-gateway。

13. WebUI

13进阶:Hermes WebUI(可选)

想用浏览器界面和 Agent 互动、无需 SSH?装 WebUI 就得。

克隆 + 设密码

cd ~ git clone https://github.com/nesquena/hermes-webui.git hermes-webui cd hermes-webui echo "HERMES_WEBUI_PASSWORD=设置一个强密码" > .env

建 systemd 服务

sudo nano /etc/systemd/system/hermes-webui.service
[Unit] Description=Hermes WebUI After=network.target [Service] Type=simple User=ubuntu WorkingDirectory=/home/ubuntu/hermes-webui ExecStart=/home/ubuntu/hermes-webui/start.sh Restart=always RestartSec=5 [Install] WantedBy=multi-user.target

启动 + 访问

sudo systemctl daemon-reload sudo systemctl enable hermes-webui sudo systemctl start hermes-webui

浏览器开http://<Public IP>:8787,用 .env 密码登入。记住 OCI Security List 要放行 8787。

(可选)Nginx 反代 + HTTPS

sudo apt install nginx certbot python3-certbot-nginx -y sudo nano /etc/nginx/sites-available/hermes-webui
server { listen 80; server_name ai.yourdomain.com; client_max_body_size 500M; location / { proxy_pass http://127.0.0.1:8787; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } }
sudo ln -s /etc/nginx/sites-available/hermes-webui /etc/nginx/sites-enabled/ sudo nginx -t && sudo systemctl restart nginx sudo certbot --nginx -d ai.yourdomain.com
14. 备份

14备份与维护建议

▎14.1 定期备份(最重要的档案)

tar -czvf hermes-backup-$(date +%Y%m%d).tar.gz \ ~/.hermes/config.yaml ~/.hermes/.env ~/.hermes/SOUL.md \ ~/.hermes/logs/ /etc/systemd/system/hermes-gateway.service # 拉返落本地 scp ubuntu@<你的Public IP>:~/hermes-backup-*.tar.gz ./

config.yaml(设定)、.env(密钥)、SOUL.md(长期记忆)、systemd 服务档 — 这四样加起来就是整台机器的「灵魂」,没有它们等于从头再来。

▎14.2 维护节奏

频率做咩
每周sudo apt update && sudo apt upgrade -y+sudo apt autoremove -y
每月sudo journalctl --vacuum-time=30d;df -h/free -h检查
每 3-6 个月rotation API Key、检查 Drive/远端备份完整性
⚠️ 不要把 apt 升级当作「一定安全」:升级 docker-ce / containerd 会重启 Docker daemon,所有容器一起 bounce。实测(2026-09-16):daemon 重启时 Pi-hole 绑不到 host port,静静死掉 → 依赖它做 DNS 的代理全部 handshake 失败,客户端显示「port 没开」,其实 443/853 一直在监听。升级后必验三样:docker ps 容器齐不齐、systemctl status sing-box、真正连一次代理(见 §16 自动化写法)。

▎14.3 安全建议

附录

15 ⚠️ 2026-06-15:Oracle 免费额度悄悄减半

2026-06-15 Oracle 没有公告、没有邮件,悄悄改文档将 Always Free ARM 额度减半:4 OCPU / 24GB → 2 OCPU / 12GB(每月上限 3,000 OCPU-hrs + 18,000 GB-hrs → 1,500 + 9,000)。外送流量维持 10TB/月(未变)。

配置(长开一个月)消耗新额度 1,500 + 9,000
4 OCPU / 24GB(旧)2,920 OCPU-hrs + 17,520 GB-hrs❌ 超出一倍
2 OCPU / 12GB(新)1,460 OCPU-hrs + 8,760 GB-hrs✅ 刚好

▎15.1 纯免费 vs PAYG 命运不同

⚠️ 唯一风险(官方有提):实例正常停止 → 可以再启动;但若被终止(terminate),重建同配置要看大阪区当时 ARM 容量。保险已就绪:OCI boot volume backup + Drive 异地备份。

▎15.2 官方政策原文(关键段落)

来源:docs.oracle.com — Always Free Resources

"All tenancies get the first 1,500 OCPU hours and 9,000 GB hours per month for free for VM instances using the VM."
"you can create one or two OCI Ampere A1 Compute instances, 2 OCPUs total."

▎15.3 官方客服回覆原文(2026-08-03,PAYG 账户查询)

"Thank you for providing the details. Since your tenancy is a Pay As You Go (PAYG) account, you do not need to worry about the recent Always Free Ampere A1 resource limit update. Your existing 4 OCPU / 24 GB A1 instance does not need to be resized as a result of this policy change. You will not be billed for your existing 4 OCPU / 24 GB A1 instance solely because of the Always Free limit update. The reduction to 2 OCPUs / 12 GB RAM applies only to Always Free tenancies, not to PAYG accounts. There is no deadline requiring PAYG customers to resize existing A1 instances because of this change. If your instance is stopped, you can start it again normally. However, if it is terminated, the ability to recreate an instance with the same configuration depends on current capacity availability in your selected region. The reduction in the Always Free Ampere A1 allocation applies only to Always Free tenancies. PAYG and other paid tenancy types are not affected by this specific policy change. Based on the information available, your existing 4 OCPU / 24 GB A1 instance on your PAYG tenancy will continue to operate under the terms applicable to your paid account and will not incur charges solely because of this Always Free policy update."

▎15.4 社群共识(2026-07)

▎15.5 保险三宝(亲测)

  1. OCI Boot Volume Backup:Console → 计算 → 实例 → 引导卷 → 创建备份(云端整机还原,~10 分钟 Available)
  2. Drive 异地备份:配置 tar.gz(~/.hermes、nginx、systemd、crontab)每日自动 → Google Drive(见 §14)
  3. 不要乱停机:grandfather 期间一旦终止,可能永远开不回来

▎15.6 替代方案(万一 Oracle 完蛋)

需求方案成本
日本 IP + 最便宜保留 Oracle 2/12$0
日本 IP 付费Contabo 大阪 4vCPU/8GB | Vultr Tokyo 1-2GB~€7/月 | $5-6/月
不需要日本 IPRackNerd 1GB | GCP e2-micro~$1/月 | $0
科学上网用途VLESS/REALITY(任何 VPS 都行)+ CF Worker 后备$0 起

💡 GFW 提示:Oracle/Contabo 数据中心 IP 用久了容易被封,REALITY 可抵挡主动探测;CF Worker(edgetunnel)是免费后备线路。

16 免费额度监控 + 每日账单推送(OCI Usage API)

Oracle 不会主动通知你额度用了多少 —— 通常等到出费用才发现。这一节用 OCI 官方 Usage API 每天自动拉「用了多少 + 月底预测」,超过 90% 就报警,再由 Hermes 推到 Telegram。所有数字都是 API 实时取的,不是手工填的。

▎16.1 安装 OCI CLI + API Key

bash -c "$(curl -L https://raw.githubusercontent.com/oracle/oci-cli/master/scripts/install/install.sh)" ~/bin/oci setup config # 交互式:Tenancy OCID / User OCID / Region / 生成 keypair

然后到 Console 右上头像 → My profile → API keys → Add API key → 粘贴 ~/.oci/oci_api_key_public.pem 的内容。顺手记下 Tenancy OCID(就是下面 --tenant-id 要的值)。之后所有查询直接读 ~/.oci/config,不用再登录。

文档 vs 现实:这个 CLI 版本里 oci limits / oci iam limit* 不存在,免费额度不能靠 quota API 查 —— 要用下面的 Usage API 反推。

▎16.2 两条关键命令(实测,官网文档不全)

TENANCY=ocid1.tenancy.oc1..xxxx # 你的 Tenancy OCID S=$(date -d "$(date +%Y-%m-01)" +%Y-%m-%d) # 本月 1 号 E=$(date -d tomorrow +%Y-%m-%d) # ① 费用(本月 / 昨日) ~/bin/oci usage-api usage-summary request-summarized-usages \ --tenant-id $TENANCY \ --time-usage-started ${S}T00:00:00Z --time-usage-ended ${E}T00:00:00Z \ --granularity MONTHLY --query-type COST --output json # ② 免费额度用量(按 service + skuName 分组) ~/bin/oci usage-api usage-summary request-summarized-usages \ --tenant-id $TENANCY \ --time-usage-started ${S}T00:00:00Z --time-usage-ended ${E}T00:00:00Z \ --granularity MONTHLY --query-type USAGE \ --group-by '["service","skuName"]' --output json
API 返回(service · skuName)对应免费额度单位
Compute · Standard - A1ARM 运算OCPU·时
Compute · Standard - A1 - MemoryARM 内存GB·时
Block Storage · Block Volume - Free块存储总量GB
Virtual Cloud Network · Outbound Data Transfer*出站流量GB
⚠️ 三个实测坑:
  • 正确路径是 usage-api usage-summary request-summarized-usages。写成 usage-api request-summarized-usages 或 usage-api query ...(后者只管 saved query)一律 Error: No such command。
  • oci ... list 没结果时是 rc=0 + stdout 完全为空(不是 {"data": []})→ json.loads 直接报错。helper 要 if not out: return {"data": []}。
  • 关键字 Standard - A1 会连内存条目一起匹配 → OCPU·时 = qty("A1") − qty("A1 - Memory"),不减就会大一倍。

▎16.3 接上 Hermes:每天 08:00 自动推 Telegram

# 1) 报告脚本(打印的 stdout 就是 Telegram 消息内容) nano /home/ubuntu/oci-billing/oci_billing_report.py # 2) Hermes cron 只认 ~/.hermes/scripts/ 下的文件,所以要一个 thin wrapper echo '#!/bin/bash' > ~/.hermes/scripts/oci_billing_report.sh echo 'exec python3 /home/ubuntu/oci-billing/oci_billing_report.py' >> ~/.hermes/scripts/oci_billing_report.sh chmod +x ~/.hermes/scripts/oci_billing_report.sh # 3) 创建 no_agent job(零 token,script stdout 直接发送) hermes cron create "0 8 * * *" --name "OCI 账单日报" \ --script oci_billing_report.sh --no-agent --deliver origin # 4) 立刻试一次(不用等明早) hermes cron run <job_id>

--no-agent = 不调用 LLM,脚本打印什么就发什么(stdout 为空 = 静默不发,适合 watchdog);想改时间就改 cron 表达式,例如 "30 7 * * 1" = 每周一 07:30。系统 crontab 也能做同样的事,但 hermes cron 多了执行记录和失败通知。

▎16.4 实测输出(大阪 A1 · 4 OCPU / 24GB · PAYG)

-- 甲骨文 OCI 账单日报 -- 📅 2026-09-16 · 大阪 ap-osaka-1 -- 💰 费用 (HKD) -- 昨日: 0.00 本月: 0.00 -- 🎁 本月免费额度用量 -- ARM 计算: 1,484.0 / 3,000 OCPU·时 (49%) ARM 内存: 8,904.0 / 18,000 GB·时 (49%) 出站流量: 53.6 / 10,240 GB (1%) 块存: 85.7 / 200 GB (43%) -- 📈 月底预测 (至 9月30日) -- ARM 计算: ~2,782.5 / 3,000 OCPU·时 (93%) ARM 内存: ~16,695.0 / 18,000 GB·时 (93%) ⚠️ 接近上限: ARM 计算, ARM 内存 -- 🖥️ 实例 -- 运行中: 1 台 · instance-20260508-2242 · VM.Standard.A1.Flex 4.0 OCPU / 24.0 GB -- 💡 免费额度还能用 -- AMD 小实例: 还可开 2 台 (E2.1.Micro · 1/8 核 / 1GB) 自治数据库: 2 个未用 负载均衡: 1 个未用

▎16.5 免费上限写在哪里(设置一次)

上限是官方固定值(只做分母),写在脚本顶部常量即可;用量本身永远是 API 实时数字:

LIMITS = { "arm_ocpu": 3000.0, # OCPU·时/月(Always Free 账户请改 1500) "arm_mem": 18000.0, # GB·时/月(Always Free 账户请改 9000) "egress": 10240.0, # GB/月(10TB,两种账户一样) "block": 200.0, # GB 总量(两种账户一样) } WARN_PCT = 90.0 # 月底预测达 90% → 出警告

附附录:档案路径 + 资源限制 + 完成清单

▎A.1 档案路径总览

路径说明
~/.local/bin/hermesHermes 主程式
~/.hermes/config.yaml主设定档
~/.hermes/.env环境变数 / 密钥
~/.hermes/SOUL.md系统提示词(长期记忆)
~/.hermes/logs/gateway.logGateway 日志
/etc/systemd/system/hermes-gateway.serviceGateway systemd 服务档

▎A.2 OCI Always Free 资源上限

资源限制
ARM Ampere A1 实例2 OCPU + 12GB RAM(2026-06-15 起减半;旧账户可继续跑 4/24 直至实例终止)
x86 AMD 实例最多 2 个 E2.1.Micro(各 1/8 OCPU + 1GB)
开机磁碟总容量200GB(所有实例共享)
公有 IPv4最多 6 个
网路频宽每 vCPU 1 Gbps

▎A.3 部署完成清单

✅检查项
□VM 已建立(ARM 2 OCPU / 12GB)并 SSH 连到
□hermes --version有输出
□DeepSeek API Key 有效(curl 200)
□systemd 服务 active + enabled,日志见✓ telegram connected
□Telegram 实测有回覆
□SOUL.md 已设繁中回覆
□OCI Security List + UFW 两层防火墙已开
□备份策略已建立(tar.gz + 拉返本地)
相关连结

喜欢这份指南?请我喝杯咖啡 ☕

☕ 请我喝杯咖啡