Files
nexus/openclaw/xingyao/ubuntu/ubuntu-openclaw-tech.md
2026-03-23 20:57:45 +08:00

147 lines
2.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Ubuntu OpenClaw 技术笔记
> 本文件记录 Ubuntu 服务器上 OpenClaw 的安装、配置和管理命令。
## 环境概述
- **系统**: Ubuntu 20.04 / 22.04
- **安装方式**: npm 用户级全局安装
- **CLI 路径**: `/home/shenwei/.npm-global/bin/openclaw`
- **配置目录**: `/home/shenwei/.openclaw`
- **systemd 服务**: `/home/shenwei/.config/systemd/user/openclaw-gateway.service`
---
## PATH 配置
```bash
# 临时生效
export PATH=$HOME/.npm-global/bin:$PATH
# 永久生效(添加到 ~/.bashrc
echo 'export PATH=$HOME/.npm-global/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
```
---
## 安装 OpenClaw
```bash
# 安装
npm install -g openclaw clawhub
# 初始化
openclaw onboard
```
---
## Gateway 管理
```bash
# 启动/停止/重启
systemctl --user start openclaw-gateway
systemctl --user stop openclaw-gateway
systemctl --user restart openclaw-gateway
# 查看状态
systemctl --user status openclaw-gateway
# 开机自启
systemctl --user enable openclaw-gateway
# 查看日志
journalctl --user -u openclaw-gateway -n 50 --no-pager
# 修改配置后重载
systemctl --user daemon-reload
```
---
## Agent 管理
### 创建 Agent
```bash
openclaw agents add <agent_name> --non-interactive --workspace /home/shenwei/.openclaw/workspace-agent-<agent_name> --model MiniMax-M2.5
```
**示例**
```bash
openclaw agents add yunhan --non-interactive --workspace /home/shenwei/.openclaw/workspace-agent-yunhan --model MiniMax-M2.5
```
### 列出 Agent
```bash
openclaw agents list
```
### 删除 Agent
```bash
openclaw agents delete <agent_name> --force
```
---
## Telegram Bot 绑定
### 绑定 Bot 到 Agent
```bash
openclaw agents bind --agent <agent_id> --bind telegram:<account_name>
```
**示例**
```bash
openclaw agents bind --agent yunhan --bind telegram:yunhan
```
绑定后需重启 Gateway
```bash
systemctl --user restart openclaw-gateway
```
### 删除 Bot
```bash
openclaw channels remove --channel telegram --account <account_name> --delete
```
---
## 常用命令
| 命令 | 功能 |
|------|------|
| `openclaw --version` | 查看版本 |
| `openclaw status` | 查看状态 |
| `openclaw onboard` | 初始化 |
| `openclaw doctor --fix` | 修复配置 |
| `openclaw logs --follow` | 查看日志 |
---
## 注意事项
1. **不要用 root 运行** - 会生成 `/root/.openclaw`,权限混乱
2. **统一使用普通用户** (shenwei) 安装和运行
3. **通过 systemctl 管理 Gateway**,不要用 tmux
4. **Telegram Bot 限制** - 每个账号最多 20 个 bot
---
## Ubuntu 服务器列表
| 服务器 | 内网 IP | 说明 |
|--------|---------|------|
| ubuntu1 | 192.168.3.47 | - |
| ubuntu2 | 192.168.3.45 | - |
---
*最后更新: 2026-03-16*