feat(infraestrutura): adiciona plugin infraestrutura (agents, skills, knowledge e metadados do projeto)
This commit is contained in:
@@ -0,0 +1,187 @@
|
||||
---
|
||||
name: proxmox-ha
|
||||
description: Configuracao de High Availability em cluster Proxmox -- HA Manager, fencing devices (STONITH) e failover automatico para VMs criticas.
|
||||
layer: wiki
|
||||
---
|
||||
|
||||
# Proxmox HA
|
||||
|
||||
Configurar High Availability (HA) em cluster Proxmox com HA Manager, fencing devices e failover automatico para VMs criticas.
|
||||
|
||||
## Quando Usar
|
||||
|
||||
- Configurar HA apos cluster formation (/proxmox-cluster)
|
||||
- Proteger VMs criticas com failover automatico
|
||||
- Configurar fencing devices (STONITH)
|
||||
- Definir HA groups por criticidade
|
||||
- Testar failover procedures
|
||||
|
||||
## Sintaxe
|
||||
|
||||
```bash
|
||||
/proxmox-ha configure --critical-vms <vm-ids> [--fencing watchdog|ipmi] [--max-relocate 2]
|
||||
```
|
||||
|
||||
## Knowledge Sources
|
||||
|
||||
```bash
|
||||
mcp__notebooklm__notebook_query \
|
||||
notebook_id:"276ccdde-6b95-42a3-ad96-4e64d64c8d52" \
|
||||
query:"proxmox ha high availability fencing stonith failover"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Pre-Requisitos
|
||||
|
||||
**1. Cluster formado:**
|
||||
```bash
|
||||
pvecm status
|
||||
# Expected: Quorum: Active, Nodes: 2+ online
|
||||
```
|
||||
|
||||
**2. Shared Storage ou Replication:**
|
||||
- **Shared storage** (NFS, Ceph): HA ideal (failover <30s)
|
||||
- **Sem shared storage**: ZFS replication ou boot time failover (~2-5min)
|
||||
|
||||
**3. Fencing device configurado** - sem fencing = risco split-brain
|
||||
|
||||
---
|
||||
|
||||
## Workflow Completo
|
||||
|
||||
### Fase 1: Fencing Configuration
|
||||
|
||||
Detalhes completos das 3 opcoes (Watchdog, IPMI, Network) em: `references/fencing-configuration.md`
|
||||
|
||||
**Resumo:** Watchdog para inicio, IPMI para producao, evitar network fencing.
|
||||
|
||||
### Fase 2: HA Manager Configuration
|
||||
|
||||
```bash
|
||||
# Verificar status
|
||||
ha-manager status
|
||||
# Expected: quorum: OK, master: <node-name> (elected), lrm: active
|
||||
```
|
||||
|
||||
**Criar HA Groups por criticidade:**
|
||||
```bash
|
||||
# Critical (priority 100)
|
||||
ha-manager groupadd critical \
|
||||
--nodes "server.descomplicar.pt:100,cluster.descomplicar.pt:100"
|
||||
|
||||
# Medium (priority 50)
|
||||
ha-manager groupadd medium \
|
||||
--nodes "server.descomplicar.pt:50,cluster.descomplicar.pt:50"
|
||||
|
||||
# Low (priority 10)
|
||||
ha-manager groupadd low \
|
||||
--nodes "server.descomplicar.pt:10,cluster.descomplicar.pt:10"
|
||||
```
|
||||
|
||||
### Fase 3: Adicionar VMs a HA
|
||||
|
||||
```bash
|
||||
# VM 200 (EasyPanel Docker)
|
||||
ha-manager add vm:200 \
|
||||
--group critical \
|
||||
--max_restart 3 \
|
||||
--max_relocate 2 \
|
||||
--state started
|
||||
|
||||
# VM 300 (CWP)
|
||||
ha-manager add vm:300 \
|
||||
--group critical \
|
||||
--max_restart 3 \
|
||||
--max_relocate 2 \
|
||||
--state started
|
||||
```
|
||||
|
||||
**Parametros:**
|
||||
- `max_restart`: Tentativas restart no mesmo node antes de relocate
|
||||
- `max_relocate`: Maximo relocates entre nodes
|
||||
- `state started`: HA Manager garante VM esta sempre started
|
||||
|
||||
```bash
|
||||
# Verificar
|
||||
ha-manager status
|
||||
```
|
||||
|
||||
### Fase 4: Failover Testing
|
||||
|
||||
Procedimentos detalhados de teste (shutdown clean, node crash simulado, live migration) e tuning de policies em: `references/failover-testing.md`
|
||||
|
||||
### Fase 5: Production Rollout
|
||||
|
||||
Abordagem faseada (low -> medium -> critical) com monitorizacao de 30 dias.
|
||||
|
||||
Documentar runbook em: `06-Operacoes/Procedimentos/D7-Tecnologia/PROC-HA-Failover.md`
|
||||
|
||||
---
|
||||
|
||||
## Best Practices
|
||||
|
||||
**Fazer:**
|
||||
- Testar failover em VMs teste ANTES production
|
||||
- Configurar fencing (watchdog minimo, IPMI ideal)
|
||||
- Monitorizar quorum 24/7
|
||||
- Documentar runbooks failover
|
||||
- Backup ANTES activar HA
|
||||
|
||||
**Nao fazer:**
|
||||
- HA sem fencing (risco split-brain)
|
||||
- max_relocate muito alto (VM fica "bouncing")
|
||||
- Assumir instant failover sem shared storage
|
||||
- Testar failover em production sem plano
|
||||
|
||||
---
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### VM nao failover
|
||||
```bash
|
||||
ha-manager status | grep vm:ID
|
||||
pvecm status
|
||||
journalctl -u pve-ha-crm -f
|
||||
```
|
||||
|
||||
### Split-brain detected
|
||||
```bash
|
||||
# Shutdown 1 node completamente
|
||||
systemctl poweroff
|
||||
|
||||
# No node restante:
|
||||
pvecm expected 1 # Force quorum com 1 node
|
||||
# Resolver networking, rejoin node shutdown
|
||||
```
|
||||
|
||||
### Failover loop (VM keeps restarting)
|
||||
```bash
|
||||
# Pause HA temporario
|
||||
ha-manager set vm:ID --state disabled
|
||||
# Fix VM issue
|
||||
# Re-enable HA
|
||||
ha-manager set vm:ID --state started
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## References
|
||||
|
||||
- `references/fencing-configuration.md` - Detalhes Watchdog, IPMI e Network fencing
|
||||
- `references/failover-testing.md` - Testes, policies, monitoring, alertas, production rollout
|
||||
- **NotebookLM:** 276ccdde-6b95-42a3-ad96-4e64d64c8d52
|
||||
- **HA Manager Docs:** https://pve.proxmox.com/pve-docs/ha-manager.1.html
|
||||
- **Fencing:** https://pve.proxmox.com/wiki/Fencing
|
||||
|
||||
---
|
||||
|
||||
## Healing Log
|
||||
|
||||
Registo de erros conhecidos e como evitá-los. Lido automaticamente antes de executar.
|
||||
|
||||
```jsonl
|
||||
{"date":"","issue":"","fix":"","source":"user|auto"}
|
||||
```
|
||||
|
||||
*Adicionar nova linha após cada erro corrigido.*
|
||||
@@ -0,0 +1,185 @@
|
||||
# Failover Testing - Proxmox HA
|
||||
|
||||
Procedimentos detalhados de teste de failover e monitoring.
|
||||
|
||||
---
|
||||
|
||||
## Criar VM Teste HA
|
||||
|
||||
```bash
|
||||
# VM 999 para teste (nao production)
|
||||
qm create 999 --name ha-test --memory 512 --cores 1
|
||||
|
||||
# Adicionar a HA
|
||||
ha-manager add vm:999 --state started
|
||||
```
|
||||
|
||||
## Teste 1: Shutdown Clean
|
||||
|
||||
```bash
|
||||
# Node onde VM 999 corre:
|
||||
qm shutdown 999
|
||||
|
||||
# HA Manager deve:
|
||||
# 1. Detectar shutdown (~30s)
|
||||
# 2. Tentar restart no mesmo node (max_restart vezes)
|
||||
# 3. Se continua down -> relocate para outro node
|
||||
|
||||
# Monitorizar
|
||||
watch -n 1 'ha-manager status | grep vm:999'
|
||||
```
|
||||
|
||||
## Teste 2: Node Crash (Simulado)
|
||||
|
||||
```bash
|
||||
# CUIDADO: Apenas em teste, nao production
|
||||
|
||||
# Shutdown abrupto do node onde VM 999 corre
|
||||
# (simula hardware failure)
|
||||
echo b > /proc/sysrq-trigger # Reboot forcado
|
||||
|
||||
# Outro node deve:
|
||||
# 1. Detectar node down via quorum (~1min)
|
||||
# 2. Fence node (via watchdog/IPMI)
|
||||
# 3. Boot VM 999 no node surviving
|
||||
|
||||
# Timeline esperado:
|
||||
# - 0s: Node crash
|
||||
# - ~60s: Quorum detecta node missing
|
||||
# - ~90s: Fencing executado
|
||||
# - ~120s: VM boota em outro node
|
||||
|
||||
# Total downtime: ~2-3min (sem shared storage)
|
||||
# Com shared storage: ~30-60s
|
||||
```
|
||||
|
||||
## Teste 3: Live Migration Manual
|
||||
|
||||
```bash
|
||||
# Migration manual (com VM running)
|
||||
qm migrate 999 <target-node-name> --online
|
||||
|
||||
# Com shared storage: <10s downtime
|
||||
# Sem shared storage: copia disk = lento (GB/min)
|
||||
|
||||
# Para production VMs:
|
||||
# - Fazer em janela manutencao se sem shared storage
|
||||
# - Live migration OK se shared storage
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## HA Policies e Tuning
|
||||
|
||||
### Shutdown Policy
|
||||
|
||||
```bash
|
||||
# Default: conditional (HA Manager decide)
|
||||
# Opcoes: conditional, freeze, failover, migrate
|
||||
|
||||
# Para VMs criticas que NAO devem migrar durante manutencao:
|
||||
ha-manager set vm:200 --state freeze
|
||||
|
||||
# Para forcar migrate durante manutencao:
|
||||
ha-manager set vm:200 --state migrate
|
||||
```
|
||||
|
||||
### Maintenance Mode
|
||||
|
||||
```bash
|
||||
# Colocar node em maintenance (nao recebe novos VMs HA)
|
||||
ha-manager set-node-state <node-name> maintenance
|
||||
|
||||
# VMs HA existentes:
|
||||
# - Nao migram automaticamente
|
||||
# - Mas nao recebem novas em failover
|
||||
|
||||
# Sair de maintenance
|
||||
ha-manager set-node-state <node-name> active
|
||||
```
|
||||
|
||||
### Priorities (Load Balance)
|
||||
|
||||
```bash
|
||||
# Preferencia de nodes por VM
|
||||
|
||||
# VM 200: Preferir Node B
|
||||
ha-manager set vm:200 --group critical --restricted
|
||||
|
||||
# restricted: VM so corre nos nodes do grupo
|
||||
# unrestricted: VM pode correr em qualquer node (fallback)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Monitoring e Alertas
|
||||
|
||||
### HA Manager Logs
|
||||
|
||||
```bash
|
||||
# Logs HA Manager
|
||||
journalctl -u pve-ha-lrm -f # Local Resource Manager
|
||||
journalctl -u pve-ha-crm -f # Cluster Resource Manager
|
||||
|
||||
# Ver decisoes de failover
|
||||
grep "migrate\|relocate" /var/log/pve/tasks/index
|
||||
```
|
||||
|
||||
### Configurar Alertas
|
||||
|
||||
```bash
|
||||
# Via Web UI: Datacenter -> Notifications
|
||||
|
||||
# Email alerts para:
|
||||
# - Node down
|
||||
# - Quorum lost
|
||||
# - VM failover events
|
||||
# - Fencing executed
|
||||
|
||||
# SMTP: mail.descomplicar.pt
|
||||
# To: admin@descomplicar.pt
|
||||
```
|
||||
|
||||
### Script Monitorizacao (cron cada 5min)
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
# /usr/local/bin/check-ha-health.sh
|
||||
|
||||
ha_status=$(ha-manager status | grep "quorum:" | awk '{print $2}')
|
||||
|
||||
if [ "$ha_status" != "OK" ]; then
|
||||
echo "HA Quorum NOT OK" | mail -s "ALERT: HA Issue" admin@descomplicar.pt
|
||||
fi
|
||||
|
||||
# Cron
|
||||
# */5 * * * * /usr/local/bin/check-ha-health.sh
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Production Rollout
|
||||
|
||||
Phased approach:
|
||||
|
||||
```bash
|
||||
# Week 1: VMs nao-criticas (teste)
|
||||
ha-manager add vm:250 --group low
|
||||
|
||||
# Week 2: VMs medias (se Week 1 OK)
|
||||
ha-manager add vm:201,202 --group medium
|
||||
|
||||
# Week 3: VMs criticas (se tudo OK)
|
||||
ha-manager add vm:200,300 --group critical
|
||||
```
|
||||
|
||||
### Documentar Runbook
|
||||
|
||||
Criar: `06-Operacoes/Procedimentos/D7-Tecnologia/PROC-HA-Failover.md`
|
||||
|
||||
Conteudo:
|
||||
- Detectar failover event
|
||||
- Validar VM booted correctamente
|
||||
- Investigar causa node failure
|
||||
- Restore node original
|
||||
- Migrate VM back (se necessario)
|
||||
@@ -0,0 +1,60 @@
|
||||
# Fencing Configuration - Proxmox HA
|
||||
|
||||
Configuracao detalhada de fencing devices (STONITH) para High Availability.
|
||||
|
||||
---
|
||||
|
||||
## Opcao A: Watchdog (Software Fencing)
|
||||
|
||||
Mais simples, menos confiavel:
|
||||
|
||||
```bash
|
||||
# Instalar watchdog em ambos nodes
|
||||
apt install watchdog
|
||||
|
||||
# Load kernel module
|
||||
modprobe softdog
|
||||
|
||||
# Auto-load on boot
|
||||
echo "softdog" >> /etc/modules
|
||||
|
||||
# Configurar HA Manager para usar watchdog
|
||||
# (automatico quando HA activado)
|
||||
```
|
||||
|
||||
## Opcao B: IPMI/iLO (Hardware Fencing)
|
||||
|
||||
Mais confiavel, requer IPMI:
|
||||
|
||||
```bash
|
||||
# Verificar IPMI disponivel
|
||||
ipmitool lan print
|
||||
|
||||
# Configurar IPMI credentials (via BIOS ou ipmitool)
|
||||
|
||||
# Configurar em Proxmox (Web UI):
|
||||
# Datacenter -> Fencing -> Add
|
||||
# Type: IPMI
|
||||
# IP: <node-ipmi-ip>
|
||||
# Username: admin
|
||||
# Password: <ipmi-pass>
|
||||
|
||||
# Test
|
||||
fence_ipmilan -a <node-ipmi-ip> -l admin -p <pass> -o status
|
||||
```
|
||||
|
||||
## Opcao C: Network Fencing (Menos Confiavel)
|
||||
|
||||
Usar apenas se IPMI nao disponivel:
|
||||
|
||||
```bash
|
||||
# SSH-based fencing (perigoso)
|
||||
# Depende de network estar up
|
||||
# Nao recomendado para production
|
||||
```
|
||||
|
||||
## Recomendacao Cluster Descomplicar
|
||||
|
||||
- **Inicio:** Watchdog (simple, funcional)
|
||||
- **Producao:** IPMI se hardware suporta
|
||||
- **Evitar:** Network fencing
|
||||
Reference in New Issue
Block a user