REI3 3.13.1 常用 CLI 命令与工具详解
REI3 3.13.1 命令行工具详解:r3 全部 16 个启动参数(服务安装/启停/卸载/-run 控制台/-newadmin 账号恢复)与配套 systemctl/journalctl/pg_dump 备份恢复/sha256 校验,全部实测回显。
REI3 3.13.1 常用 CLI 命令与工具详解
目标:系统梳理 REI3 平台的命令行工具集——
r3单二进制的全部 16 个启动参数(服务安装/启停/卸载、控制台运行、管理员恢复等)以及日常运维必用的配套命令(systemd 状态与日志、pg_dump/pg_restore 备份恢复、安装包校验)。全部命令与回显均在 Ubuntu 22.04 + REI3 3.13.1 环境实测照抄。
一、环境信息
- 操作系统:Ubuntu 22.04.5 LTS(x86_64)
- REI3 版本:3.13.1(实测二进制自报
v3.13.1.7204) - 数据库:PostgreSQL 16.15(本机 5432,库名/角色均为 app)
- 安装目录:
/opt/rei3/,服务单元rei3.service - 演示账号:
root/q1w2e3r4(-newadmin创建)、数据库口令q1w2e3r4 - 文中时间戳(如
I: 04:17:02)为实测环境的真实回显,读者执行时为当时时间
二、工具概览
REI3 的运维入口极简:平台本体就是一个可执行文件 r3,安装、启停、卸载、管理员恢复全部通过它的启动参数完成,没有独立的管理 CLI。直接运行 r3(或任何未识别参数)会打印完整参数表——以下为实测原文(/opt/rei3 目录下执行 ./r3,回显节选自实测首尾):
Available parameters:
-config string
Location of configuration file (combined with -run) (default "config.json")
-debug
Logs all events regardless of configured log level (combined with -run)
-dynamicport
Start with a port provided by the operating system (combined with -run)
-http
Start with HTTP (not encrypted, for testing/development only, combined with -run)
-imagemagick string
Alternative location for the ImageMagick convert utility
-install
Install REI3 service
-keepworkdir
Do not change working directory to directory of executable
-newadmin string
Create new admin user (username:password), password must not contain spaces or colons
-open
Open URL of REI3 in default browser (combined with -run)
-run
Run REI3 from within this console (see 'config.json' for configuration)
-servicename string
Specify name of service to manage (to (un)install, start or stop service) (default "REI3")
-setdata string
Write to config file: Data directory (platform files and database if stand-alone)
-start
Start REI3 service
-stop
Stop REI3 service
-uninstall
Uninstall REI3 service
-wwwpath string
(Development) Use web files from given path instead of embedded ones
################################################################################
This is the executable of REI3, the open low-code platform, v3.13.1.7204
Copyright (c) 2019-2026 Gabriel Victor Herbert
REI3 can be installed as service (-install) or run from the console (-run).
When REI3 is running, use any modern browser to access it (port 443 by default).
For installation instructions, please refer to the included README file or visit
https://rei3.de/en/docs/admin/ for the full admin documentation.
################################################################################
See above for available parameters. Press enter to return.
💡 说明:REI3 没有独立的版本子参数(
-version会报flag provided but not defined),版本号可从上述横幅获取,或查看官方下载页。
日常运维配套命令分工:
| 工具 | 用途 | 本文章节 |
|---|---|---|
| r3 -install/-uninstall/-start/-stop | 服务生命周期管理 | 4.1 |
| r3 -run/-http/-dynamicport/-config 等 | 控制台运行与调试 | 4.2 |
| r3 -newadmin | 管理员账号恢复 | 4.3 |
| systemctl / journalctl | 服务状态与日志(服务以 systemd 托管后首选) | 5.1 |
| pg_dump / pg_restore | 数据库级完整备份与恢复(官方推荐) | 5.2 |
| sha256sum | 安装包完整性校验 | 5.3 |
三、前置条件
- 已按安装指南完成 REI3 安装(服务已注册或至少二进制就位于
/opt/rei3/r3); - 服务管理类参数需要 root/sudo 权限(写
/etc/systemd/system/); -newadmin必须在服务停止时执行;- 数据库备份命令需要
postgresql-client工具包与数据库口令。
四、r3 参数详解
以下按使用频率分组,每组先给语法与语义,再给实测回显。所有命令在 /opt/rei3 目录下执行(r3 默认在工作目录找 config.json,或用 -config 指定路径)。
4.1 服务生命周期管理
(1)安装服务 -install:注册 systemd 服务单元(默认服务名 REI3,实际单元文件为小写 rei3.service)并设置为开机自启。实测:
cd /opt/rei3
sudo ./r3 -install
I: 04:17:12 service was successfully installed
systemctl list-unit-files | grep -i rei3
rei3.service enabled enabled
⚠️ 重要(实测两次复现):
-install生成的单元ExecStart=/opt/rei3/r3不带-run,导致服务启动后立即打印参数表退出、状态停在activating (auto-restart)。每次安装后需手工补参数并重载(详见安装指南 4.5 节排障实录):sudo sed -i 's|ExecStart=/opt/rei3/r3$|ExecStart=/opt/rei3/r3 -run|' /etc/systemd/system/rei3.service sudo systemctl daemon-reload
(2)启动/停止服务 -start / -stop:等效于 systemctl start/stop rei3,可直接以普通用户执行(服务名默认 REI3)。实测:
cd /opt/rei3
./r3 -start
I: 04:17:03 service was successfully started
./r3 -stop
I: 04:17:06 service was successfully stopped
(3)卸载服务 -uninstall:移除服务单元(不动程序文件与数据)。实测:
cd /opt/rei3
sudo ./r3 -uninstall
I: 04:17:12 service was successfully uninstalled
systemctl list-unit-files | grep -i rei3
(无输出,单元已移除)
(4)自定义服务名 -servicename:配合安装/卸载参数使用,实现单机多实例(不同目录、不同服务名、不同端口与数据库)。实测安装第二个服务实例:
cd /opt/rei3
sudo ./r3 -install -servicename rei3-test
systemctl list-unit-files | grep -i rei3
I: 04:17:12 service was successfully installed
rei3-test.service enabled enabled
rei3.service enabled enabled
对不存在的服务名执行卸载会得到错误回显(实测):
sudo ./r3 -uninstall -servicename rei3-test
I: 04:17:12 service was successfully uninstalled
(再执行一次,服务已不存在时)
E: 04:17:12 exit status 1
💡 说明:
-servicename默认值为REI3;多实例时每个实例需要独立的安装目录与 config.json(-config指定),服务名仅区分 systemd 单元。
4.2 控制台运行与调试
(1)控制台运行 -run:以前台进程方式启动平台(读取 -config 指定的配置文件),是排障时的首选运行方式。实测启动日志:
cd /opt/rei3
timeout 14 ./r3 -run
Starting web server for '0.0.0.0:443'...
Shutting down...
(timeout 14 到期终止进程产生 Shutting down...,正常前台运行按 Ctrl+C 结束)
(2)明文 HTTP 模式 -http:与 -run 组合使用,跳过 TLS 以 HTTP 启动——参数表明确标注 for testing/development only(仅测试开发用)。实测:
cd /opt/rei3
timeout 14 ./r3 -run -http -dynamicport
Starting web server for '0.0.0.0:0'...
Shutting down...
(3)动态端口 -dynamicport:与 -run 组合,忽略 config 中的端口由操作系统分配(配合 -http 使用如上,日志中显示为 0,实际端口可从启动日志或 ss -ltnp 确认)。
(4)指定配置文件 -config:与 -run 组合,指定配置文件路径(默认取当前目录 config.json):
cd /opt/rei3
sudo ./r3 -run -config /etc/rei3/config.json
(5)调试日志 -debug:与 -run 组合,忽略配置的日志级别输出全部事件,排障时使用。
(6)其余开发辅助参数(参数表原文语义,调试时可用):
-keepworkdir:不把工作目录切换到可执行文件所在目录(默认会切换);-open:与-run组合,启动后在默认浏览器打开 REI3 首页(Windows 便携场景常用);-wwwpath:开发用,使用指定路径的 Web 前端文件替代二进制内嵌文件;-imagemagick:指定 ImageMagick convert 工具的替代路径(非标准安装位置时使用);-setdata:把指定数据目录写入 config 文件(stand-alone 模型迁移数据目录时用)。
4.3 管理员账号恢复 -newadmin
忘记管理员口令或失去全部管理员访问时,停服后用 -newadmin 用户名:口令 创建新管理员(用户名不能与现有用户重复,口令不能含空格或冒号)。实测:
sudo systemctl stop rei3
systemctl is-active rei3
cd /opt/rei3
sudo ./r3 -newadmin root:q1w2e3r4
inactive
I: 04:17:02 successfully created new admin user
Shutting down...
重启服务后即可用新账号登录(实测):
sudo systemctl start rei3
systemctl is-active rei3
active
五、配套工具命令详解
5.1 服务状态与日志
服务以 systemd 托管后,日常状态与日志查询走 systemctl/journalctl(实测回显):
systemctl is-active rei3
active
systemctl is-enabled rei3
enabled
journalctl -u rei3 --no-pager -n 6
Oct 24 04:10:53 rei3-server systemd[1]: Started Provides the REI3 platform components.
Oct 24 04:10:53 rei3-server systemd[1]: rei3.service: Deactivated successfully.
Oct 24 04:12:01 rei3-server systemd[1]: Stopped Provides the REI3 platform components.
Oct 24 04:12:01 rei3-server systemd[1]: Started Provides the REI3 platform components.
Oct 24 04:17:00 rei3-server systemd[1]: Stopping Provides the REI3 platform components...
Oct 24 04:17:00 rei3-server systemd[1]: rei3.service: Deactivated successfully.
💡 说明:REI3 自身运行日志同样可在管理面板的 System logs 页面查看;systemd journal 主要覆盖启动、退出与崩溃类事件。证书加载失败等启动问题按官方文档要求查 syslog/journal。
5.2 数据库备份与恢复(pg_dump / pg_restore)
REI3 的完整备份 = 数据库 + config.json + certificates/files/transfer 目录(官方 Backup and recovery 一节清单)。数据库部分官方推荐用 PostgreSQL 原生工具做目录格式全量备份。实测备份(-Fd 目录格式,口令经环境变量传入):
export PGPASSWORD='q1w2e3r4'
pg_dump -h localhost -p 5432 -U app -Fd -f /tmp/appdump app
(无输出即成功)核对产物(实测回显):
ls /tmp/appdump | head -5
du -sh /tmp/appdump
5229.dat.gz
5230.dat.gz
5231.dat.gz
5232.dat.gz
5233.dat.gz
1.1M /tmp/appdump
恢复官方命令模式(恢复到空库,实测于安装指南同环境可复用;--no-owner 保证以目标库属主身份恢复):
export PGPASSWORD='q1w2e3r4'
pg_restore -h localhost -p 5432 --no-owner -U app -d app /tmp/appdump
官方备份实践建议(Admin 文档原文语义):备份应保存到独立网络位置;恢复时始终针对空库/新库进行,确认数据完整后再切换 config.json 指向。
💡 技术拓展:PostgreSQL 备份格式取舍——
格式 参数 特点 目录格式 -Fd 并行恢复友好、分片压缩,本文采用 自定义格式 -Fc 单文件、可选并行恢复 纯 SQL -Fp 可读可手工编辑,大库恢复慢 REI3 内建备份功能(管理面板启用,依赖 postgresql-client)只能做全量备份;数据量增大后官方建议转用 pg_dump/pg_restore 自建增量/差异流程。
5.3 安装包完整性校验(sha256sum)
升级或离线部署时,下载包先校验再安装(实测):
sha256sum REI3_3.13.1_x64_linux.tar.gz
7bd3cb53f374bc67aa6a8cff763e7188b472e25212033c1d379f280492748661 REI3_3.13.1_x64_linux.tar.gz
六、注意事项
-install后必须修复 ExecStart(缺-run),且卸载重装会复现,详见 4.1 节警示;-newadmin仅在服务停止时可用,且新建用户名不可与现有用户重复;-http只用于测试:明文传输无 TLS,生产一律走 HTTPS(config 默认);-servicename多实例:注意每个实例的 config.json 指向不同的数据库与数据目录,端口也不能冲突;- 升级时先备份:数据库不可降级,升级流程为停服 → 覆盖解压新版本文件 → 修复 ExecStart(如重装过服务)→ 启动(官方 Updates 一节流程);
- 普通用户可执行
-start/-stop:它们走 systemd 服务接口;而-install/-uninstall写系统目录需要 sudo。
七、常见问题(FAQ)
Q1:./r3 -version 报错 flag provided but not defined?
REI3 没有版本参数;版本号看参数表下方横幅(v3.13.1.7204)或 r3 无参数输出,也可查官方下载页。
Q2:-start 提示成功但服务很快又停了?
先看 journalctl -u rei3:若出现 Deactivated successfully 且 status 显示 status=0/SUCCESS,即 4.1 节所述 ExecStart 缺 -run 问题,按修复步骤处理;若为其他退出码,结合 -run 前台运行观察完整日志定位。
Q3:控制台 -run 启动时卡在数据库连接?
核对 config.json 的 db 段与实际 PostgreSQL 状态(pg_lsclusters 看 online、psql 手工连一次),多为口令/主机/端口笔误。
Q4:备份恢复后登录不了?
官方建议恢复到新库再切换 config.json 的 db.name;直接覆盖原库时注意 --no-owner 与账号权限,必要时用 -newadmin 重建管理员。
八、参考链接
- 官方 Admin 文档(Backup and recovery / Updates 章节):https://rei3.de/en/docs/admin
- 官方下载页:https://rei3.de/en/downloads
- pg_dump 官方手册:https://www.postgresql.org/docs/16/app-pgdump.html
- pg_restore 官方手册:https://www.postgresql.org/docs/16/app-pgrestore.html
- 本专栏系列:《REI3 3.13.1 介绍与选型指南》、《Ubuntu 22.04 安装 REI3 3.13.1 指南》、《REI3 3.13.1 配置参数详解》