Raspberry Pi
Raspberry Pi(树莓派)是部署 OpenClaw 的绝佳低功耗设备,适合作为家庭智能网关 7×24 小时运行。
支持的型号
| 型号 | 内存 | 支持情况 | 备注 |
|---|---|---|---|
| Raspberry Pi 5 | 4/8 GB | ✅ 推荐 | 性能最强 |
| Raspberry Pi 4B | 4/8 GB | ✅ 良好 | 4GB 起步 |
| Raspberry Pi 4B | 2 GB | ⚠️ 勉强 | 仅轻负载 |
| Raspberry Pi 3B+ | 1 GB | ❌ 不支持 | 内存不足 |
| Raspberry Pi Zero 2W | 512 MB | ❌ 不支持 | 内存不足 |
ARM64 要求
OpenClaw 需要 64 位操作系统。请确保安装的是 Raspberry Pi OS (64-bit) 而非 32 位版本。
系统要求
| 项目 | 要求 |
|---|---|
| 操作系统 | Raspberry Pi OS Bookworm (64-bit) 或 Ubuntu 22.04+ ARM64 |
| 内存 | 4 GB+(强烈推荐) |
| 存储 | 16 GB+ SD 卡或 USB SSD |
| 网络 | 有线以太网(推荐)或 Wi-Fi |
SSD 替代 SD 卡
SD 卡读写速度慢且寿命有限。强烈建议使用 USB SSD 作为启动盘,性能可提升 3-5 倍。
安装步骤
步骤一:安装操作系统
- 下载 Raspberry Pi Imager
- 选择 Raspberry Pi OS (64-bit) Lite(无桌面版,节省资源)
- 写入 SD 卡或 SSD
- 在高级设置中配置 Wi-Fi 和 SSH
步骤二:初始配置
bash
# SSH 连接到树莓派
ssh pi@raspberrypi.local
# 更新系统
sudo apt update && sudo apt upgrade -y
# 确认是 64 位系统
uname -m
# 应输出 aarch64步骤三:安装 OpenClaw
bash
# 快速安装
curl -fsSL https://openclaw.ai/install.sh | bash
# 或 Docker 安装(推荐)
curl -fsSL https://get.docker.com | bash
sudo usermod -aG docker $USER
# 重新登录后
docker run -d \
--name openclaw \
--restart unless-stopped \
-p 7681:7681 \
-v openclaw-data:/app/data \
openclaw/openclaw:latest步骤四:配置为系统服务
bash
# 自动安装 systemd 服务
openclaw daemon install
# 启动并设为开机自启
openclaw daemon start性能优化
内存优化
Raspberry Pi 内存有限,建议做以下优化:
yaml
# OpenClaw 配置
performance:
max_memory: 2GB # 限制最大内存使用
gc_interval: 300 # 垃圾回收间隔(秒)
cache_size: 50MB # 缓存大小限制如果使用桌面版 OS,关闭图形界面:
bash
# 切换到命令行模式
sudo raspi-config
# 选择 System Options → Boot / Auto Login → ConsoleGPU 内存分配
无桌面环境时,可以减少 GPU 内存:
bash
# 编辑 /boot/config.txt
sudo nano /boot/config.txt
# 添加(最低 16MB 给 GPU)
gpu_mem=16Swap 配置
增加 Swap 空间防止内存不足导致进程被杀:
bash
# 增加 Swap 到 2GB
sudo dphys-swapfile swapoff
sudo sed -i 's/CONF_SWAPSIZE=.*/CONF_SWAPSIZE=2048/' /etc/dphys-swapfile
sudo dphys-swapfile setup
sudo dphys-swapfile swapon电源管理
电源要求
| 型号 | 最低电源 | 推荐电源 |
|---|---|---|
| Pi 4 | 5V 3A (USB-C) | 官方电源适配器 |
| Pi 5 | 5V 5A (USB-C) | 官方 27W 电源 |
供电不足
供电不足会导致系统不稳定、SD 卡损坏。务必使用合格的电源适配器,避免使用手机充电器。
UPS 不间断电源
推荐为 7×24 运行的树莓派配备 UPS HAT:
bash
# 安装 UPS 监控工具(以 PiSugar 为例)
curl -fsSL https://cdn.pisugar.com/release/PiSugar-Power-Manager.sh | bash使用场景
智能家居网关
yaml
# 家庭网关配置
gateway:
port: 7681
auto_start: true
# 集成智能家居
tools:
home_assistant:
enabled: true
url: http://homeassistant.local:8123
token: ${HA_TOKEN}
# 接入移动设备节点
nodes:
auto_accept: true24小时在线 Agent
yaml
# 始终在线配置
agent:
always_on: true
automation:
cron:
- name: morning_briefing
schedule: "0 7 * * *"
action: "早上好!今天的天气和日程如下..."
- name: evening_summary
schedule: "0 22 * * *"
action: "今天的工作摘要..."家庭监控中心
将树莓派摄像头作为视觉节点:
bash
# 启动摄像头节点
openclaw node --type camera --device /dev/video0外设接线
USB 麦克风
bash
# 检查是否识别
arecord -l
# 测试录音
arecord -D plughw:1,0 -d 5 test.wav
aplay test.wavUSB 摄像头
bash
# 检查设备
ls /dev/video*
# 测试(需要安装 fswebcam)
sudo apt install fswebcam
fswebcam test.jpg故障排查
| 问题 | 解决方案 |
|---|---|
| 启动缓慢 | 使用 SSD 替代 SD 卡 |
| 内存不足 OOM | 增加 Swap,限制 OpenClaw 内存 |
| SD 卡损坏 | 使用高品质 SD 卡或换 SSD |
| 温度过高 | 安装散热器和风扇,检查通风 |
| Wi-Fi 不稳定 | 使用有线以太网连接 |
| USB 设备不识别 | 检查供电是否充足 |
🇨🇳 中国用户须知
树莓派在中国创客社区非常受欢迎,以下是一些提示:
- 购买渠道:推荐在淘宝授权经销商或 DFRobot、Waveshare 等渠道购买正品
- 系统下载:官方镜像下载较慢,可使用清华大学镜像站:
https://mirrors.tuna.tsinghua.edu.cn/raspberry-pi-os-images/- apt 镜像:使用国内镜像加速系统更新:
bash
sudo sed -i 's/deb.debian.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list- Docker 镜像:配置阿里云 Docker 镜像加速器
