# Homelab Galera/MaxScale Topology (Updated 2026-07-13)

## MariaDB Galera Cluster (3 nodes — quorum-safe: 3 different PVE hosts)

| Node | VM ID | Proxmox Host | IP | Hostname | RAM |
|------|-------|---------------|----|----------|-----|
| db1 | 300 | n5pro (10.0.20.91) | 10.0.30.71 | mariadb-01 | 8 GB |
| db2 | 301 | proxmox3 (10.0.20.30) | 10.0.30.72 | mariadb-02 | 8 GB |
| db3 | 302 | proxmox6 (10.0.20.60) | 10.0.30.73 | mariadb-03 | 8 GB |

- MariaDB version: 11.4.10-MariaDB-deb12
- Cluster name: `mariadb-galera`
- Galera address: `gcomm://10.0.30.71,10.0.30.72,10.0.30.73`
- DB size: ~18GB (homeassistant schema)
- **Effective RAM usage**: ~5.5 GB per node (4 GB innodb_buffer_pool + 1.5 GB OS/Galera)
- `balloon: 0` on all Galera VMs — see SKILL.md §5.3b for rationale
- **Quorum guarantee**: Any single PVE host failure leaves ≥2 Galera nodes alive
- **Note**: PVE HA may migrate VMs. Always verify current placement
  with `qm list` on each node before operating.

## MaxScale Proxy (2 instances + VIP)

| Node | VM ID | Proxmox Host | IP | Hostname | RAM | Status |
|------|-------|---------------|----|----------|-----|--------|
| maxscale-01 | 310 | n5pro (10.0.20.91) | 10.0.30.81 | maxscale-01 | 2 GB | Active |
| maxscale-02 | 311 | proxmox3 (10.0.20.30) | 10.0.30.82 | maxscale-02 | 2 GB | Standby |
| VIP | — | — | 10.0.30.70 | keepalived VIP | — | — |

- MaxScale version: 24.02.9
- Services: `rw-router` (readwritesplit), `ro-router` (readconnroute)
- Monitor: `galera-monitor` (galeramon)
- Listener: `rw-listener` on port 3306

## HA Rules (PVE 8 rules.cfg)

```
node-affinity: db-nodes
    nodes n5pro,proxmox3,proxmox6
    resources vm:300,vm:301,vm:302,vm:310,vm:311
    strict 1

resource-affinity: ha-rule-ea9e852a-8d82
    affinity negative
    resources vm:310,vm:311

resource-affinity: ha-rule-d61699eb-2baf
    affinity negative
    resources vm:301,vm:302
```

- `db-nodes` (strict=1): Galera + MaxScale VMs restricted to n5pro + proxmox3 + proxmox6 (3 hardware-diverse hosts)
- Negative resource-affinity: MaxScale 310↔311 kept apart, Galera 301↔302 kept apart
- At node failure, HA manager restarts VM on one of the other 2 allowed nodes (deterministic)
- **⚠️ Anti-affinity rules can block `qm migrate`** — check rules.cfg before migrating

## PVE Host RAM Capacity

| Host | IP | Physical RAM | Notes |
|------|-----|-------------|-------|
| n5pro | 10.0.20.91 | 91 GB | Massive headroom, primary DB host |
| proxmox3 | 10.0.20.30 | 31 GB | Good headroom, secondary DB host |
| proxmox6 | 10.0.20.60 | 15 GB | Tight — 113% overcommit with Galera VM, but effective use is only 5.5 GB |
| proxmox1-2,4-5,7 | 10.0.20.{10,20,40,50,??} | 15 GB each | NOT in db-nodes rule — DB VMs cannot failover here |

## SSH Access

```bash
# MariaDB VMs (user: debian) — may vary if HA migrated the VM
ssh -i ~/.ssh/id_ed25519_proxmox debian@10.0.30.71
ssh -i ~/.ssh/id_ed25519_proxmox debian@10.0.30.72
ssh -i ~/.ssh/id_ed25519_proxmox debian@10.0.30.73

# MaxScale VMs (user: debian)
ssh -i ~/.ssh/id_ed25519_proxmox debian@10.0.30.70

# Proxmox hosts (user: root)
ssh -i ~/.ssh/id_ed25519_proxmox root@10.0.20.10   # proxmox1
ssh -i ~/.ssh/id_ed25519_proxmox root@10.0.20.30   # proxmox3
ssh -i ~/.ssh/id_ed25519_proxmox root@10.0.20.60   # proxmox6
ssh -i ~/.ssh/id_ed25519_proxmox root@10.0.20.91   # n5pro
```

## Credentials

Credentials in 1Password Vault "Kubernetes ESO" (ID: `334ykdtj5kar3jlpcrztjvx2fu`):
- `mariadb-root` — root password (localhost only, `sudo mariadb` on node)
- `mariadb-app-user` — username=dominik, app access
- `gitea-db` — Gitea database user/password

Legacy item `mariadb-galera-vm` in vault "Hermes" may still contain:
- `maxscale-password` — MaxScale MySQL user with SUPER privilege
- `mariabackup-password` — Galera SST transfer auth
- `ha-recorder-password` — HA Recorder MySQL user
- `keepalived-auth-pass` — keepalived VIP failover auth

## Firewall (UFW on MariaDB VMs)

- Port 3306: ALLOW from 10.0.30.81, 10.0.30.82 (MaxScale only)
- Ports 4567, 4568, 4444: ALLOW between Galera nodes (10.0.30.71-73)

## Home Assistant

- VM 106 on proxmox1 (10.0.20.10)
- Internal: http://10.0.30.10:8123
- External: https://homeassistant.familie-schoen.com
- Config: `/mnt/data/supervisor/homeassistant/configuration.yaml`
- Recorder DB URL: `mysql://ha_recorder:***@10.0.30.70:3306/homeassistant`
- InfluxDB: 10.0.30.109:8086, bucket `ha_hot_90d` (long-term history)

### HAOS SSH Access (Port 22222)

```bash
ssh -i ~/.ssh/id_ed25519_proxmox root@10.0.30.10 -p 22222
```
