mindnet/docs/99_Archive/alte_Versionen/V2.6.0/admin_guide.md

238 lines
8.0 KiB
Markdown
Raw Normal View History

2025-12-10 18:55:38 +01:00
# Mindnet v2.4 – Admin Guide
2025-12-12 22:54:59 +01:00
**Datei:** `docs/mindnet_admin_guide_v2.6.md`
**Stand:** 2025-12-12
**Status:** **FINAL** (Inkl. Traffic Control & Smart Edge Config)
**Quellen:** `Handbuch.md`, `mindnet_developer_guide_v2.6.md`.
2025-12-07 12:11:51 +01:00
2025-12-10 10:26:44 +01:00
> Dieses Handbuch richtet sich an **Administratoren**. Es beschreibt Installation, Konfiguration, Backup-Strategien, Monitoring und den sicheren Betrieb der Mindnet-Instanz (API + UI + DB).
2025-12-07 12:11:51 +01:00
---
## 1. Zielgruppe & Scope
2025-12-10 10:26:44 +01:00
Mindnet ist als **Multi-Service-Architektur** konzipiert, die lokal oder auf einem privaten Server läuft.
2025-12-08 09:07:34 +01:00
Wir unterscheiden strikt zwischen:
2025-12-10 10:26:44 +01:00
* **Production:** Backend (8001) + Frontend (8501). Stabiler `main` Branch.
* **Development:** Backend (8002) + Frontend (8502). Experimentelle Feature-Branches.
2025-12-07 12:11:51 +01:00
---
2025-12-08 09:07:34 +01:00
## 2. Initial Setup & Installation
2025-12-07 12:11:51 +01:00
### 2.1 Systemvoraussetzungen
* **OS:** Linux (Ubuntu 22.04+ empfohlen) oder macOS.
2025-12-08 16:14:52 +01:00
* **Runtime:** Python 3.10+, Docker (für Qdrant), Ollama (für LLM).
2025-12-07 12:11:51 +01:00
* **Hardware:**
2025-12-11 16:58:23 +01:00
* CPU: 4+ Cores empfohlen (für Async Import & Inference).
2025-12-08 16:14:52 +01:00
* RAM: Min. 8GB empfohlen (4GB System + 4GB für Phi-3/Qdrant).
2025-12-07 12:11:51 +01:00
* Disk: SSD empfohlen für Qdrant-Performance.
2025-12-08 09:07:34 +01:00
### 2.2 Installation (Code)
2025-12-09 17:11:03 +01:00
2025-12-07 12:11:51 +01:00
# 1. Repository klonen
2025-12-08 09:07:34 +01:00
git clone <repo-url> /home/llmadmin/mindnet
cd /home/llmadmin/mindnet
2025-12-07 12:11:51 +01:00
# 2. Umgebung einrichten
python3 -m venv .venv
source .venv/bin/activate
2025-12-10 10:26:44 +01:00
2025-12-11 16:58:23 +01:00
# 3. Dependencies installieren (inkl. Streamlit, HTTPX)
2025-12-07 12:11:51 +01:00
pip install -r requirements.txt
2025-12-10 10:26:44 +01:00
# 4. Verzeichnisse anlegen
2025-12-11 16:58:23 +01:00
mkdir -p logs qdrant_storage data/logs vault
2025-12-07 12:11:51 +01:00
### 2.3 Qdrant Setup (Docker)
Wir nutzen Qdrant als Vektor-Datenbank. Persistenz ist wichtig.
2025-12-09 17:11:03 +01:00
2025-12-07 12:11:51 +01:00
docker run -d \
--name mindnet_qdrant \
--restart always \
-p 6333:6333 \
-v $(pwd)/qdrant_storage:/qdrant/storage \
qdrant/qdrant
2025-12-11 16:58:23 +01:00
### 2.4 Ollama Setup (LLM & Embeddings)
Mindnet benötigt einen lokalen LLM-Server für Chat UND Embeddings.
2025-12-12 22:54:59 +01:00
**WICHTIG (Update v2.4):** Es muss zwingend `nomic-embed-text` installiert sein, sonst startet der Import nicht.
2025-12-09 17:11:03 +01:00
2025-12-08 16:14:52 +01:00
# 1. Installieren (Linux Script)
2025-12-11 16:58:23 +01:00
curl -fsSL https://ollama.com/install.sh | sh
2025-12-08 16:14:52 +01:00
2025-12-11 16:58:23 +01:00
# 2. Modelle laden
ollama pull phi3:mini # Für Chat/Reasoning
ollama pull nomic-embed-text # Für Vektoren (768 Dim)
2025-12-08 16:14:52 +01:00
# 3. Testen
curl http://localhost:11434/api/generate -d '{"model": "phi3:mini", "prompt":"Hi"}'
### 2.5 Konfiguration (ENV)
2025-12-12 22:54:59 +01:00
Erstelle eine `.env` Datei im Root-Verzeichnis. Achte besonders auf `VECTOR_DIM` und das neue `MINDNET_LLM_BACKGROUND_LIMIT`.
2025-12-07 12:11:51 +01:00
2025-12-11 16:58:23 +01:00
# Server Config
UVICORN_HOST=0.0.0.0
2025-12-07 12:11:51 +01:00
# Qdrant Verbindung
QDRANT_URL="http://localhost:6333"
# Mindnet Core Settings
2025-12-08 16:14:52 +01:00
COLLECTION_PREFIX="mindnet"
2025-12-07 12:11:51 +01:00
MINDNET_TYPES_FILE="./config/types.yaml"
2025-12-11 16:58:23 +01:00
MINDNET_VAULT_ROOT="./vault"
2025-12-07 12:11:51 +01:00
2025-12-11 16:58:23 +01:00
# WICHTIG: Dimension auf 768 setzen (für Nomic)
VECTOR_DIM=768
# AI Modelle (Ollama)
2025-12-10 18:55:38 +01:00
MINDNET_OLLAMA_URL="http://127.0.0.1:11434"
2025-12-11 16:58:23 +01:00
MINDNET_LLM_MODEL="phi3:mini"
2025-12-12 22:54:59 +01:00
MINDNET_EMBEDDING_MODEL="nomic-embed-text"
2025-12-09 17:11:03 +01:00
2025-12-12 22:54:59 +01:00
# Timeouts (Erhöht für Async/Nomic/Smart Edges)
2025-12-11 16:58:23 +01:00
MINDNET_LLM_TIMEOUT=300.0
2025-12-12 22:54:59 +01:00
MINDNET_API_TIMEOUT=300.0 # Wichtig: Frontend muss warten können
# Traffic Control (Neu in v2.6)
# Begrenzt parallele LLM-Calls im Import, um Chat stabil zu halten.
MINDNET_LLM_BACKGROUND_LIMIT=2
2025-12-11 16:58:23 +01:00
# Configs
2025-12-09 17:11:03 +01:00
MINDNET_PROMPTS_PATH="./config/prompts.yaml"
MINDNET_DECISION_CONFIG="./config/decision_engine.yaml"
2025-12-07 12:11:51 +01:00
2025-12-10 10:26:44 +01:00
### 2.6 Deployment via Systemd (Backend & Frontend)
Mindnet benötigt zwei Services pro Umgebung: API (Uvicorn) und UI (Streamlit).
**Production Backend (`/etc/systemd/system/mindnet-prod.service`):**
2025-12-08 09:07:34 +01:00
2025-12-10 10:26:44 +01:00
[Unit]
Description=Mindnet API Prod (8001)
After=network.target
[Service]
User=llmadmin
Group=llmadmin
WorkingDirectory=/home/llmadmin/mindnet
2025-12-11 16:58:23 +01:00
# Async Server Start
2025-12-10 10:26:44 +01:00
ExecStart=/home/llmadmin/mindnet/.venv/bin/uvicorn app.main:app --host 0.0.0.0 --port 8001 --env-file .env
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
**Production Frontend (`/etc/systemd/system/mindnet-ui-prod.service`):**
[Unit]
Description=Mindnet UI Prod (8501)
After=mindnet-prod.service
[Service]
User=llmadmin
Group=llmadmin
WorkingDirectory=/home/llmadmin/mindnet
# Environment Variables
Environment="MINDNET_API_URL=http://localhost:8001"
Environment="MINDNET_API_TIMEOUT=300"
Environment="STREAMLIT_SERVER_PORT=8501"
Environment="STREAMLIT_SERVER_ADDRESS=0.0.0.0"
Environment="STREAMLIT_SERVER_HEADLESS=true"
ExecStart=/home/llmadmin/mindnet/.venv/bin/streamlit run app/frontend/ui.py
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
**Firewall (UFW):**
Öffne die Ports für den Zugriff:
sudo ufw allow 8501/tcp # Prod UI
sudo ufw allow 8502/tcp # Dev UI (falls gewünscht)
2025-12-08 09:07:34 +01:00
2025-12-07 12:11:51 +01:00
---
## 3. Betrieb im Alltag
### 3.1 Regelmäßige Importe
2025-12-12 22:54:59 +01:00
Der Vault-Zustand sollte regelmäßig (z.B. stündlich per Cronjob) nach Qdrant synchronisiert werden. Das Skript nutzt nun **AsyncIO**, **Smart Edges** und **Traffic Control**.
2025-12-07 12:11:51 +01:00
**Cronjob-Beispiel (stündlich):**
2025-12-09 17:11:03 +01:00
2025-12-11 16:58:23 +01:00
0 * * * * cd /home/llmadmin/mindnet && .venv/bin/python3 -m scripts.import_markdown --vault ./vault --prefix "mindnet" --apply --purge-before-upsert --sync-deletes >> ./logs/import.log 2>&1
2025-12-07 12:11:51 +01:00
2025-12-12 22:54:59 +01:00
**Hinweis zu Smart Edges:**
Der Import dauert nun länger (ca. 2-3 Min pro Datei), da das LLM intensiv genutzt wird. Dank `MINDNET_LLM_BACKGROUND_LIMIT=2` bleibt der Server dabei aber für den Chat responsive.
2025-12-07 12:11:51 +01:00
### 3.2 Health-Checks
2025-12-10 10:26:44 +01:00
Prüfe regelmäßig, ob alle Komponenten laufen.
2025-12-09 17:11:03 +01:00
2025-12-08 09:07:34 +01:00
sudo systemctl status mindnet-prod
2025-12-10 10:26:44 +01:00
sudo systemctl status mindnet-ui-prod
2025-12-08 16:14:52 +01:00
sudo systemctl status ollama
2025-12-07 12:11:51 +01:00
2025-12-08 09:07:34 +01:00
### 3.3 Logs & Monitoring
2025-12-10 10:26:44 +01:00
* **Backend Fehler:** `journalctl -u mindnet-prod -f`
* **Frontend Fehler:** `journalctl -u mindnet-ui-prod -f`
* **LLM Fehler:** `journalctl -u ollama -f`
2025-12-08 16:14:52 +01:00
* **Fachliche Logs:** `data/logs/search_history.jsonl`
2025-12-07 12:11:51 +01:00
---
2025-12-12 22:54:59 +01:00
## 4. Troubleshooting (Update v2.6)
2025-12-07 12:11:51 +01:00
2025-12-11 16:58:23 +01:00
### "Vector dimension error: expected dim: 768, got 384"
* **Ursache:** Du versuchst, in eine alte Qdrant-Collection (mit 384 Dim aus v2.2) neue Embeddings (mit 768 Dim von Nomic) zu schreiben.
* **Lösung:** Full Reset erforderlich.
1. `python -m scripts.reset_qdrant --mode wipe --prefix mindnet --yes` (Löscht DB).
2. `python -m scripts.import_markdown ...` (Baut neu auf).
2025-12-07 12:11:51 +01:00
2025-12-12 22:54:59 +01:00
### "500 Internal Server Error" beim Speichern/Chatten
* **Ursache:** Oft Timeout bei Ollama, wenn `nomic-embed-text` noch nicht im RAM geladen ist ("Cold Start") oder der Import die GPU blockiert.
2025-12-11 16:58:23 +01:00
* **Lösung:**
2025-12-12 22:54:59 +01:00
1. `MINDNET_LLM_TIMEOUT` in `.env` auf `300.0` setzen.
2. `MINDNET_LLM_BACKGROUND_LIMIT` auf `1` reduzieren (falls Hardware schwach).
2025-12-09 17:11:03 +01:00
2025-12-12 22:54:59 +01:00
### Import ist sehr langsam
* **Ursache:** Smart Edges sind aktiv (`types.yaml`) und analysieren jeden Chunk.
* **Lösung:**
* Akzeptieren (für bessere Qualität).
* Oder für Massen-Initial-Import in `types.yaml` temporär `enable_smart_edge_allocation: false` setzen.
2025-12-07 12:11:51 +01:00
---
## 5. Backup & Restore
2025-12-08 09:07:34 +01:00
Datensicherheit ruht auf drei Säulen: Vault (Source), Qdrant (Index), JSONL-Logs (Lern-Daten).
2025-12-07 12:11:51 +01:00
### 5.1 Vault-Backup (Priorität 1)
2025-12-10 10:26:44 +01:00
Der Markdown-Vault ist die **Single Source of Truth**.
2025-12-07 12:11:51 +01:00
### 5.2 Qdrant-Snapshots (Priorität 2)
2025-12-08 09:07:34 +01:00
Für schnelle Wiederherstellung des Suchindex.
2025-12-09 17:11:03 +01:00
2025-12-07 12:11:51 +01:00
docker stop mindnet_qdrant
tar -czf qdrant_backup_$(date +%F).tar.gz ./qdrant_storage
docker start mindnet_qdrant
2025-12-11 16:58:23 +01:00
### 5.3 Notfall-Wiederherstellung (Rebuild)
Wenn die Datenbank korrupt ist oder Modelle gewechselt werden:
2025-12-09 17:11:03 +01:00
2025-12-07 12:11:51 +01:00
# 1. DB komplett leeren (Wipe)
python3 -m scripts.reset_qdrant --mode wipe --prefix "mindnet" --yes
2025-12-12 22:54:59 +01:00
# 2. Alles neu importieren (Force re-calculates Hashes)
2025-12-11 16:58:23 +01:00
python3 -m scripts.import_markdown --vault ./vault --prefix "mindnet" --apply --force
2025-12-07 12:11:51 +01:00
---
2025-12-08 09:07:34 +01:00
## 6. Governance & Sicherheit
2025-12-07 12:11:51 +01:00
2025-12-08 09:07:34 +01:00
### 6.1 Zugriffsschutz
Mindnet hat aktuell **keine integrierte Authentifizierung**.
2025-12-10 10:26:44 +01:00
* **Frontend:** Streamlit auf Port 8501 ist offen. Nutze Nginx Basic Auth oder VPN.
* **API:** Sollte nicht direkt im öffentlichen Netz stehen.
2025-12-11 16:58:23 +01:00
* **Qdrant:** Auf `127.0.0.1` beschränken.