Nexus Edge OS 离线部署指南 (ARM64/x86_64)
本指南适用于无法连接互联网的工控机环境,支持 ARM64(如树莓派、RK3588)和 x86_64(如 Intel/AMD 工控机)。
1. 准备工作 (在有网的电脑上操作)
你需要一台可以上网的电脑(Mac/Linux/Windows WSL)来准备离线安装包。
1.1 拉取对应架构的镜像
请根据目标工控机的 CPU 架构选择对应的拉取命令。我们需要拉取业务服务以及 watchtower(用于内网环境下的 OTA 更新)。
方案 A:针对 ARM64 架构 (如树莓派、RK3588)
# 显式指定拉取 arm64 架构镜像
docker pull --platform linux/arm64 justinzhq/nexus-edge-os:latest
docker pull --platform linux/arm64 eclipse-mosquitto:2
docker pull --platform linux/arm64 containrrr/watchtower方案 B:针对 x86_64 架构 (如 Intel/AMD 工控机)
# 显式指定拉取 amd64 架构镜像
docker pull --platform linux/amd64 justinzhq/nexus-edge-os:latest
docker pull --platform linux/amd64 eclipse-mosquitto:2
docker pull --platform linux/amd64 containrrr/watchtower1.2 导出镜像包
将拉取到的镜像保存为 .tar 文件。
导出 ARM64 包:
docker save -o nexus-arm64-images.tar \
justinzhq/nexus-edge-os:latest \
eclipse-mosquitto:2 \
containrrr/watchtower导出 x86_64 包:
docker save -o nexus-amd64-images.tar \
justinzhq/nexus-edge-os:latest \
eclipse-mosquitto:2 \
containrrr/watchtower1.3 整理部署目录
创建一个文件夹(例如 nexus-deploy),放入以下文件:
- 镜像包:
nexus-arm64-images.tar或nexus-amd64-images.tar - 配置文件:
apps/edge-os/docker-compose.yml(从项目中复制)apps/edge-os/mosquitto/文件夹 (从项目中复制mosquitto/config/mosquitto.conf)
- 安装脚本:
install.sh(见下方脚本)
1.4 修改 docker-compose.yml (关于 Watchtower)
在离线环境或内网环境中,建议保留 Watchtower 服务。
如果未来需要在内网进行 OTA 更新,你可以搭建私有的 Docker Registry(如 Harbor 或简单的 Registry 容器),并修改 docker-compose.yml 让服务指向该私有仓库。Watchtower 将自动监测私有仓库的更新并同步到边缘设备。
2. 编写通用安装脚本 (install.sh)
该脚本会自动检测当前目录下存在的镜像包并加载。
在部署目录中创建 install.sh:
#!/bin/bash
# 颜色定义
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
echo -e "${GREEN}=== Nexus Edge OS 离线安装程序 ===${NC}"
# 1. 检查 Docker 是否安装
if ! command -v docker &> /dev/null; then
echo "错误: 未检测到 Docker。请先在工控机上安装 Docker 和 Docker Compose。"
exit 1
fi
# 2. 自动检测并导入镜像
IMAGE_LOADED=false
if [ -f "nexus-arm64-images.tar" ]; then
echo -e "${YELLOW}检测到 ARM64 镜像包,正在导入...${NC}"
docker load -i nexus-arm64-images.tar
IMAGE_LOADED=true
elif [ -f "nexus-amd64-images.tar" ]; then
echo -e "${YELLOW}检测到 x86_64 (AMD64) 镜像包,正在导入...${NC}"
docker load -i nexus-amd64-images.tar
IMAGE_LOADED=true
else
echo "错误: 未找到镜像包 (nexus-arm64-images.tar 或 nexus-amd64-images.tar)。"
exit 1
fi
if [ "$IMAGE_LOADED" = true ]; then
echo -e "${GREEN}镜像导入成功!${NC}"
fi
# 3. 启动服务
echo "正在启动服务..."
# 确保 mosquitto 配置目录权限 (可选)
mkdir -p mosquitto/data mosquitto/log
chmod -R 777 mosquitto/data mosquitto/log
# 启动容器 (后台运行)
docker compose up -d
echo -e "${GREEN}=== 安装完成 ===${NC}"
echo "请访问: http://localhost:8080"
echo "MQTT 端口: 1883"3. 现场部署 (在工控机上操作)
假设你已经将部署包拷贝到 U 盘,并将 U 盘插入了工控机。
3.1 SSH 登录工控机
# 替换为工控机的实际 IP 地址和用户名
ssh username@192.168.1.1003.2 挂载 U 盘并拷贝文件
# 1. 查看 U 盘设备名 (通常是 /dev/sda1 或 /dev/sdb1,根据容量判断)
lsblk
# 2. 创建挂载点
sudo mkdir -p /mnt/usb
# 3. 挂载 U 盘 (注意:请将 /dev/sda1 替换为上一步查到的实际设备名)
sudo mount /dev/sda1 /mnt/usb
# 4. 将部署包拷贝到当前用户的主目录
cp -r /mnt/usb/nexus-deploy ~/nexus-deploy
# 5. 卸载 U 盘 (可选)
sudo umount /mnt/usb3.3 执行安装
# 1. 进入部署目录
cd ~/nexus-deploy
# 2. 赋予脚本执行权限
chmod +x install.sh
# 3. 运行安装脚本 (建议使用 sudo 以确保 Docker 权限)
sudo ./install.shLast updated on