Initial commit: Momentry Core v0.1
- Rust-based digital asset management system - Video analysis: ASR, OCR, YOLO, Face, Pose - RAG capabilities with Qdrant vector database - Multi-database support: PostgreSQL, Redis, MongoDB - Monitoring system with launchd plists - n8n workflow automation integration
This commit is contained in:
388
monitor/SKILL_TROUBLESHOOTING.md
Normal file
388
monitor/SKILL_TROUBLESHOOTING.md
Normal file
@@ -0,0 +1,388 @@
|
||||
# Momentry 服務故障排除 Skill
|
||||
|
||||
## 概述
|
||||
|
||||
此 Skill 提供常見服務問題的快速診斷參考,包含問題類型、檢查命令、日誌位置和常見解決方案。
|
||||
|
||||
---
|
||||
|
||||
## 快速檢查清單
|
||||
|
||||
### 1. 服務狀態檢查
|
||||
|
||||
```bash
|
||||
# 查看所有 momentry 服務狀態
|
||||
launchctl list | grep com.momentry
|
||||
|
||||
# 或執行健康檢查
|
||||
/Users/accusys/momentry_core_0.1/monitor/service/health_check.sh
|
||||
```
|
||||
|
||||
### 2. 端口佔用檢查
|
||||
|
||||
```bash
|
||||
# 檢查特定端口
|
||||
lsof -i :<PORT>
|
||||
|
||||
# 常用端口對照
|
||||
# PostgreSQL: 5432
|
||||
# Redis: 6379
|
||||
# MariaDB: 3306
|
||||
# n8n: 8085 (內部), 5678 (舊配置)
|
||||
# Caddy Admin: 2019
|
||||
# Ollama: 11434
|
||||
# Qdrant: 6333
|
||||
# SFTPGo: 8080 (HTTP), 2022 (SFTP)
|
||||
# Gitea: 3000
|
||||
# PHP-FPM: 9000
|
||||
# RustDesk: 21115-21119
|
||||
# MongoDB: 27017
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 服務詳細診斷
|
||||
|
||||
### PostgreSQL
|
||||
|
||||
**配置文件**: `/Users/accusys/momentry/etc/postgresql/`
|
||||
**數據目錄**: `/Users/accusys/momentry/var/postgresql/`
|
||||
**日誌**: `/Users/accusys/momentry/log/postgresql.log`
|
||||
|
||||
| 問題 | 檢查命令 | 解決方案 |
|
||||
|------|----------|----------|
|
||||
| 連線失敗 | `pg_isready -h localhost -p 5432 -U accusys` | 檢查 plist 是否載入 |
|
||||
| 認證錯誤 | `psql -U accusys -h localhost -d momentry -c "SELECT 1"` | 檢查 pg_hba.conf |
|
||||
| 效能問題 | `psql -U accusys -h localhost -d momentry -c "SELECT * FROM pg_stat_activity"` | 檢查連線數 |
|
||||
| 資料庫不存在 | `psql -U accusys -h localhost -l` | 創建數據庫 |
|
||||
|
||||
```bash
|
||||
# 創建數據庫
|
||||
createdb -U accusys momentry
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Redis
|
||||
|
||||
**配置文件**: `/opt/homebrew/etc/redis.conf`
|
||||
**數據目錄**: `/Users/accusys/momentry/var/redis/`
|
||||
**日誌**: `/Users/accusys/momentry/log/redis.log`
|
||||
|
||||
| 問題 | 檢查命令 | 解決方案 |
|
||||
|------|----------|----------|
|
||||
| 連線失敗 | `redis-cli -a accusys ping` | 檢查密碼是否正確 |
|
||||
| 認證錯誤 | `redis-cli -a accusys AUTH accusys` | 檢查密碼配置 |
|
||||
| 記憶體過高 | `redis-cli -a accusys INFO memory` | 檢查 keys 數量 |
|
||||
| 持久化失敗 | `redis-cli -a accusys LASTSAVE` | 檢查 RDB 配置 |
|
||||
|
||||
```bash
|
||||
# 常用操作
|
||||
redis-cli -a accusys SAVE # 觸發保存
|
||||
redis-cli -a accusys FLUSHALL # 清空所有 keys
|
||||
redis-cli -a accusys KEYS '*' # 查看所有 keys
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### MariaDB
|
||||
|
||||
**配置文件**: `/Users/accusys/momentry/etc/mariadb/`
|
||||
**數據目錄**: `/Users/accusys/momentry/var/mariadb/`
|
||||
**日誌**: `/Users/accusys/momentry/log/mariadb.log`
|
||||
|
||||
| 問題 | 檢查命令 | 解決方案 |
|
||||
|------|----------|----------|
|
||||
| 連線失敗 | `mysql -u accusys -e "SELECT 1"` | 檢查用戶權限 |
|
||||
| 拒絕訪問 | `mysql -u root -e "SELECT user FROM mysql.user"` | 檢查用戶配置 |
|
||||
| 效能問題 | `mysql -u accusys -e "SHOW PROCESSLIST"` | 檢查慢查詢 |
|
||||
|
||||
```bash
|
||||
# 常用操作
|
||||
mysql -u accusys -e "SHOW DATABASES"
|
||||
mysql -u accusys -e "SHOW TABLES" momentry
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### n8n
|
||||
|
||||
**配置文件**: `/Users/accusys/momentry/etc/n8n/`
|
||||
**數據目錄**: `/Users/accusys/momentry/var/n8n/`
|
||||
**日誌**: `/Users/accusys/momentry/log/n8n-main.log`
|
||||
|
||||
| 問題 | 檢查命令 | 解決方案 |
|
||||
|------|----------|----------|
|
||||
| 網頁無法訪問 | `curl -s http://localhost:8085/` | 檢查端口是否正確 |
|
||||
| API 錯誤 | `curl -s http://localhost:8085/healthz` | 檢查服務狀態 |
|
||||
| Workflow 不執行 | 檢查 n8n log | 檢查 queue (Redis) 連線 |
|
||||
| 資料庫連線失敗 | `psql -U n8n -h localhost -d n8n -c "SELECT 1"` | 檢查 PostgreSQL |
|
||||
|
||||
**重要**: n8n 使用 PostgreSQL (非 SQLite),端口為 8085
|
||||
|
||||
```bash
|
||||
# 數據庫連線
|
||||
psql -U n8n -h localhost -d n8n
|
||||
|
||||
# 查看 users
|
||||
psql -U n8n -h localhost -d n8n -c "SELECT id, email, \"firstName\", \"roleSlug\" FROM \"user\";"
|
||||
|
||||
# 查看 workflows
|
||||
psql -U n8n -h localhost -d n8n -c "SELECT id, name, active FROM workflow_entity;"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Ollama
|
||||
|
||||
**配置文件**: `/Users/accusys/momentry/etc/ollama/`
|
||||
**模型目錄**: `/Users/accusys/momentry/var/ollama/`
|
||||
**日誌**: `/Users/accusys/momentry/log/ollama.log`
|
||||
|
||||
| 問題 | 檢查命令 | 解決方案 |
|
||||
|------|----------|----------|
|
||||
| API 無回應 | `curl -s http://localhost:11434/api/tags` | 檢查服務是否啟動 |
|
||||
| 模型下載失敗 | `ollama list` | 重新下載模型 |
|
||||
| 記憶體不足 | `ollama list` | 檢查已加載模型 |
|
||||
|
||||
```bash
|
||||
# 常用操作
|
||||
ollama list # 列出模型
|
||||
ollama pull <model> # 下載模型
|
||||
ollama run <model> <prompt> # 運行模型
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Qdrant
|
||||
|
||||
**配置文件**: `/Users/accusys/momentry/etc/qdrant/`
|
||||
**數據目錄**: `/Users/accusys/momentry/var/qdrant/`
|
||||
**日誌**: `/Users/accusys/momentry/log/qdrant.log`
|
||||
|
||||
| 問題 | 檢查命令 | 解決方案 |
|
||||
|------|----------|----------|
|
||||
| API 無回應 | `curl -s http://localhost:6333/collections` | 需要 API Key |
|
||||
| 認證失敗 | `curl -s -H "api-key: Test3200Test3200" http://localhost:6333/collections` | 檢查 API Key |
|
||||
| 效能問題 | `curl -s http://localhost:6333/cluster` | 檢查叢集狀態 |
|
||||
|
||||
```bash
|
||||
# 需要認證的指令
|
||||
curl -s -H "api-key: Test3200Test3200" http://localhost:6333/collections
|
||||
curl -s -H "api-key: Test3200Test3200" http://localhost:6333/points/count
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Caddy
|
||||
|
||||
**配置文件**: `/Users/accusys/momentry/etc/caddy/`
|
||||
**數據目錄**: `/Users/accusys/momentry/var/caddy/`
|
||||
**日誌**: `/Users/accusys/momentry/log/caddy.log`
|
||||
|
||||
| 問題 | 檢查命令 | 解決方案 |
|
||||
|------|----------|----------|
|
||||
| Admin API 無回應 | `curl -s http://localhost:2019/config/` | 檢查 Caddy 進程 |
|
||||
| 網站無法訪問 | `curl -s -I https://localhost:443/` | 檢查證書配置 |
|
||||
| 代理失敗 | `curl -s http://localhost:2019/config/` | 檢查反向代理配置 |
|
||||
|
||||
```bash
|
||||
# 重新載入配置
|
||||
sudo launchctl unload /Library/LaunchDaemons/com.momentry.caddy.plist
|
||||
sudo launchctl load /Library/LaunchDaemons/com.momentry.caddy.plist
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Gitea
|
||||
|
||||
**配置文件**: `/Users/accusys/momentry/etc/gitea/app.ini`
|
||||
**數據目錄**: `/Users/accusys/momentry/var/gitea/`
|
||||
**日誌**: `/Users/accusys/momentry/log/gitea.log`
|
||||
|
||||
| 問題 | 檢查命令 | 解決方案 |
|
||||
|------|----------|----------|
|
||||
| 網頁無法訪問 | `curl -s http://localhost:3000/` | 檢查服務狀態 |
|
||||
| Git 推送失敗 | `ssh git@localhost -p 22` | 檢查 SSH 配置 |
|
||||
| 資料庫連線 | `mysql -u gitea -p gitea_db -e "SELECT 1"` | 檢查 PostgreSQL |
|
||||
|
||||
---
|
||||
|
||||
### SFTPGo
|
||||
|
||||
**配置文件**: `/Users/accusys/momentry/etc/sftpgo/sftpgo.json`
|
||||
**數據目錄**: `/Users/accusys/momentry/var/sftpgo/`
|
||||
**日誌**: `/Users/accusys/momentry/log/sftpgo.log`
|
||||
|
||||
| 問題 | 檢查命令 | 解決方案 |
|
||||
|------|----------|----------|
|
||||
| Web UI 無法訪問 | `curl -s http://localhost:8080/` | 檢查 HTTP 端口 |
|
||||
| SFTP 連線失敗 | `sftp -P 2022 user@localhost` | 檢查 SSH 密鑰 |
|
||||
| 認證失敗 | `curl -s http://localhost:8080/api/v2/info` | 檢查用戶配置 |
|
||||
|
||||
---
|
||||
|
||||
### PHP-FPM
|
||||
|
||||
**配置文件**: `/Users/accusys/momentry/etc/php/`
|
||||
**日誌**: `/Users/accusys/momentry/log/php.log`
|
||||
|
||||
| 問題 | 檢查命令 | 解決方案 |
|
||||
|------|----------|----------|
|
||||
| PHP 無法執行 | `php -v` | 檢查 PHP 版本 |
|
||||
| FPM 無回應 | `curl -s http://localhost:9000/` | 檢查 FPM 端口 |
|
||||
| 500 錯誤 | `tail -100 /Users/accusys/momentry/log/php.error.log` | 檢查錯誤日誌 |
|
||||
|
||||
---
|
||||
|
||||
### RustDesk
|
||||
|
||||
**配置文件**: `/Users/accusys/momentry/etc/rustdesk/`
|
||||
**日誌**: `/Users/accusys/momentry/log/rustdesk.*.log`
|
||||
|
||||
| 問題 | 檢查命令 | 解決方案 |
|
||||
|------|----------|----------|
|
||||
| 連線失敗 | `nc -z localhost 21116 && nc -z localhost 21117` | 檢查端口 |
|
||||
| ID 伺服器錯誤 | `pgrep -a hbbs` | 檢查 hbbs 進程 |
|
||||
| 中繼伺服器錯誤 | `pgrep -a hbbr` | 檢查 hbbr 進程 |
|
||||
|
||||
---
|
||||
|
||||
### MongoDB
|
||||
|
||||
**配置文件**: `/Users/accusys/momentry/etc/mongodb/`
|
||||
**數據目錄**: `/Users/accusys/momentry/var/mongodb/`
|
||||
**日誌**: `/Users/accusys/momentry/log/mongodb.log`
|
||||
|
||||
| 問題 | 檢查命令 | 解決方案 |
|
||||
|------|----------|----------|
|
||||
| 連線失敗 | `mongosh --quiet --eval "db.adminCommand('ping')"` | 需要認證 |
|
||||
| 認證錯誤 | `mongosh -u accusys -p Test3200Test3200 --authenticationDatabase admin` | 檢查用戶 |
|
||||
| 效能問題 | `mongosh -u accusys -p Test3200Test3200 --eval "db.serverStatus()"` | 檢查狀態 |
|
||||
|
||||
---
|
||||
|
||||
## 服務管理命令
|
||||
|
||||
### 啟動服務
|
||||
|
||||
```bash
|
||||
sudo launchctl load /Library/LaunchDaemons/com.momentry.<service>.plist
|
||||
```
|
||||
|
||||
### 停止服務
|
||||
|
||||
```bash
|
||||
sudo launchctl unload /Library/LaunchDaemons/com.momentry.<service>.plist
|
||||
```
|
||||
|
||||
### 重啟服務
|
||||
|
||||
```bash
|
||||
sudo launchctl unload /Library/LaunchDaemons/com.momentry.<service>.plist
|
||||
sudo launchctl load /Library/LaunchDaemons/com.momentry.<service>.plist
|
||||
```
|
||||
|
||||
### 查看服務日誌
|
||||
|
||||
```bash
|
||||
tail -f /Users/accusys/momentry/log/<service>.log
|
||||
tail -f /Users/accusys/momentry/log/<service>.error.log
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 服務端口對照表
|
||||
|
||||
| 服務 | 內部端口 | 外部端口 | Caddy 域名 |
|
||||
|------|---------|---------|------------|
|
||||
| PostgreSQL | 5432 | 5432 | - |
|
||||
| Redis | 6379 | 6379 | - |
|
||||
| MariaDB | 3306 | 3306 | - |
|
||||
| n8n | 8085 | 443 | n8n.momentry.ddns.net |
|
||||
| Ollama | 11434 | 11434 | - |
|
||||
| Qdrant | 6333 | 443 | qdrant.momentry.ddns.net |
|
||||
| Caddy Admin | 2019 | 2019 | - |
|
||||
| Gitea | 3000 | 443 | gitea.momentry.ddns.net |
|
||||
| SFTPGo | 8080/2022 | 443 | sftpgo.momentry.ddns.net |
|
||||
| PHP-FPM | 9000 | - | - |
|
||||
| MongoDB | 27017 | 27017 | - |
|
||||
| RustDesk | 21115-21119 | 21115-21119 | - |
|
||||
|
||||
---
|
||||
|
||||
## 常見問題快速修復
|
||||
|
||||
### 1. 服務無法啟動
|
||||
|
||||
```bash
|
||||
# 1. 檢查進程
|
||||
pgrep -a <service_name>
|
||||
|
||||
# 2. 檢查端口
|
||||
lsof -i :<PORT>
|
||||
|
||||
# 3. 檢查日誌
|
||||
tail -100 /Users/accusys/momentry/log/<service>.error.log
|
||||
|
||||
# 4. 重新載入
|
||||
sudo launchctl unload /Library/LaunchDaemons/com.momentry.<service>.plist
|
||||
sudo launchctl load /Library/LaunchDaemons/com.momentry.<service>.plist
|
||||
```
|
||||
|
||||
### 2. 認證失敗
|
||||
|
||||
```bash
|
||||
# 檢查用戶是否存在
|
||||
psql -U <db_user> -h localhost -d <db_name> -c "SELECT 1"
|
||||
|
||||
# 檢查密碼
|
||||
# 參考各服務的 INSTALL_*.md 文檔
|
||||
```
|
||||
|
||||
### 3. 效能問題
|
||||
|
||||
```bash
|
||||
# 檢查系統資源
|
||||
top -o cpu
|
||||
top -o mem
|
||||
|
||||
# 檢查磁盤空間
|
||||
df -h
|
||||
|
||||
# 檢查網絡連線
|
||||
netstat -an | grep ESTABLISHED
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 監控腳本位置
|
||||
|
||||
- 健康檢查: `/Users/accusys/momentry_core_0.1/monitor/service/health_check.sh`
|
||||
- PostgreSQL: `/Users/accusys/momentry_core_0.1/monitor/database/postgres_monitor.sh`
|
||||
- Redis: `/Users/accusys/momentry_core_0.1/monitor/database/redis_monitor.sh`
|
||||
- Qdrant: `/Users/accusys/momentry_core_0.1/monitor/database/qdrant_monitor.sh`
|
||||
- MongoDB: `/Users/accusys/momentry_core_0.1/monitor/database/mongodb_monitor.sh`
|
||||
- n8n Workflow: `/Users/accusys/momentry_core_0.1/monitor/workflow/n8n_workflow_monitor.sh`
|
||||
|
||||
---
|
||||
|
||||
## 密碼參考 (請修改為真實密碼)
|
||||
|
||||
| 服務 | 用戶 | 密碼 |
|
||||
|------|------|------|
|
||||
| PostgreSQL | accusys | (无密码) |
|
||||
| PostgreSQL | n8n | accusys |
|
||||
| Redis | - | accusys |
|
||||
| MariaDB | accusys | - |
|
||||
| n8n | - | (Web UI 配置) |
|
||||
| Qdrant | - | Test3200Test3200 |
|
||||
| MongoDB | accusys | Test3200Test3200 |
|
||||
|
||||
---
|
||||
|
||||
## 文檔位置
|
||||
|
||||
- 安裝文檔: `/Users/accusys/momentry_core_0.1/docs/INSTALL_*.md`
|
||||
- 服務管理: `/Users/accusys/momentry_core_0.1/docs/SERVICE_ADDITION_GUIDE.md`
|
||||
- Plist 模板: `/Users/accusys/momentry_core_0.1/momentry_runtime/plist/`
|
||||
Reference in New Issue
Block a user