safesight-edge/docs/deployment.md
2026-02-25 19:21:17 +08:00

216 lines
4.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# RK3588 Media Server 部署指南
## 架构说明
```
┌─────────────────┐ ┌─────────────────┐
│ Media Server │ │ RK3588 Agent │
│ (systemd) │◄────│ (systemd) │
│ 高可用独立服务 │ │ 监控/控制 │
└─────────────────┘ └─────────────────┘
│ │
▼ ▼
RTSP 输出流 Web 管理界面
HLS 输出流 http://IP:9100
```
- **Media Server**: 独立的 systemd 服务,高可用(崩溃自动重启)
- **Agent**: 独立的 systemd 服务,通过 `systemctl` 监控和控制 Media Server
- **两者可独立重启**: 重启 Agent 不会影响 Media Server
---
## 快速开始
### 1. 编译
在 RK3588 设备上编译:
```bash
cd ~/apps/OrangePi3588Media
# 编译 Media Server
mkdir -p build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j$(nproc)
# 编译 Agent
cd ../agent
go build -o rk3588-agent_linux_arm64 ./cmd/rk3588-agent
```
### 2. 安装
```bash
cd ~/apps/OrangePi3588Media
sudo ./scripts/manage.sh install
```
安装过程会提示选择**配置文件**
- `test_cam1_face_det_rtsp_server.json` - 人脸检测(推荐)
- `sample_cam1_native_rtsp_face.json` - 完整功能
- `test_cam1_face_det_recog_rtsp_server.json` - 人脸识别
- `sample_cam1.json` - 完整功能(需手动修复)
### 3. 查看状态
```bash
sudo ./scripts/manage.sh status
```
显示内容:
- 系统运行时间
- NPU 负载
- Media Server 状态PID、CPU/内存、端口)
- Agent 状态
- 最近日志
### 4. 卸载
```bash
sudo ./scripts/manage.sh uninstall
```
---
## 升级
```bash
cd ~/apps/OrangePi3588Media
# 1. 拉取最新代码
git pull
# 2. 重新编译
mkdir -p build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j$(nproc)
cd ../agent
go build -o rk3588-agent_linux_arm64 ./cmd/rk3588-agent
# 3. 重新安装
cd ..
sudo ./scripts/manage.sh install
```
---
## 管理命令
### Media Server独立服务
```bash
# 启动/停止/重启
sudo systemctl start media-server
sudo systemctl stop media-server
sudo systemctl restart media-server
# 查看状态
sudo systemctl status media-server
# 查看日志
sudo journalctl -u media-server -f
```
### Agent独立服务
```bash
# 启动/停止/重启(不影响 Media Server
sudo systemctl start rk3588-agent
sudo systemctl stop rk3588-agent
sudo systemctl restart rk3588-agent
# 查看状态
sudo systemctl status rk3588-agent
# 查看日志
sudo journalctl -u rk3588-agent -f
```
### Web 管理界面
```
http://<设备IP>:9100
```
功能:
- 查看 Media Server 运行状态
- 启动/停止/重启 Media Server通过 systemctl
- 查看配置信息
---
## 配置修改
编辑配置文件:
```bash
sudo nano /opt/rk3588-media-server/etc/media-server.json
```
修改后重启 Media Server
```bash
sudo systemctl restart media-server
```
---
## 目录结构
```
/opt/rk3588-media-server/
├── bin/
│ ├── media-server # 主程序
│ └── plugins/ # 插件
├── etc/
│ └── media-server.json # 配置文件
├── models/ # AI 模型
├── logs/ # 日志
└── web/hls/ # HLS 输出
/opt/rk3588-agent/
├── rk3588-agent # Agent 程序
└── agent.config.json # Agent 配置
```
---
## 故障排查
### 服务无法启动
```bash
# Media Server 错误
sudo journalctl -u media-server -n 50
# Agent 错误
sudo journalctl -u rk3588-agent -n 50
```
### 检查 NPU
```bash
cat /sys/kernel/debug/rknpu/load
ls /dev/rknpu
```
### RTSP 测试
```bash
# 本地测试
ffplay rtsp://localhost:8555/live/cam1_face_det
# 远程测试
ffplay rtsp://<设备IP>:8555/live/cam1_face_det
```
---
## 系统要求
- **硬件**: Orange Pi 5 Plus (RK3588)
- **系统**: Ubuntu 22.04 LTS (ARM64)
- **依赖**: RKNN Runtime, MPP, FFmpeg