94 lines
2.0 KiB
Markdown
94 lines
2.0 KiB
Markdown
# mqtt-emma
|
|
|
|
Eclipse Mosquitto MQTT broker als Docker Compose Stack für Synology NAS.
|
|
|
|
## Voraussetzungen
|
|
|
|
- Synology NAS mit Docker/Container Manager
|
|
- SSH-Zugriff auf die NAS
|
|
- `docker` und `docker compose` verfügbar (ab DSM 7.2 inklusive)
|
|
|
|
## Deployment
|
|
|
|
### 1. Dateien auf die NAS kopieren
|
|
|
|
```bash
|
|
scp -r mqtt-emma/ admin@192.168.1.4:/volume1/docker/mqtt-emma
|
|
```
|
|
|
|
Oder per File Station / SMB-Share auf die NAS kopieren.
|
|
|
|
### 2. Per SSH einloggen und ins Projektverzeichnis wechseln
|
|
|
|
```bash
|
|
ssh admin@192.168.1.4
|
|
cd /volume1/docker/mqtt-emma
|
|
```
|
|
|
|
### 3. Stack starten
|
|
|
|
```bash
|
|
docker compose up -d
|
|
```
|
|
|
|
### 4. Verbindung testen
|
|
|
|
Von einem Rechner im gleichen Netzwerk (mosquitto-clients erforderlich):
|
|
|
|
```bash
|
|
# Subscriber starten
|
|
mosquitto_sub -h 192.168.1.4 -p 1883 -t 'test/#' -v
|
|
|
|
# In einem zweiten Terminal: Nachricht senden
|
|
mosquitto_pub -h 192.168.1.4 -p 1883 -t 'test/hello' -m 'welt'
|
|
```
|
|
|
|
> **Hinweis:** Aktuell ist anonymer Zugriff aktiviert (kein Passwort nötig). Für Produktion `allow_anonymous false` und `password_file` in `mosquitto/config/mosquitto.conf` einkommentieren.
|
|
|
|
## Ports
|
|
|
|
| Port | Protokoll | Beschreibung |
|
|
|------|------------|-----------------------------------|
|
|
| 1883 | MQTT | Standard MQTT |
|
|
| 9001 | WebSockets | Für Browser-Clients (z. B. MQTT.js) |
|
|
|
|
## Nützliche Befehle
|
|
|
|
```bash
|
|
# Logs anzeigen
|
|
docker compose logs -f mosquitto
|
|
|
|
# Stack stoppen
|
|
docker compose down
|
|
|
|
# Config neu laden (ohne Neustart)
|
|
docker compose kill -s HUP mosquitto
|
|
|
|
# Broker-Status prüfen
|
|
docker compose ps
|
|
```
|
|
|
|
## Konfiguration
|
|
|
|
Die Broker-Konfiguration liegt in `mosquitto/config/mosquitto.conf`.
|
|
Nach Änderungen genügt ein Config-Reload:
|
|
|
|
```bash
|
|
docker compose kill -s HUP mosquitto
|
|
```
|
|
|
|
Für Änderungen an Ports oder Volumes ist ein Neustart nötig:
|
|
|
|
```bash
|
|
docker compose down && docker compose up -d
|
|
```
|
|
|
|
## Zeitzone anpassen
|
|
|
|
In `docker-compose.yml` die Umgebungsvariable `TZ` anpassen, z. B.:
|
|
|
|
```yaml
|
|
environment:
|
|
- TZ=Europe/Vienna
|
|
```
|