OpenClaw 是一个高隐私、可扩展的 AI 助手网关。本手册旨在帮助开发者快速掌握从基础配置到生产环境加固、数据备份、故障排查的全量核心命令。
目录
-
1. 🛠️ 全局参数与环境隔离 -
2. 🚀 快速起步与基础配置 -
3. 🌐 核心网关 (Gateway) 管理与控制面板 -
4. 🛡️ 安全审计与生产环境加固 -
5. 💬 消息、频道与会话控制 -
6. 🧠 AI 模型、技能与内存 -
7. 📱 设备/节点 (Devices/Nodes) 管理 -
8. 📂 工作区核心文件 (Files) -
9. 💾 数据备份与恢复 (Backup) -
10. 🚨 常见问题排障 (Troubleshooting)
1. 🛠️ 全局参数与环境隔离
在执行任何 openclaw 命令前,可以添加以下全局 Flag 来改变运行环境:
|
|
|
|
|---|---|---|
--dev |
|
openclaw --dev gateway start |
--profile <name> |
|
openclaw --profile work doctor |
--log-level <level> |
|
openclaw --log-level debug logs |
--no-color |
|
openclaw --no-color status |
2. 🚀 快速起步与基础配置
初始化与工作区
# 交互式初始化
openclaw onboard --wizard
# 手动初始化指定路径
openclaw setup --workspace ~/my-ai-Agent
# 设置 Shell 自动补全 (以 Zsh 为例)
openclaw completion zsh > ~/.zsh-completion
echo "source ~/.zsh-completion" >> ~/.zshrc
基础参数配置与校验
# 修改默认端口 (永久生效)
openclaw config set gateway.port 19000
# 配置模型 API Key
openclaw config set providers.mistral.apiKey "your_key_here"
# 校验配置文件 (检查语法错误或缺失项)
openclaw config validate
# 查看特定路径的配置值
openclaw config get gateway.port
3. 🌐 核心网关 (Gateway) 管理与控制面板
运行控制
# 启动 Gateway
openclaw gateway start --bind lan
# 强制启动(自动杀死占用端口的旧进程)
openclaw gateway start --force
# 重启或停止服务
openclaw gateway restart
openclaw gateway stop
Web Dashboard
# 本地自动打开
openclaw dashboard
# 远程服务器获取登录 URL 与 Token (不自动打开浏览器)
openclaw dashboard --no-open
4. 🛡️ 安全审计与生产环境加固
# 强制启用网关 Token 验证
openclaw config set gateway.authEnabled true
openclaw config set gateway.authToken "Your_Secret_Token"
# 设置 IP 白名单
openclaw config set gateway.allowlist "127.0.0.1, 10.0.0.5"
# 运行深度安全审计
openclaw security audit --deep
5. 💬 消息、频道与会话控制
# 频道登录
openclaw channels login --channel telegram
# 测试连接性
openclaw channels test --channel telegram --target @mychat --message "Ping"
# 强制重置会话
openclaw sessions reset <session-id>
6. 🧠 AI 模型、技能与内存
# 内存索引重建 (重要:修改文件后必行)
openclaw memory index
# 查看内存状态
openclaw memory status
# 语义搜索记忆
openclaw memory search "配置细节"
7. 📱 设备/节点 (Devices/Nodes) 管理
# 查看待批准的设备
openclaw devices list
# 批准手机端配对
openclaw devices approve <id>
8. 📂 工作区核心文件 (Files)
工作区元文件位于 ~/.openclaw/workspace,通过编辑这些文件可以深度定制助手:
|
|
|
|---|---|
| AGENTS.md | 代理配置
|
| HEARTBEAT.md | 心跳逻辑
|
| IDENTITY.md | 人设设定
|
| README.md | 工作区概览
|
| SOUL.md | 价值观准则
|
| TOOLS.md | 工具清单
|
| USER.md | 用户画像
|
| MEMORY.md | 长期记忆
|
9. 💾 数据备份与恢复 (Backup)
OpenClaw 2026 版引入了原生的备份机制,用于打包配置、凭据和工作区。
创建备份
# 完整备份 (包含配置、状态、凭据和工作区)
openclaw backup create
# 导出到指定目录
openclaw backup create --output ~/my-backups/
# 仅备份配置文件
openclaw backup create --only-config
# 排除工作区文件 (仅备份系统状态和 Key)
openclaw backup create --no-include-workspace
# 备份并立即执行完整性验证
openclaw backup create --verify
校验与恢复
# 校验备份文件是否损坏或被篡改
openclaw backup verify ./2026-03-27-openclaw-backup.tar.gz
💡 提示:恢复前请务必先停止服务
10. 🚨 常见问题排障 (Troubleshooting)
典型报错及对策
|
|
|
|
|---|---|---|
| EADDRINUSE |
|
openclaw gateway start --force |
| 403 Forbidden |
|
|
| Memory Not Found |
|
openclaw memory index |
| Backup Failed |
|
openclaw doctor
|
| Config Error |
|
openclaw config validate |
生产环境服务管理 (Systemd 用户模式)
方法 A:自动化部署(推荐)
# 自动安装系统服务 (开机自启)
openclaw daemon install
# 启动/停止/状态查看
openclaw daemon start
openclaw daemon stop
openclaw daemon status
方法 B:手动命令管理
# 查看服务状态 (无需 sudo)
systemctl --user status openclaw-gateway
# 实时查看日志
journalctl --user -u openclaw-gateway -f
# 立即重启服务
systemctl --user restart openclaw-gateway


