跳到主要内容
OpenClaw 本地部署教程:环境配置、插件开发与常见问题排查 | 极客日志
JavaScript Node.js AI
OpenClaw 本地部署教程:环境配置、插件开发与常见问题排查 介绍 OpenClaw 在低配置电脑上的本地部署方案。内容涵盖 Node.js、Ollama 等环境搭建,支持 Windows 与 Ubuntu 系统。详解配置文件修改、本地模型拉取及服务启动验证。提供基于 TypeScript 的插件开发流程,包含文件压缩示例。总结虚拟化未开启、依赖超时、内存不足等常见问题的解决方案,适用于希望实现自动化办公的用户。
竹影清风 发布于 2026/4/5 更新于 2026/5/20 29 浏览前言
本文基于 OpenClaw 最新版本编写,适配低配置场景(最低 2vCPU+2GiB 内存+40GiB SSD),兼容 Windows 10/11(优先 WSL2)、Ubuntu 20.04+ 系统。内容覆盖环境配置、本地部署、插件开发及高频问题排查,重点解决部署卡顿、国内网络适配、插件开发无思路、报错无法排查四大痛点。
一、前置准备(适配优化)
1.1 硬件要求(最低适配)
CPU:Intel i3 4 代+/AMD Ryzen 3 2000+(支持虚拟化,需在 BIOS 中开启)
内存:最低 2GiB(建议 4GiB,开启轻量化配置可适配 2GiB)
存储:最低 40GiB SSD(机械硬盘需优化读写)
系统:Windows 10 64 位+/Ubuntu 20.04 LTS 64 位+
1.2 必备工具与依赖
核心依赖:Node.js v22+、Git、pnpm、Python 3.10-3.11(禁止 3.12+,避免依赖冲突)、Ollama v0.15.4+(本地模型运行核心)
1.2.1 Windows 系统(优先 WSL2,无 WSL2 则用原生系统)
# 1. 配置系统执行权限(管理员身份打开 PowerShell)
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine
Get-ExecutionPolicy -List
# 验证,LocalMachine 显示 RemoteSigned 即为成功
# 2. 安装 Node.js v22+(国内镜像,无需手动配置环境变量)
iwr -useb https://registry.npmmirror.com/binary.html?path=node/v22.0.0/node-v22.0.0-x64.msi -OutFile node-v22.0.0-x64.msi
.
ode-v22.0.0-x64.msi /quiet
# 静默安装,避免弹窗
node -v
# 验证,输出 v22.0.0+ 即为成功
npm -v
# 验证,输出 10.5.0+ 即为成功
# 3. 配置 npm 国内镜像(解决下载慢、超时)
npm config set registry https://registry.npmmirror.com
npm config set puppeteer_download_host https://registry.npmmirror.com/binary.html?path=chromium-browser-snapshots/
# 4. 安装 Git(国内镜像,适配版)
iwr -useb https://registry.npmmirror.com/binary.html?path=git-for-windows/v2.43.0.windows.1/Git-2.43.0-64-bit.exe -OutFile Git-2.43.0-64-bit.exe
.
Git-2.43.0-64-bit.exe /silent /norestart
git --version
# 验证,输出 git version 2.43.0+ 即为成功
# 5. 安装 Python 3.10(兼容最佳版本,国内镜像)
iwr -useb https://mirrors.aliyun.com/python/3.10/python-3.10.11-amd64.exe -OutFile python-3.10.11-amd64.exe
.
python-3.10.11-amd64.exe /quiet InstallAllUsers=1 PrependPath=1
# 静默安装并配置环境变量
python --version
# 验证,输出 Python 3.10.11 即为成功
pip --version
# 验证,输出 pip 24.0+ 即为成功
# 6. 配置 pip 国内镜像(永久生效)
mkdir %APPDATA%\pip
echo "[global] index-url = https://mirrors.aliyun.com/pypi/simple/ [install] trusted-host = mirrors.aliyun.com timeout = 60" > %APPDATA%\pip\pip.ini
pip install pip -U
# 验证,显示从阿里云镜像下载即为成功
# 7. 安装 Ollama v0.15.4+(本地模型运行核心,适配)
winget install ollama
# 若无 winget,手动下载:https://ollama.com/download
ollama --version
# 验证,输出 0.15.4+ 即为成功
1.2.2 Ubuntu 系统(含 WSL2,轻量化首选)
sudo apt update && sudo apt install -y curl git build-essential --no-install-recommends
curl -fsSL https://registry.npmmirror.com/binary.html?path=node/v22.0.0/node-v22.0.0-linux-x64.tar.xz | tar -xJ -C /usr/local/
>> ~/.bashrc
~/.bashrc
node -v
npm -v
npm config registry https://registry.npmmirror.com
npm config puppeteer_download_host https://registry.npmmirror.com/binary.html?path=chromium-browser-snapshots/
apt install -y python3.10 python3.10-pip python3.10-venv --no-install-recommends
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1
python3 --version
-p ~/.config/pip
> ~/.config/pip/pip.conf
pip3 install pip -U
curl -fsSL https://ollama.com/install.sh | sh
ollama --version
sudo
echo
"export PATH=/usr/local/node-v22.0.0-linux-x64/bin:$PATH "
source
set
set
sudo
sudo
mkdir
echo
"[global] index-url = https://mirrors.aliyun.com/pypi/simple/ [install] trusted-host = mirrors.aliyun.com timeout = 60"
1.3 API Key 获取(国内大模型,无联网也可跳过,用本地模型) 优先选择阿里通义千问(免费额度足,国内直连,无压力),步骤如下(纯操作):
start https://dashscope.aliyun.com/
xdg-open https://dashscope.aliyun.com/
1.4 轻量化优化(核心,解决卡顿、内存不足) # Windows 优化(管理员 PowerShell 执行)
# 1. 关闭非必要后台进程(释放内存)
taskkill /f /im chrome.exe /im qq.exe /im wechat.exe
# 关闭浏览器、IM 等无关进程
# 2. 优化虚拟内存(机械硬盘必做,SSD 可选)
wmic pagefileset where name='C:\pagefile.sys' set InitialSize=4096,MaximumSize=8192
# 虚拟内存设为 4-8GiB
# 3. 关闭 Windows 自动更新(避免后台占用 CPU/内存)
sc config wuauserv start= disabled
sc stop wuauserv
sudo systemctl stop cron.service bluetooth.service --no-block
echo "* soft memlock 2097152" >> /etc/security/limits.conf
echo "* hard memlock 2097152" >> /etc/security/limits.conf
sudo sysctl -w vm.dirty_ratio=5
sudo sysctl -w vm.dirty_background_ratio=2
二、OpenClaw 核心部署(最新版本) 核心说明:OpenClaw 当前版本已整合原 ClawdBot、Moltbot 功能,旧版本命令全部失效,需按以下步骤全新安装,禁止混合旧版本文件。
2.1 克隆 OpenClaw 最新源码(国内镜像)
mkdir D:\OpenClaw && cd D:\OpenClaw
mkdir ~/openclaw && cd ~/openclaw
git clone https://github.moeyy.xyz/https://github.com/openclaw/openclaw.git
cd openclaw
2.2 安装项目依赖(国内源加速)
npm install -g pnpm --registry https://registry.npmmirror.com
pnpm -v
pnpm install --registry https://registry.npmmirror.com --no-optional
pip3 install dashscope requests pyyaml python-dotenv -i https://mirrors.aliyun.com/pypi/simple/
2.3 核心配置(本地模型/在线模型二选一) 配置文件为项目根目录 config.yaml,对缩进敏感,直接复制以下内容,仅修改 API Key(在线模型)或模型名称(本地模型)即可。
notepad config.yaml
vim config.yaml
bot:
name: OpenClaw-AI-Employee
version: 2026.1 .30
language: zh-CN
memory:
enabled: true
max_size: 100
model:
type: local
online:
api_key: "你的通义千问 API Key"
base_url: "https://dashscope.aliyuncs.com/compatible-mode/v1"
model: "qwen-turbo"
local:
model: "ministral-3:8b"
ollama_url: "http://localhost:11434"
gateway:
port: 18789
enabled: true
lightweight: true
skills:
enabled: true
auto_load: true
max_concurrent: 2
2.4 本地模型部署(无联网必做,Ollama)
ollama pull ministral-3:8b
ollama pull llama3:8b-instruct-q4_0
start /b ollama serve
nohup ollama serve > ollama.log 2>&1 &
curl http://localhost:11434/api/version
2.5 启动 OpenClaw 服务
pnpm start:lightweight
nohup pnpm start:lightweight > openclaw.log 2>&1 &
start http://127.0.0.1:18789/
xdg-open http://127.0.0.1:18789/
curl http://localhost:18789/health
pnpm run test :agent -- --message "列出当前目录下所有文件"
New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Run" -Name "OpenClaw" -Value "D:\OpenClaw\openclaw\node_modules\.bin\pnpm start:lightweight"
echo "nohup pnpm start:lightweight > ~/openclaw/openclaw.log 2>&1 &" >> ~/.bashrc
2.6 部署验证(必做,确保 AI 员工可正常工作)
pnpm run agent -- --message "在当前目录创建 test 文件夹,新建 3 个 txt 文件,分别命名为 file1.txt、file2.txt、file3.txt"
echo "OpenClaw 是热门开源 AI 助手,可本地部署,适配,实现自动化办公" > test.txt
pnpm run agent -- --message "总结 test.txt 文件的内容,不超过 50 字"
pnpm run agent -- --message "介绍你自己,用中文,简洁明了"
三、OpenClaw 插件开发 核心说明:OpenClaw 插件基于 TypeScript(ESM)开发,遵循 Oxlint/Oxfmt 规范,采用 AgentSkills 标准格式,通过 SKILL.md 定义功能,开发无需高配置,插件体积控制在 100KB 以内即可正常运行。以下以'文件批量压缩插件'为例(高频需求),全程实操,可直接复制代码。
3.1 插件开发环境准备
pnpm install -D typescript @types/node oxlint oxfmt --registry https://registry.npmmirror.com
npx tsc --init --target ES6 --module ESNext --outDir dist --rootDir src
mkdir -p src/plugins/compress-files
cd src/plugins/compress-files
touch index.ts SKILL.md package.json .eslintrc.js
3.2 插件核心代码编写(批量压缩文件)
3.2.1 package.json(插件配置,固定格式) {
"name" : "compress-files-plugin" ,
"version" : "1.0.0" ,
"description" : "OpenClaw 文件批量压缩插件,支持 zip 格式,轻量化无冗余" ,
"main" : "dist/index.js" ,
"type" : "module" ,
"dependencies" : {
"archiver" : "^7.0.1"
} ,
"devDependencies" : {
"@types/archiver" : "^6.0.2"
}
}
3.2.2 SKILL.md(插件功能定义,AI 识别核心) # 插件名称:文件批量压缩插件(compress-files-plugin)
# 插件功能:批量压缩指定目录下的文件/文件夹,生成 zip 压缩包,适配低配置
# 适用场景:文件整理、空间释放
# 输入参数:
# - dirPath:必填,需要压缩的目录路径(绝对路径/相对路径均可)
# - zipName:必填,压缩包名称(无需加.zip 后缀)
# - ignore:可选,需要忽略的文件/文件夹(数组格式,如 ["node_modules", "*.log"])
# 输出结果:压缩包保存路径、压缩大小、耗时
# 异常处理:目录不存在、无权限时,返回明确报错信息,不崩溃
# 优化:禁用多线程压缩,降低 CPU 占用
3.2.3 index.ts(核心逻辑,TypeScript,轻量化) import fs from 'fs' ;
import path from 'path' ;
import archiver from 'archiver' ;
export class CompressFilesPlugin {
public static pluginId = 'compress-files-plugin' ;
public static version = '1.0.0' ;
private static readonly isLightweight = true ;
public async execute (params : { dirPath : string ; zipName : string ; ignore ?: string []; }): Promise <{ success : boolean ; data ?: any ; error ?: string }> {
try {
const { dirPath, zipName, ignore = [] } = params;
if (!fs.existsSync (dirPath)) {
return { success : false , error : `目录不存在:${dirPath} ` };
}
const absoluteDirPath = path.resolve (dirPath);
const zipPath = path.resolve (`${zipName} .zip` );
const output = fs.createWriteStream (zipPath);
const archive = archiver ('zip' , {
zlib : { level : 1 },
...(CompressFilesPlugin .isLightweight && { highWaterMark : 64 * 1024 }),
});
output.on ('close' , () => {});
archive.on ('warning' , (err ) => {
if (err.code === 'ENOENT' ) {
console .warn (`压缩警告:${err.message} ` );
} else {
throw err;
}
});
archive.on ('error' , (err ) => {
throw err;
});
archive.pipe (output);
archive.directory (absoluteDirPath, false , (entry ) => {
const isIgnore = ignore.some ((ignoreItem ) => {
if (ignoreItem.startsWith ('*.' )) {
const ext = path.extname (entry.name );
return ext === ignoreItem.slice (1 );
} else {
return entry.name === ignoreItem || entry.name .includes (ignoreItem);
}
});
return !isIgnore;
});
await archive.finalize ();
const zipStats = fs.statSync (zipPath);
const zipSize = (zipStats.size / 1024 / 1024 ).toFixed (2 );
return {
success : true ,
data : {
zipPath,
zipSize : `${zipSize} MB` ,
耗时:`${Date .now() - Date .now()} ms` ,
message : '压缩成功,适配低配置'
}
};
} catch (error) {
return { success : false , error : `压缩失败:${(error as Error ).message} ` };
}
}
public static register ( ) {
return {
pluginId : this .pluginId ,
version : this .version ,
execute : (params : any ) => new this ().execute (params)
};
}
}
export default CompressFilesPlugin .register ();
3.2.4 .eslintrc.js(代码规范,可选) module .exports = {
env : {
node : true ,
es2021 : true ,
},
extends : ['eslint:recommended' , 'plugin:@typescript-eslint/recommended' ],
parser : '@typescript-eslint/parser' ,
parserOptions : {
ecmaVersion : 'latest' ,
sourceType : 'module' ,
},
plugins : ['@typescript-eslint' ],
rules : {
'@typescript-eslint/explicit-module-boundary-types' : 'off' ,
'@typescript-eslint/no-unused-vars' : 'warn' ,
'no-console' : 'off' ,
},
};
3.3 插件打包与安装(一键完成)
cd src/plugins/compress-files
pnpm install --registry https://registry.npmmirror.com
npx tsc
cd ../../../..
pnpm run plugin:install -- --path src/plugins/compress-files
pnpm run plugin:list
pnpm run restart:lightweight
3.4 插件测试(必做,确保电脑可正常使用)
pnpm run agent -- --message "调用文件批量压缩插件,dirPath=./test,zipName=test-compress,ignore=[\"*.log\"]"
ls | grep test-compress.zip
dir | findstr test-compress.zip
pnpm run agent -- --message "调用文件批量压缩插件,dirPath=./nonexistent,zipName=error-test"
mkdir test-100 && cd test-100
for i in {1..100}; do echo "test" > file$i .txt; done
for /l %i in (1,1,100) do echo test > file%i.txt
cd ..
pnpm run agent -- --message "调用文件批量压缩插件,dirPath=./test-100,zipName=100-files-compress"
3.5 插件开发规范(适配补充) # 1. 插件开发 3 个核心原则(必遵循)
# 1.1 体积控制:插件打包后体积≤100KB,避免依赖大型库(如 axios 可用 node 内置 http 替代)
# 1.2 CPU/内存控制:禁用多线程、多进程,压缩级别、缓存大小设为最低
# 1.3 异常处理:所有异常必须捕获,返回明确报错,禁止崩溃(抗干扰弱)
# 2. 常用插件开发模板(直接复用,适配)
# 2.1 文件操作类(批量重命名、批量删除):复用压缩插件结构,替换核心逻辑
# 2.2 文本处理类(批量替换、文本提取):无需依赖大型库,用 node 内置 fs、string 方法
# 2.3 IM 对接类(企业微信、钉钉):使用轻量 SDK,禁用长连接(节省内存)
# 3. 插件卸载(无需时删除,释放空间)
pnpm run plugin:uninstall -- --id compress-files-plugin
rm -rf src/plugins/compress-files # 彻底删除插件目录
四、常见坑排查 核心说明:所有坑均来自 OpenClaw 最新版本,结合低配置场景,每个坑均提供'报错信息 + 原因 + 解决命令',可直接复制执行,无需复杂排查。
坑 1:启动失败,报错'VT-x is disabled in BIOS/UEFI' # 报错原因:BIOS 中未开启虚拟化,Ollama 和 OpenClaw 网关无法运行
# 解决步骤(纯操作,通用)
1. 关闭电脑,重启时连续按 BIOS 快捷键(联想 F2、戴尔 F12、惠普 F10,其他品牌百度)
2. 进入 BIOS,找到'虚拟化技术'(VT-x/AMD-V),设置为'Enabled'
3. 保存 BIOS 设置(按 F10,选择 Yes),电脑自动重启
4. 重启后重新启动 OpenClaw 和 Ollama,验证是否正常
pnpm start:lightweight
nohup ollama serve > ollama.log 2>&1 &
坑 2:依赖安装超时,报错'request timed out'(国内网络) # 报错原因:未配置国内镜像,或镜像配置错误,网络速度慢
# 解决命令(Windows/Ubuntu 通用,一键修复)
# 1. 重新配置 npm 国内镜像
npm config delete registry
npm config set registry https://registry.npmmirror.com
npm config set puppeteer_download_ host https://registry.npmmirror.com/binary.html?path=chromium-browser-snapshots/
# 2. 重新配置 pip 国内镜像
# Windows
echo "[global] index-url = https://mirrors.aliyun.com/pypi/simple/ [install] trusted-host = mirrors.aliyun.com timeout = 120" > %APPDATA%\pip\pip.ini
# Ubuntu
echo "[global] index-url = https://mirrors.aliyun.com/pypi/simple/ [install] trusted-host = mirrors.aliyun.com timeout = 120" > ~/.config/pip/pip.conf
# 3. 清理缓存,重新安装依赖
npm cache clean --force
pnpm cache clean
pnpm install --registry https://registry.npmmirror.com --no-optional
坑 3:启动后卡顿,CPU 占用 100% # 报错原因:未开启轻量化配置,并发数过高,本地模型配置不当
# 解决命令(一键优化,必做)
# 1. 修改 config.yaml,开启轻量化配置(重新启动生效)
# Windows notepad config.yaml
# Ubuntu vim config.yaml
# 关键修改参数(确保以下配置一致)
gateway:
lightweight: true
skills:
max_concurrent: 1 # 并发数设为 1,进一步降低 CPU 占用
model:
local:
model: "llama3:8b-instruct-q4_ 0" # 2GiB 内存必设,量化版更轻量
# 2. 关闭无关进程,释放 CPU/内存
# Windows(管理员 PowerShell)
taskkill /f /im chrome.exe /im qq.exe /im wechat.exe /im explorer.exe
# 保留核心进程
start explorer.exe
# Ubuntu/WSL2
sudo killall -9 chrome firefox qq wechat
sudo systemctl stop cron.service bluetooth.service
# 3. 重启 OpenClaw 服务(轻量化模式)
pnpm run restart:lightweight
# 验证 CPU 占用(≤50% 即为正常)
# Windows tasklist | findstr node
# Ubuntu top -p $(pgrep node)
坑 4:插件安装失败,报错'Plugin id already exists' # 报错原因:插件 ID 重复(OpenClaw 插件 ID 唯一),或之前安装过同名插件未卸载干净
# 解决命令(一键清理,重新安装)
# 1. 查看已安装插件,找到重复 ID
pnpm run plugin:list
# 2. 卸载重复插件(替换为重复的插件 ID)
pnpm run plugin:uninstall -- --id 重复的插件 ID
# 3. 清理插件缓存(必做,避免缓存残留)
rm -rf node_modules/.cache/openclaw-plugin
# 4. 修改新插件的 pluginId(src/plugins/compress-files/index.ts)
# 找到 pluginId,修改为唯一值,如 compress-files-plugin-v1
# 5. 重新打包安装插件
cd src/plugins/compress-files
npx tsc
cd ../../../..
pnpm run plugin:install -- --path src/plugins/compress-files
坑 5:本地模型启动失败,报错'insufficient memory' # 报错原因:内存不足,本地模型体积过大(如 ministral-3:8b 需要 8GiB 内存)
# 解决命令(专属,轻量化模型替换)
# 1. 删除原有大型模型
ollama rm ministral-3:8b
# 2. 拉取轻量化量化模型(2GiB 内存可运行)
ollama pull llama3:8b-instruct-q4_0 # 4GiB 大小,量化版
# 3. 修改 OpenClaw 配置,适配轻量化模型
# Windows notepad config.yaml
# Ubuntu vim config.yaml
# 修改 model.local.model 为轻量化模型
model:
type: local
local:
model: "llama3:8b-instruct-q4_ 0"
# 4. 优化 Ollama 内存占用(必做)
# Windows(管理员 PowerShell)
setx OLLAMA_MAX_ MEMORY "2GB" /m
# Ubuntu/WSL2
echo "export OLLAMA_MAX_ MEMORY=2GB" >> ~/.bashrc
source ~/.bashrc
# 5. 重启 Ollama 和 OpenClaw 服务
# Windows
taskkill /f /im ollama.exe
start /b ollama serve
pnpm run restart:lightweight
# Ubuntu/WSL2
pkill ollama
nohup ollama serve > ollama.log 2>&1 &
pnpm run restart:lightweight
坑 6:Web Dashboard 无法访问,报错'Connection refused' # 报错原因:网关未启动、端口被占用,或防火墙拦截
# 解决命令(一键排查修复)
# 1. 检查 OpenClaw 网关状态
pnpm run gateway:status
# 若未启动,启动网关
pnpm run gateway:start -- --lightweight
# 2. 检查端口是否被占用(默认 18789)
# Windows netstat -ano | findstr 18789
# 若占用,结束占用进程(替换为占用进程 ID)
taskkill /f /pid 占用进程 ID
# Ubuntu/WSL2 lsof -i:18789
# 若占用,结束占用进程(替换为占用进程 ID)
sudo kill -9 占用进程 ID
# 3. 关闭防火墙(临时,验证是否拦截)
# Windows(管理员 PowerShell)
netsh advfirewall set allprofiles state off
# Ubuntu sudo ufw disable
# 4. 重新访问 Web Dashboard
start http://127.0.0.1:18789/ # Windows
xdg-open http://127.0.0.1:18789/ # Ubuntu
坑 7:启动报错'Cannot find module 'dashscope'' # 报错原因:Python 依赖未安装,或安装失败,pip 镜像配置错误
# 解决命令(一键安装修复)
# 1. 重新配置 pip 国内镜像
# Windows
echo "[global] index-url = https://mirrors.aliyun.com/pypi/simple/ [install] trusted-host = mirrors.aliyun.com timeout = 120" > %APPDATA%\pip\pip.ini
# Ubuntu
echo "[global] index-url = https://mirrors.aliyun.com/pypi/simple/ [install] trusted-host = mirrors.aliyun.com timeout = 120" > ~/.config/pip/pip.conf
# 2. 重新安装缺失的 Python 依赖
pip3 install dashscope requests pyyaml python-dotenv -i https://mirrors.aliyun.com/pypi/simple/
# 3. 验证依赖是否安装成功
pip3 list | grep dashscope
# 输出 dashscope 版本即为成功
# 4. 重启 OpenClaw 服务
pnpm run restart:lightweight
坑 8:机械硬盘部署,报错'EIO: i/o error, write' # 报错原因:机械硬盘读写速度慢,文件 IO 超时,或硬盘存在坏道
# 解决命令(机械硬盘专属优化)
# 1. 优化硬盘读写缓存(Windows/Ubuntu 通用)
# Windows(管理员 PowerShell)
fsutil behavior set DisableLastAccess 1 # 禁用文件最后访问时间记录
# Ubuntu/WSL2
sudo sysctl -w vm.dirty_ratio=3
sudo sysctl -w vm.dirty_ background_ratio=1
# 2. 更换部署目录(机械硬盘→SSD,若无 SSD,选择空间充足的分区)
# Windows mkdir E:\OpenClaw && cd E:\OpenClaw
git clone https://github.moeyy.xyz/https://github.com/openclaw/openclaw.git
cd openclaw
pnpm install --registry https://registry.npmmirror.com --no-optional
# 3. 降低文件 IO 频率(修改 config.yaml)
model:
cache: false # 禁用模型缓存,减少硬盘读写
skills:
auto_ load: false # 禁用插件自动加载,手动加载所需插件
# 4. 手动加载插件(避免启动时大量 IO 操作)
pnpm run plugin:load -- --id compress-files-plugin
# 5. 重启 OpenClaw 服务
pnpm run restart:lightweight
五、进阶优化(可选,进一步提升流畅度) # 1. 模型优化(本地模型,核心)
# 1.1 量化模型(进一步降低内存占用)
ollama pull llama3:8b-instruct-q2_k # 2GiB 内存极致优化版(2.5GiB 大小)
# 1.2 禁用模型记忆(节省内存,无需记忆功能时)
# 修改 config.yaml
bot:
memory:
enabled: false
# 2. 服务优化(后台运行,不占用桌面资源)
# Windows(创建后台服务,开机自启)
sc create OpenClaw binPath= "D:\OpenClaw\openclaw\node_ modules\.bin\pnpm start:lightweight" start= auto sc start OpenClaw
# Ubuntu/WSL2(创建 systemd 服务)
sudo echo "[Unit] Description=OpenClaw AI Employee After=network.target ollama.service [Service] User=$USER ExecStart=$HOME/openclaw/node_modules/.bin/pnpm start:lightweight Restart=always RestartSec=5 [Install] WantedBy=multi-user.target" > /etc/systemd/system/openclaw.service
sudo systemctl daemon-reload
sudo systemctl enable openclaw.service
sudo systemctl start openclaw.service
# 3. 插件优化(仅保留必要插件)
pnpm run plugin:uninstall -- --id 无需的插件 ID
# 手动加载插件(仅加载常用插件)
pnpm run plugin:load -- --id compress-files-plugin
# 4. 日志优化(禁用多余日志,减少硬盘读写)
# 修改 config.yaml
logger:
level: "error" # 仅记录错误日志,禁用 info、debug 日志
file: false # 禁用日志文件写入,仅控制台输出
六、部署/开发常用命令汇总 # 一、部署常用命令
1. 启动 OpenClaw(轻量化):pnpm start:lightweight
2. 重启 OpenClaw:pnpm run restart:lightweight
3. 停止 OpenClaw:pnpm run stop
4. 验证服务健康:curl http://localhost:18789/health
5. 启动 Ollama 服务:nohup ollama serve > ollama.log 2>&1 &(Ubuntu)
6. 拉取本地模型:ollama pull llama3:8b-instruct-q4_0
# 二、插件开发常用命令
1. 打包插件:npx tsc(插件目录下)
2. 安装插件:pnpm run plugin:install -- --path 插件路径
3. 卸载插件:pnpm run plugin:uninstall -- --id 插件 ID
4. 查看插件列表:pnpm run plugin:list
5. 手动加载插件:pnpm run plugin:load -- --id 插件 ID
# 三、优化常用命令
1. 释放内存/CPU:taskkill /f /im 无关进程(Windows);sudo killall -9 无关进程(Ubuntu)
2. 优化硬盘读写:sudo sysctl -w vm.dirty_ ratio=3(Ubuntu);fsutil behavior set DisableLastAccess 1(Windows)
3. 查看 CPU 占用:top -p $(pgrep node)(Ubuntu);tasklist | findstr node(Windows)
# 四、问题排查常用命令
1. 查看 OpenClaw 日志:cat openclaw.log(Ubuntu);type openclaw.log(Windows)
2. 查看 Ollama 日志:cat ollama.log(Ubuntu);type ollama.log(Windows)
3. 检查端口占用:lsof -i:18789(Ubuntu);netstat -ano | findstr 18789(Windows)
4. 验证依赖安装:pnpm list && pip3 list
相关免费在线工具 RSA密钥对生成器 生成新的随机RSA私钥和公钥pem证书。 在线工具,RSA密钥对生成器在线工具,online
Mermaid 预览与可视化编辑 基于 Mermaid.js 实时预览流程图、时序图等图表,支持源码编辑与即时渲染。 在线工具,Mermaid 预览与可视化编辑在线工具,online
随机西班牙地址生成器 随机生成西班牙地址(支持马德里、加泰罗尼亚、安达卢西亚、瓦伦西亚筛选),支持数量快捷选择、显示全部与下载。 在线工具,随机西班牙地址生成器在线工具,online
Keycode 信息 查找任何按下的键的javascript键代码、代码、位置和修饰符。 在线工具,Keycode 信息在线工具,online
Escape 与 Native 编解码 JavaScript 字符串转义/反转义;Java 风格 \uXXXX(Native2Ascii)编码与解码。 在线工具,Escape 与 Native 编解码在线工具,online
JavaScript / HTML 格式化 使用 Prettier 在浏览器内格式化 JavaScript 或 HTML 片段。 在线工具,JavaScript / HTML 格式化在线工具,online