92 lines
3.7 KiB
Markdown
92 lines
3.7 KiB
Markdown
# 部署指南(v3 运动事件驱动架构,2026-08-22 同步)
|
||
|
||
## 1. NAS 端部署 (FAM-Core + FAM-UI + MariaDB)
|
||
|
||
### 1.1 MariaDB
|
||
```bash
|
||
# 通过 Synology 套件中心安装 MariaDB(10.11),unix_socket=/run/mysqld/mysqld10.sock
|
||
|
||
# 执行 DDL
|
||
python3 scripts/init_db.py --host 127.0.0.1 --port 3306 --user root --password <密码>
|
||
```
|
||
|
||
### 1.2 FAM-Core
|
||
```bash
|
||
cd /volume1/web/sentinel-home-ai/fam-core
|
||
python3 -m venv venv
|
||
source venv/bin/activate
|
||
pip install -r requirements.txt
|
||
|
||
# 配置
|
||
cp config/config.yaml.example config/config.yaml
|
||
# 编辑 config.yaml:数据库密码、oracle_sync.base_url/token、motion_notifier(DSM 凭据走 .env)
|
||
|
||
# 仓库根 .env 提供 DSM_ACCOUNT/DSM_PASSWORD/ORACLE_SYNC_TOKEN(start_core.sh 会 source)
|
||
|
||
# 启动(含 Oracle-Sync + MotionNotifier 轮询)
|
||
cd /volume1/web/sentinel-home-ai && bash start_core.sh
|
||
```
|
||
|
||
### 1.3 FAM-UI(Vue3 SPA,无独立进程)
|
||
```bash
|
||
cd /Users/ericwyuan/Desktop/Work/sentinel-home-ai/fam-ui # 本地开发机
|
||
npm install
|
||
npm run build # 产物 fam-ui/dist/
|
||
# 部署 dist 到 NAS(构建产物不入库):
|
||
tar czf - fam-ui/dist | ssh -p 2222 ericwyuan@192.168.50.64 \
|
||
'cd /volume1/web/sentinel-home-ai && rm -rf fam-ui/dist && tar xzf -'
|
||
# 浏览器访问 http://192.168.50.64:8000(由 FAM-Core static_app.py 托管,Vue Router history 回退)
|
||
```
|
||
|
||
## 2. Oracle 端部署 (FAM-Edge + Ollama + FFmpeg)
|
||
|
||
### 2.1 系统依赖
|
||
```bash
|
||
sudo apt update && sudo apt install -y ffmpeg python3-opencv
|
||
|
||
# Ollama + qwen2.5:7b(纯文本,仅问答兜底)
|
||
curl -fsSL https://ollama.com/install.sh | sh
|
||
systemctl enable ollama && systemctl start ollama
|
||
ollama pull qwen2.5:7b
|
||
```
|
||
|
||
### 2.2 FAM-Edge(systemd 守护)
|
||
```bash
|
||
cd /opt/fam-edge
|
||
python3 -m venv venv
|
||
source venv/bin/activate
|
||
pip install -r requirements.txt
|
||
|
||
# 配置:config/config.yaml(素材目录/DB/模型/motion_segment);.env 提供 ORACLE_SYNC_TOKEN/GEMINI_API_KEY*/NVIDIA_API_KEY
|
||
|
||
# systemd 服务(已配置 /etc/systemd/system/fam-edge.service,Restart=always)
|
||
sudo systemctl enable fam-edge
|
||
sudo systemctl restart fam-edge # 部署代码后必须用 systemctl 重启,勿手动 setsid
|
||
```
|
||
|
||
## 3. 代码同步(tar 管道,scp 在 NAS 被禁用)
|
||
|
||
```bash
|
||
# NAS(fam-core):仓库根即部署根,直接解包
|
||
tar czf - --exclude=venv --exclude=__pycache__ fam-core | \
|
||
ssh -p 2222 ericwyuan@192.168.50.64 'tar xzf - -C /volume1/web/sentinel-home-ai'
|
||
|
||
# Oracle(fam-edge):/opt/fam-edge 是 fam-edge 根,--strip-components=1 解临时目录再 cp
|
||
tar czf - --exclude=venv --exclude=__pycache__ --exclude=data --exclude=gdrive_videos fam-edge | \
|
||
ssh ubuntu@129.146.203.203 'mkdir -p /opt/fam-edge/tmp_d && tar xzf - --strip-components=1 -C /opt/fam-edge/tmp_d && \
|
||
cp -rf /opt/fam-edge/tmp_d/* /opt/fam-edge/ && rm -rf /opt/fam-edge/tmp_d && sudo systemctl restart fam-edge'
|
||
```
|
||
|
||
## 4. 验证清单
|
||
|
||
| 项目 | 命令 | 预期 |
|
||
|------|------|------|
|
||
| NAS MariaDB | `mysql -u root -p -e "SHOW DATABASES"` | 包含 sentinel_home_ai |
|
||
| NAS FAM-Core | `curl http://localhost:8000/health` | `{"status":"ok"}` |
|
||
| NAS 运动监测 | `curl http://localhost:8000/api/ss/status` | `poll_enabled: true, running: true` |
|
||
| NAS FAM-UI | 浏览器访问 `http://192.168.50.64:8000` | Vue3 SPA(时间轴/人物管理/统计) |
|
||
| Oracle FAM-Edge | `curl http://localhost:5000/health` | `{"status":"ok","queue_alive":true}` |
|
||
| Oracle 运动事件 | `sqlite3 /opt/fam-edge/data/oracle.db "SELECT COUNT(*) FROM ss_motion_events"` | >0(NAS 推送) |
|
||
| Oracle 运动片段 | `ls /opt/fam-edge/motion_clips/` | 存在 motion_*.mp4(素材分割产物) |
|
||
| Oracle Ollama | `curl http://localhost:11434/api/tags` | 模型列表含 qwen2.5:7b |
|