xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

如何在 Raspberry Pi 安装 OpenClaw All In One

如何在 Raspberry Pi 安装 OpenClaw All In One

树莓派 4B / 5B 养龙虾🦞

前置条件(Raspberry Pi 软硬件推荐配置)

  • Raspberry Pi 5 with 4 GB+ RAM
  • USB SSD (USB 移动固态硬盘)
  • Raspberry Pi 官方电源
  • WiFi (写入系统时候,添加到配置文件)
  • 64-bit Raspberry Pi OS

image

https://docs.openclaw.ai/install/raspberry-pi#prerequisites

Raspberry Pi 5 / Raspberry Pi 4B

https://www.raspberrypi.com/products/raspberry-pi-5/

https://www.raspberrypi.com/products/raspberry-pi-5-model-b/

https://www.raspberrypi.com/products/raspberry-pi-4-model-b/

Raspberry Pi 5 compute module

https://www.raspberrypi.com/products/compute-module-5/?variant=cm5-104032

Raspberry Pi Imager

使用 Raspberry Pi OS Lite (64-bit) 制作 headless 服务器系统,设置必要启动配置项目

  • 设置 hostname
  • 开启 SSH
  • 设置 username & password
  • 配置 WiFi (wifi name & wifi password)
  • 静态 ip ?
$ sudo apt install rpi-imager

https://www.raspberrypi.com/software/

https://www.raspberrypi.com/software/operating-systems/

SSH 远程连接

# ssh username@hostname
$ ssh pi@192.168.1.7
# 更新
$ sudo apt update && sudo apt upgrade -y

# 安装必要的 OpenClaw 依赖软件包 (git, curl, build-essential)
$ sudo apt install -y git curl build-essential

# 设置 timezone (用于准确触发 cron & reminders)
$ sudo timedatectl set-timezone Asia/Shanghai

# 安装 nvm
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.4/install.sh | bash
$ nvm -h

$ nvm ls-remote | grep "Latest LTS"
# 安装 node.js 24+
$ nvm install 24.14.0
$ nvm use 24.14.0
$ nvm alias default 24.14.0

$ node --version
$ npm -v
$ npx -v

https://github.com/nvm-sh/nvm?tab=readme-ov-file#install--update-script

设置 swap, 内存性能优化

$ sudo fallocate -l 2G /swapfile

$ sudo chmod 600 /swapfile
$ sudo mkswap /swapfile
$ sudo swapon /swapfile
$ echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

# Reduce swappiness for low-RAM devices
$ echo 'vm.swappiness=10' | sudo tee -a /etc/sysctl.conf
$ sudo sysctl -p

安装 OpenClaw

$ curl -fsSL https://openclaw.ai/install.sh | bash
$ openclaw onboard --install-daemon

$ openclaw status

$ sudo systemctl status openclaw

$ journalctl -u openclaw -f
# 获取 dashboard URL (username@hostname)
$ ssh pi@192.168.1.7  'openclaw dashboard --no-open'
# 在新 Terminal 开启 SSH tunnel (username@hostname)
$ ssh -N -L 18789:127.0.0.1:18789 pi@192.168.1.7

一直可以远程访问,需要使用Tailscale integration (内网穿透 VPN)

# Tailnet-only (Serve)

{
  gateway: {
    bind: "loopback",
    tailscale: { mode: "serve" },
  },
}
#Tailnet-only (bind to Tailnet IP)

{
  gateway: {
    bind: "tailnet",
    auth: { mode: "token", token: "your-token" },
  },
}

https://docs.openclaw.ai/gateway/tailscale

The best secure connectivity platform for devs, IT, and security

A Zero Trust identity-based connectivity platform that replaces your legacy VPN, SASE, and PAM and connects remote teams, multi-cloud environments, CI/CD pipelines, Edge & IoT devices, and AI workloads.

https://tailscale.com/

demos

image

(🐞 反爬虫测试!打击盗版⚠️)如果你看到这个信息, 说明这是一篇剽窃的文章,请访问 https://www.cnblogs.com/xgqfrms/ 查看原创文章!

性能优化

  1. 使用 USB SSD 启动 Raspberry Pi

https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#usb-mass-storage-boot

  1. 开启 module compile cache
$ grep -q 'NODE_COMPILE_CACHE=/var/tmp/openclaw-compile-cache' ~/.bashrc || cat >> ~/.bashrc <<'EOF' # pragma: allowlist secret
export NODE_COMPILE_CACHE=/var/tmp/openclaw-compile-cache
mkdir -p /var/tmp/openclaw-compile-cache
export OPENCLAW_NO_RESPAWN=1
EOF

$ source ~/.bashrc
  1. 减少 memory 使用
$ echo 'gpu_mem=16' | sudo tee -a /boot/config.txt

# 禁用蓝牙 💩
$ sudo systemctl disable bluetooth

https://docs.openclaw.ai/install/raspberry-pi#performance-tips

OpenClaw 配置

$ cat ~/.openclaw/openclaw.json
# 🚀 直接修改配置文件
$ sudo vim ~/.openclaw/openclaw.json

# ⚠️ 直接 CLI 命令行修改
$ openclaw config get agents.defaults.workspace
$ openclaw config set agents.defaults.heartbeat.every "2h"
$ openclaw config unset plugins.entries.brave.config.webSearch.apiKey

# 💩 命令行交互式修改
# full onboarding flow
$ openclaw onboard

# config wizard
$ openclaw configure

https://docs.openclaw.ai/gateway/configuration

feishu bot

https://docs.openclaw.ai/gateway/configuration

$ openclaw plugins install @openclaw/feishu

https://docs.openclaw.ai/channels/feishu

timezone

Ubuntu Linux 通过命令查看时区 timezone

xgqfms@ai2026:~$ timedatectl
               Local time: 五 2026-03-27 14:08:57 CST
           Universal time: 五 2026-03-27 06:08:57 UTC
                 RTC time: 五 2026-03-27 06:08:57
                Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no
xgqfms@ai2026:~$ cat /etc/timezone
Asia/Shanghai
xgqfms@ai2026:~$ ls -l /etc/localtime
lrwxrwxrwx 1 root root 33  3月 11 21:38 /etc/localtime -> /usr/share/zoneinfo/Asia/Shanghai

xgqfms@ai2026:~$ date
2026年 03月 27日 星期五 14:08:46 CST
xgqfms@ai2026:~$ date -R
Fri, 27 Mar 2026 14:08:49 +0800

image

refs



©xgqfrms 2012-2021

www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!


posted @ 2026-03-27 14:53  xgqfrms  阅读(107)  评论(3)    收藏  举报