Files
sentinel-home-ai/docs/DEPLOY.md

92 lines
3.7 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.
# 部署指南v3 运动事件驱动架构2026-08-22 同步)
## 1. NAS 端部署 (FAM-Core + FAM-UI + MariaDB)
### 1.1 MariaDB
```bash
# 通过 Synology 套件中心安装 MariaDB10.11unix_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_notifierDSM 凭据走 .env
# 仓库根 .env 提供 DSM_ACCOUNT/DSM_PASSWORD/ORACLE_SYNC_TOKENstart_core.sh 会 source
# 启动(含 Oracle-Sync + MotionNotifier 轮询)
cd /volume1/web/sentinel-home-ai && bash start_core.sh
```
### 1.3 FAM-UIVue3 SPA托管于云服务器 Caddy :80
```bash
cd /Users/ericwyuan/Desktop/Work/sentinel-home-ai/fam-ui # 本地开发机
npm install
npm run build # 产物 fam-ui/dist/
# 部署 dist 到云服务器Caddy 静态目录,/api 经 frp 隧道反代回 NAS
tar czf - fam-ui/dist | ssh -i ~/.ssh/oracle_new ubuntu@129.146.26.249 \
'sudo tar xzf - --strip-components=2 -C /var/www/fam-ui && sudo chown -R ubuntu:ubuntu /var/www/fam-ui'
# 浏览器访问 http://129.146.26.249/Caddy 托管,/api/* 反代 NAS fam-core
```
## 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-Edgesystemd 守护)
```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.serviceRestart=always
sudo systemctl enable fam-edge
sudo systemctl restart fam-edge # 部署代码后必须用 systemctl 重启,勿手动 setsid
```
## 3. 代码同步tar 管道scp 在 NAS 被禁用)
```bash
# NASfam-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'
# Oraclefam-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.26.249 '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"` | >0NAS 推送) |
| Oracle 运动片段 | `ls /opt/fam-edge/motion_clips/` | 存在 motion_*.mp4素材分割产物 |
| Oracle Ollama | `curl http://localhost:11434/api/tags` | 模型列表含 qwen2.5:7b |