从安装到故障排查,覆盖 OpenClaw 日常运维的 12 个关键场景

本文整理了 OpenClaw 日常运维的完整流程:安装 → 日常运维 → 模型管理 → 插件 → Gateway → systemd → 故障排查 → 常见场景。


一、安装与基础初始化

安装 OpenClaw

npm install -g openclaw@latest

更新版本

openclaw update

查看版本

openclaw --version

初始化配置

openclaw configure

主要配置内容:

  • API Key
  • 默认模型
  • Gateway
  • 插件

二、日常管理命令

查看整体状态

openclaw status

健康检查

openclaw health

查看日志

openclaw daemon logs

重启后台服务

openclaw daemon restart

重新配置

openclaw configure

三、TUI 终端

打开 TUI

openclaw tui

进入 AI 终端界面后,可用命令:

  • /new - 新建对话
  • /clear - 清空历史
  • 查看当前模型

四、模型管理

查看所有模型

openclaw models list

搜索模型

openclaw models list | grep openai

例如:

openclaw models list | grep aicodewith

设置默认模型

openclaw models set [provider/model]

示例:

openclaw models set kimi-code/kimi-for-coding

查看当前默认模型

openclaw config get agents.defaults.model

修改默认模型

openclaw config set agents.defaults.model.primary openai-codex/gpt-5.4

添加备用模型(Fallback)

当主模型失败时自动切换。

openclaw models fallbacks add [provider/model]

示例:

openclaw models fallbacks add openai-codex/gpt-5.2-codex

查看备用模型

openclaw config get agents.defaults.model.fallbacks

五、插件管理

查看插件列表

openclaw plugins list

安装插件

openclaw plugins install 插件名

示例:

openclaw plugins install openclaw-aicodewith-auth

启用插件

openclaw plugins enable openclaw-aicodewith-auth

禁用插件

openclaw plugins disable 插件名

卸载插件

openclaw plugins remove 插件名

六、Gateway 管理

Gateway 是 OpenClaw 的模型代理层。

查看 Gateway 状态

openclaw gateway status

启动 Gateway

openclaw gateway start

停止 Gateway

openclaw gateway stop

重启 Gateway

openclaw gateway restart

Gateway 端口检查

默认端口:18789

检查:

ss -lntp | grep 18789

七、推荐:使用 systemd 管理(生产环境)

生产环境建议: 不要用 openclaw gateway 命令,直接 systemd 管理。

启动

systemctl start openclaw-gateway

停止

systemctl stop openclaw-gateway

重启

systemctl restart openclaw-gateway

查看状态

systemctl status openclaw-gateway --no-pager -l

实时日志

journalctl -u openclaw-gateway -f

查看最近日志

journalctl -u openclaw-gateway -n 100

八、配置管理

查看所有配置

openclaw config list

查看某项配置

openclaw config get KEY

例如:

openclaw config get agents.defaults.model

修改配置

openclaw config set KEY VALUE

例如:

openclaw config set agents.defaults.model.primary kimi-code/kimi-for-coding

九、常见故障排查

1. Gateway 无法启动

检查端口:

ss -lntp | grep 18789

查看日志:

journalctl -u openclaw-gateway -f

2. 模型调用失败

检查:

  • API KEY
  • 模型名称
  • 插件是否启用

查看模型列表:

openclaw models list

3. 插件无法使用

查看插件:

openclaw plugins list

重新启用:

openclaw plugins enable 插件名

4. TUI 无法连接 Gateway

检查:

  • Gateway 是否启动
  • 端口是否监听
systemctl status openclaw-gateway

十、常用运维三板斧

日常 90% 情况只用这三个命令:

# 看状态
systemctl status openclaw-gateway

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

# 重启
systemctl restart openclaw-gateway

十一、推荐模型组合(稳定方案)

示例配置

主模型: openai-codex/gpt-5.4

备用模型:

  • openai-codex/gpt-5.2-codex
  • kimi-code/kimi-for-coding

添加备用模型

openclaw models fallbacks add openai-codex/gpt-5.2-codex
openclaw models fallbacks add kimi-code/kimi-for-coding

十二、推荐服务器配置

配置最低推荐
CPU2 核4 核
RAM4GB8GB
端口1878918789

总结

OpenClaw 日常运维的核心流程:

  1. 安装配置openclaw configure
  2. 日常管理openclaw status + openclaw health
  3. 模型管理openclaw models list + fallback 配置
  4. 插件管理openclaw plugins list + install/enable
  5. Gateway 管理:生产环境用 systemd
  6. 故障排查:三板斧(status + logs + restart)

记住运维三板斧,覆盖 90% 日常场景。


整理日期:2026-03-13