Skip to content

Latest commit

 

History

History
120 lines (83 loc) · 3.9 KB

install.md

File metadata and controls

120 lines (83 loc) · 3.9 KB

安装与部署

系统要求

  • Linux x86_64 或 arm64,内核 3.10+(CentOS 7 / Ubuntu 16.04 / Debian 9 及更高)
  • Windows 10 / Windows Server 2016 及更高(amd64,见文末); 不支持 Windows 7 / 8、Windows Server 2008 / 2012(运行时在上述系统无法启动)
  • Mosquitto(MQTT Broker)与 Redis,可同机部署
  • 所需端口未被占用:8899(Web)、443(APP/小程序接入)、 1888/2888(控制台接入)、1800(本机 broker,可配)

一键安装(Linux)

curl -fsSL https://github.com/ThingBoot/thingboot-cloud-node/releases/latest/download/install.sh | sudo bash

安装脚本行为:

  1. 探测 CPU 架构(amd64/arm64,其他架构报错退出),查询最新版本;
  2. 下载对应发行包并校验 sha256;
  3. 解压到 /opt/thingboot;
  4. 创建独立运行用户 thingboot;
  5. setcap cap_net_bind_service 授权二进制绑定 443 等特权端口(无需 root 运行);
  6. 写入并启动 systemd 服务 thingboot (ExecStart=/opt/thingboot/thingboot -config /opt/thingboot/configs/config.yaml serve, 崩溃自动重启)。

安装结束后会打印 Web 管理界面地址(http://<本机IP>:8899)。

指定版本

curl -fsSL https://github.com/ThingBoot/thingboot-cloud-node/releases/latest/download/install.sh | sudo bash -s v1.2.3

或下载脚本后执行:

bash install.sh v1.2.3

自建镜像

下载地址是变量,可整体切换到自建镜像(镜像需保持 <地址>/v<版本>/thingboot-cloud-node_<版本>_linux_<架构>.tar.gz 的目录结构):

bash install.sh v1.2.3   # 先导出镜像地址
THINGBOOT_DOWNLOAD_BASE=https://mirror.example.com/releases bash install.sh v1.2.3

镜像不提供校验文件时可用 THINGBOOT_SKIP_SHA256=1 跳过 sha256 校验。

其他可调环境变量:THINGBOOT_INSTALL_DIR(安装目录,默认 /opt/thingboot)。

首次启动

服务以 thingboot serve 运行:supervisor 拉起全部 16 个功能模块(各自独立进程, 崩溃自动重启),同时启动 Web 管理界面(默认 0.0.0.0:8899)。

首次启动生成随机管理员密码,只在日志中出现一次:

journalctl -u thingboot -n 50
# 或查看日志文件
ls /opt/thingboot/logs/

打开 http://<服务器IP>:8899,用该密码登录(首登后请立即修改)。

体检

安装后运行 thingboot doctor 逐项检查:配置文件、broker/Redis/平台连通性、 端口占用、license 状态,全部 ✓ 即可投入使用。

升级

重跑一键安装命令(或 bash install.sh v<新版本>)即可:覆盖二进制并自动重启服务, 配置与数据保留在 /opt/thingboot。

卸载

bash install.sh uninstall

卸载会停止并禁用 systemd 服务、删除 unit 文件,然后询问是否删除 /opt/thingboot(含配置与数据,默认保留;管道方式执行时无法交互,默认保留)。 确认全删可用:

THINGBOOT_PURGE=1 bash install.sh uninstall

运行用户 thingboot 不会被删除,如需清理:userdel thingboot。

Windows

  1. 从 Releases 下载 thingboot-cloud-node_<版本>_windows_amd64.zip,解压到 例如 C:\thingboot;
  2. 管理员 PowerShell 中注册并启动系统服务:
cd C:\thingboot
.\thingboot.exe service install
.\thingboot.exe service start

服务的卸载/停止:.\thingboot.exe service stop / .\thingboot.exe service uninstall (卸载会先停止再删除服务);另有 status 查看状态、restart 重启。 前台调试可直接运行 .\thingboot.exe serve。

使用非默认配置文件时加 -config,安装时会记录为绝对路径:

.\thingboot.exe -config D:\conf\config.yaml service install

注册/启停/卸载服务均需管理员权限,否则命令会报错并提示以管理员身份运行。