proxmox monitori
This commit is contained in:
360
proxmox/ha-monitor.sh
Normal file
360
proxmox/ha-monitor.sh
Normal file
@@ -0,0 +1,360 @@
|
||||
#!/bin/bash
|
||||
|
||||
# HA Monitor cu PVE::Notify - versiune finală
|
||||
# Folosește sistemul nativ Proxmox cu template-uri personalizate
|
||||
#
|
||||
# TEMPLATE SYSTEM:
|
||||
# ================
|
||||
# Acest script folosește template-uri Handlebars pentru formatarea emailurilor,
|
||||
# exact ca sistemul de backup Proxmox. Template-urile trebuie create în:
|
||||
#
|
||||
# /etc/pve/notification-templates/default/
|
||||
# ├── ha-status-subject.txt.hbs (subject-ul emailului)
|
||||
# ├── ha-status-body.txt.hbs (conținutul text al emailului)
|
||||
# └── ha-status-body.html.hbs (opțional, versiunea HTML)
|
||||
#
|
||||
# Template-urile folosesc sintaxa Handlebars cu variabilele:
|
||||
# - {{ hostname }} : FQDN-ul serverului
|
||||
# - {{ status }} : "SUCCESSFUL" sau "FAILED"
|
||||
# - {{ runtime }} : timpul de execuție în secunde
|
||||
# - {{ details }} : detaliile verificării HA
|
||||
#
|
||||
# Pentru alte scripturi care vor să folosească sistemul de notificări Proxmox:
|
||||
# 1. Creați template-urile în /etc/pve/notification-templates/default/
|
||||
# 2. Folosiți PVE::Notify::notify($severity, $template_name, $template_data, $fields)
|
||||
# 3. $template_name trebuie să corespundă cu numele fișierelor template
|
||||
#
|
||||
# PREREQUISITE:
|
||||
# =============
|
||||
# Template-urile sunt create automat de script la prima rulare
|
||||
|
||||
HOSTNAME=$(hostname)
|
||||
FQDN=$(hostname -f)
|
||||
DATE=$(date '+%Y-%m-%d %H:%M:%S')
|
||||
START_TIME=$(date +%s)
|
||||
|
||||
# Funcție pentru crearea template-urilor de notificare
|
||||
create_templates() {
|
||||
local template_dir="/etc/pve/notification-templates/default"
|
||||
|
||||
# Creează directorul dacă nu există
|
||||
mkdir -p "$template_dir"
|
||||
|
||||
echo "Creating notification templates in $template_dir..."
|
||||
|
||||
# Template pentru subject - pentru SUCCESS
|
||||
cat > "$template_dir/ha-status-subject.txt.hbs" << 'EOF'
|
||||
{{#if (eq status "SUCCESSFUL")}}✅ HA CLUSTER OK - {{ hostname }}{{else}}🚨 HA CLUSTER ISSUES - {{ hostname }}{{/if}}
|
||||
EOF
|
||||
|
||||
# Template pentru body text
|
||||
cat > "$template_dir/ha-status-body.txt.hbs" << 'EOF'
|
||||
{{#if (eq status "SUCCESSFUL")}}✅ HIGH AVAILABILITY STATUS: ALL SYSTEMS OK{{else}}🚨 HIGH AVAILABILITY CLUSTER HAS ISSUES{{/if}}
|
||||
|
||||
Host: {{ hostname }}
|
||||
Check duration: {{ runtime }}s
|
||||
|
||||
CLUSTER STATUS:
|
||||
{{ details }}
|
||||
|
||||
{{#if (eq status "FAILED")}}
|
||||
=== HOW TO READ pvecm status OUTPUT ===
|
||||
|
||||
Your current problematic output shows:
|
||||
- Total votes: 2 (WRONG - should be 3)
|
||||
- Qdevice (votes 0) (WRONG - should be votes 1)
|
||||
|
||||
After fix should show:
|
||||
- Total votes: 3 (CORRECT)
|
||||
- Qdevice (votes 1) (CORRECT)
|
||||
|
||||
=== STEP-BY-STEP FIX ===
|
||||
|
||||
Step 1 - Fix Qdevice (PRIORITY):
|
||||
systemctl restart corosync-qdevice
|
||||
sleep 5
|
||||
corosync-qdevice-tool -s
|
||||
|
||||
Step 2 - Verify cluster status:
|
||||
pvecm status
|
||||
LOOK FOR: Total votes: 3 (not 2!) and Qdevice (votes 1)
|
||||
|
||||
Step 3 - Test HA functionality:
|
||||
ha-manager status
|
||||
|
||||
=== WHAT THIS MEANS ===
|
||||
QDEVICE DISCONNECTED: No tie-breaker vote
|
||||
- If one node fails, cluster may lose quorum
|
||||
- VMs won't automatically migrate
|
||||
|
||||
The cluster works now but has no tie-breaker vote.
|
||||
One node failure = no quorum = VMs can't migrate.
|
||||
{{else}}
|
||||
All HA components are functioning normally.
|
||||
- Cluster has proper quorum with qdevice participation
|
||||
- Automatic VM migration is available
|
||||
- System is fully redundant
|
||||
{{/if}}
|
||||
|
||||
=== MANUAL SCRIPT EXECUTION ===
|
||||
|
||||
To run this HA status check manually:
|
||||
|
||||
Basic check:
|
||||
/opt/scripts/ha-monitor.sh
|
||||
|
||||
Verbose output (shows details on console):
|
||||
/opt/scripts/ha-monitor.sh -v
|
||||
|
||||
Recreate email templates:
|
||||
/opt/scripts/ha-monitor.sh --create-templates
|
||||
|
||||
Script location: /opt/scripts/ha-monitor.sh
|
||||
Log file: /var/log/pve-ha-monitor.log
|
||||
|
||||
Total check time: {{ runtime }}s
|
||||
EOF
|
||||
|
||||
# Template pentru body HTML cu font mai mare și consistent
|
||||
cat > "$template_dir/ha-status-body.html.hbs" << 'EOF'
|
||||
<div style="font-family: Arial, sans-serif; font-size: 16px; line-height: 1.5; max-width: 800px;">
|
||||
|
||||
{{#if (eq status "SUCCESSFUL")}}
|
||||
<h2 style="font-size: 22px; color: green; margin-bottom: 15px;">✅ HIGH AVAILABILITY STATUS: ALL SYSTEMS OK</h2>
|
||||
{{else}}
|
||||
<h2 style="font-size: 22px; color: red; margin-bottom: 15px;">🚨 HIGH AVAILABILITY CLUSTER HAS ISSUES</h2>
|
||||
{{/if}}
|
||||
|
||||
<p style="font-size: 16px; margin-bottom: 15px;"><strong>Host:</strong> {{ hostname }}<br>
|
||||
<strong>Check duration:</strong> {{ runtime }}s</p>
|
||||
|
||||
<h3 style="font-size: 18px; margin-top: 20px; margin-bottom: 10px;">CLUSTER STATUS</h3>
|
||||
<pre style="font-size: 15px; background: #f8f9fa; padding: 12px; border: 1px solid #ddd; border-radius: 4px; margin-bottom: 20px;">{{ details }}</pre>
|
||||
|
||||
{{#if (eq status "FAILED")}}
|
||||
<h3 style="font-size: 18px; margin-top: 20px; margin-bottom: 10px;">HOW TO READ pvecm status OUTPUT</h3>
|
||||
<p style="font-size: 16px; margin-bottom: 10px;"><strong>Your current problematic output shows:</strong></p>
|
||||
<ul style="font-size: 16px; margin-bottom: 15px;">
|
||||
<li>Total votes: 2 <strong style="color: red;">(WRONG - should be 3)</strong></li>
|
||||
<li>Qdevice (votes 0) <strong style="color: red;">(WRONG - should be votes 1)</strong></li>
|
||||
</ul>
|
||||
|
||||
<p style="font-size: 16px; margin-bottom: 10px;"><strong>After fix should show:</strong></p>
|
||||
<ul style="font-size: 16px; margin-bottom: 15px;">
|
||||
<li>Total votes: 3 <strong style="color: green;">(CORRECT)</strong></li>
|
||||
<li>Qdevice (votes 1) <strong style="color: green;">(CORRECT)</strong></li>
|
||||
</ul>
|
||||
|
||||
<h3 style="font-size: 18px; margin-top: 20px; margin-bottom: 10px;">STEP-BY-STEP FIX</h3>
|
||||
|
||||
<h4 style="font-size: 16px; margin-top: 15px; margin-bottom: 8px;">Step 1 - Fix Qdevice:</h4>
|
||||
<div style="font-size: 15px; background: #f8f9fa; padding: 12px; border: 1px solid #ddd; border-radius: 4px; margin-bottom: 10px;">
|
||||
<div style="margin-bottom: 5px;">systemctl restart corosync-qdevice</div>
|
||||
<div style="margin-bottom: 5px;">sleep 5</div>
|
||||
<div>corosync-qdevice-tool -s</div>
|
||||
</div>
|
||||
|
||||
<h4 style="font-size: 16px; margin-top: 15px; margin-bottom: 8px;">Step 2 - Verify status:</h4>
|
||||
<div style="font-size: 15px; background: #f8f9fa; padding: 12px; border: 1px solid #ddd; border-radius: 4px; margin-bottom: 10px;">
|
||||
<div>pvecm status</div>
|
||||
</div>
|
||||
<p style="font-size: 16px; margin-bottom: 15px;"><strong>LOOK FOR:</strong> Total votes: 3 (not 2!) and Qdevice (votes 1)</p>
|
||||
|
||||
<p style="font-size: 16px; background: #f8d7da; padding: 12px; border-radius: 4px; margin-top: 15px;"><strong>Bottom line:</strong> The cluster works now but has no tie-breaker vote.<br>
|
||||
One node failure = no quorum = VMs can't migrate.</p>
|
||||
|
||||
{{else}}
|
||||
<p style="font-size: 16px; background: #d4edda; padding: 12px; border-radius: 4px; margin-top: 15px;"><strong>All HA components are functioning normally:</strong></p>
|
||||
<ul style="font-size: 16px; margin-top: 10px;">
|
||||
<li>Cluster has proper quorum with qdevice participation</li>
|
||||
<li>Automatic VM migration is available</li>
|
||||
<li>System is fully redundant</li>
|
||||
</ul>
|
||||
{{/if}}
|
||||
|
||||
<h3 style="font-size: 18px; margin-top: 30px; margin-bottom: 10px;">MANUAL SCRIPT EXECUTION</h3>
|
||||
<p style="font-size: 16px; margin-bottom: 10px;">To run this HA status check manually:</p>
|
||||
|
||||
<p style="font-size: 16px; margin-bottom: 8px;"><strong>Basic check:</strong></p>
|
||||
<div style="font-size: 15px; background: #f8f9fa; padding: 8px; border: 1px solid #ddd; border-radius: 4px; margin-bottom: 10px;">
|
||||
/opt/scripts/ha-monitor.sh
|
||||
</div>
|
||||
|
||||
<p style="font-size: 16px; margin-bottom: 8px;"><strong>Verbose output:</strong></p>
|
||||
<div style="font-size: 15px; background: #f8f9fa; padding: 8px; border: 1px solid #ddd; border-radius: 4px; margin-bottom: 10px;">
|
||||
/opt/scripts/ha-monitor.sh -v
|
||||
</div>
|
||||
|
||||
<p style="font-size: 16px; margin-bottom: 8px;"><strong>Recreate templates:</strong></p>
|
||||
<div style="font-size: 15px; background: #f8f9fa; padding: 8px; border: 1px solid #ddd; border-radius: 4px; margin-bottom: 15px;">
|
||||
/opt/scripts/ha-monitor.sh --create-templates
|
||||
</div>
|
||||
|
||||
<p style="font-size: 16px; margin-bottom: 20px;"><strong>Script location:</strong> /opt/scripts/ha-monitor.sh<br>
|
||||
<strong>Log file:</strong> /var/log/pve-ha-monitor.log</p>
|
||||
|
||||
<p style="font-size: 16px; margin-top: 20px;"><strong>Total check time:</strong> {{ runtime }}s</p>
|
||||
|
||||
</div>
|
||||
EOF
|
||||
|
||||
echo "Templates created successfully."
|
||||
}
|
||||
|
||||
# Creează template-urile la prima rulare sau dacă nu există
|
||||
if [ ! -f "/etc/pve/notification-templates/default/ha-status-subject.txt.hbs" ]; then
|
||||
create_templates
|
||||
fi
|
||||
|
||||
# Verificare HA status
|
||||
check_ha_status() {
|
||||
local status_ok=true
|
||||
local details=""
|
||||
|
||||
# Verifică serviciile HA
|
||||
if systemctl is-active --quiet pve-ha-lrm && systemctl is-active --quiet pve-ha-crm; then
|
||||
details+="HA Services: OK\n"
|
||||
else
|
||||
details+="HA Services: ERROR - Services not running\n"
|
||||
details+=" Recovery: systemctl restart pve-ha-lrm pve-ha-crm\n"
|
||||
status_ok=false
|
||||
fi
|
||||
|
||||
# Verifică quorum și qdevice
|
||||
quorum_info=$(corosync-quorumtool -s 2>/dev/null)
|
||||
pvecm_info=$(pvecm status 2>/dev/null)
|
||||
|
||||
if echo "$quorum_info" | grep -q "Quorate:.*Yes"; then
|
||||
expected_votes=$(echo "$quorum_info" | grep "Expected votes:" | awk '{print $3}')
|
||||
total_votes=$(echo "$quorum_info" | grep "Total votes:" | awk '{print $3}')
|
||||
|
||||
# Verifică qdevice prin pvecm status - caută linia cu "Qdevice"
|
||||
qdevice_votes=$(echo "$pvecm_info" | grep -E "^[[:space:]]*0x00000000[[:space:]]+1[[:space:]]+Qdevice" | awk '{print $2}')
|
||||
|
||||
if [ "$total_votes" = "$expected_votes" ] && [ "$qdevice_votes" = "1" ]; then
|
||||
details+="Quorum: OK ($total_votes/$expected_votes votes, Qdevice participating)\n"
|
||||
elif [ "$total_votes" = "$expected_votes" ]; then
|
||||
details+="Quorum: OK ($total_votes/$expected_votes votes)\n"
|
||||
else
|
||||
details+="Quorum: WARNING ($total_votes/$expected_votes votes)\n"
|
||||
details+=" Check: pvecm status for qdevice participation\n"
|
||||
status_ok=false
|
||||
fi
|
||||
else
|
||||
details+="Quorum: ERROR - Cluster not quorate\n"
|
||||
details+=" Check: pvecm status && corosync-quorumtool -s\n"
|
||||
status_ok=false
|
||||
fi
|
||||
|
||||
# Verifică conectivitatea qdevice
|
||||
qdevice_status=$(corosync-qdevice-tool -s 2>/dev/null)
|
||||
if echo "$qdevice_status" | grep -q "State:.*Connected"; then
|
||||
qnetd_host=$(echo "$qdevice_status" | grep "QNetd host:" | awk '{print $3}')
|
||||
details+="Qdevice Connection: OK ($qnetd_host)\n"
|
||||
else
|
||||
details+="Qdevice Connection: WARNING - Disconnected\n"
|
||||
details+=" Recovery: systemctl restart corosync-qdevice\n"
|
||||
status_ok=false
|
||||
fi
|
||||
|
||||
# Verifică nodurile prin pvecm status
|
||||
nodes_online=$(echo "$pvecm_info" | grep -c "A,V,NMW")
|
||||
|
||||
if [ "$nodes_online" -ge 2 ]; then
|
||||
details+="Cluster Nodes: OK ($nodes_online nodes online)\n"
|
||||
else
|
||||
details+="Cluster Nodes: ERROR - Only $nodes_online nodes online\n"
|
||||
details+=" Check: pvecm nodes && ping [offline-node-ip]\n"
|
||||
status_ok=false
|
||||
fi
|
||||
|
||||
# Adaugă secțiune de recovery doar pentru cazurile de eroare
|
||||
if ! $status_ok; then
|
||||
details+="\n=== IMMEDIATE ACTIONS REQUIRED ===\n"
|
||||
details+="1. SSH to cluster: ssh root@$(hostname -f)\n"
|
||||
details+="2. Check overall status: pvecm status\n"
|
||||
details+="3. Review HA logs: journalctl -u pve-ha-lrm -u pve-ha-crm -n 20\n"
|
||||
details+="4. Check network connectivity between nodes\n"
|
||||
fi
|
||||
|
||||
if $status_ok; then
|
||||
echo "SUCCESSFUL"
|
||||
else
|
||||
echo "FAILED"
|
||||
fi
|
||||
echo -e "$details"
|
||||
}
|
||||
|
||||
# Execută verificarea
|
||||
RESULT=$(check_ha_status)
|
||||
STATUS=$(echo "$RESULT" | head -n 1)
|
||||
DETAILS=$(echo "$RESULT" | tail -n +2)
|
||||
|
||||
# Calculează timpul
|
||||
END_TIME=$(date +%s)
|
||||
RUNTIME=$((END_TIME - START_TIME))
|
||||
|
||||
# Determină severity
|
||||
if [ "$STATUS" = "SUCCESSFUL" ]; then
|
||||
SEVERITY="info"
|
||||
else
|
||||
SEVERITY="error"
|
||||
fi
|
||||
|
||||
# Trimite notificarea prin PVE::Notify cu tipul "ha-status"
|
||||
perl -I/usr/share/perl5 << EOF
|
||||
use strict;
|
||||
use warnings;
|
||||
use PVE::Notify;
|
||||
|
||||
# Date pentru template (în format JSON-like pentru Perl)
|
||||
my \$template_data = {
|
||||
'hostname' => '$FQDN',
|
||||
'status' => '$STATUS',
|
||||
'runtime' => '$RUNTIME',
|
||||
'details' => '$DETAILS'
|
||||
};
|
||||
|
||||
# Metadata pentru matcher
|
||||
my \$fields = {
|
||||
'hostname' => '$HOSTNAME',
|
||||
'type' => 'ha-status',
|
||||
'status' => '$STATUS'
|
||||
};
|
||||
|
||||
# Trimite notificarea cu tipul "ha-status"
|
||||
# Va folosi template-urile din /etc/pve/notification-templates/default/ha-status-*
|
||||
eval {
|
||||
PVE::Notify::notify('$SEVERITY', 'ha-status', \$template_data, \$fields);
|
||||
print "Notification sent successfully\\n";
|
||||
};
|
||||
if (\$@) {
|
||||
print STDERR "Failed to send notification: \$@\\n";
|
||||
exit 1;
|
||||
}
|
||||
EOF
|
||||
|
||||
PERL_EXIT_CODE=$?
|
||||
|
||||
# Log local
|
||||
echo "$(date): HA status check completed - $STATUS, notification exit code: $PERL_EXIT_CODE" >> /var/log/pve-ha-monitor.log
|
||||
|
||||
# Output pentru testare
|
||||
if [ "$1" == "--verbose" ] || [ "$1" == "-v" ]; then
|
||||
echo "=== HA MONITOR REPORT ==="
|
||||
echo "Status: $STATUS"
|
||||
echo "Runtime: ${RUNTIME}s"
|
||||
echo "Severity: $SEVERITY"
|
||||
echo "Perl exit code: $PERL_EXIT_CODE"
|
||||
echo
|
||||
echo "Details:"
|
||||
echo "$DETAILS"
|
||||
echo
|
||||
echo "Using template: ha-status"
|
||||
echo "Template data: hostname=$FQDN, status=$STATUS, runtime=${RUNTIME}s"
|
||||
elif [ "$1" == "--create-templates" ] || [ "$1" == "--templates" ]; then
|
||||
create_templates
|
||||
echo "Templates recreated successfully."
|
||||
echo "Run './ha-monitor.sh -v' to test with new templates."
|
||||
exit 0
|
||||
fi
|
||||
225
proxmox/proxmox-ssh-guide.md
Normal file
225
proxmox/proxmox-ssh-guide.md
Normal file
@@ -0,0 +1,225 @@
|
||||
# Ghid Conexiune SSH la Nod Proxmox
|
||||
|
||||
## Informații Generale
|
||||
- **IP Nod Proxmox:** 10.0.20.201
|
||||
- **Hostname:** pvemini
|
||||
- **Versiune:** pve-manager/8.4.12/c2ea8261d32a5020 (kernel: 6.8.12-14-pve)
|
||||
- **Utilizator:** root
|
||||
|
||||
## Configurare Inițială SSH
|
||||
|
||||
### 1. Generare Cheie SSH (din WSL/Linux)
|
||||
```bash
|
||||
# Generează cheie SSH RSA 4096-bit
|
||||
ssh-keygen -t rsa -b 4096 -C "your-email@example.com"
|
||||
|
||||
# Locația default: ~/.ssh/id_rsa
|
||||
# Apasă Enter pentru locația default
|
||||
# Setează parolă opțională pentru cheie
|
||||
```
|
||||
|
||||
### 2. Copierea Cheii pe Proxmox
|
||||
```bash
|
||||
# Metoda automată
|
||||
ssh-copy-id root@10.0.20.201
|
||||
|
||||
# Metoda manuală
|
||||
cat ~/.ssh/id_rsa.pub | ssh root@10.0.20.201 "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"
|
||||
```
|
||||
|
||||
### 3. Testare Conexiune
|
||||
```bash
|
||||
ssh root@10.0.20.201
|
||||
```
|
||||
|
||||
## Storage Configuration
|
||||
|
||||
### Storage-uri Disponibile
|
||||
| Storage | Tip | Conținut | Capacitate | Utilizare |
|
||||
|---------|-----|----------|------------|-----------|
|
||||
| `backup` | dir | backup,snippets,rootdir,images,import,iso,vztmpl | 1.79 TiB | 174.99 GiB (9.55%) |
|
||||
| `backup-ssd` | dir | images,snippets,rootdir,backup,vztmpl,iso | 0.00 B | Dezactivat |
|
||||
| `local` | dir | iso,backup,vztmpl | 1.54 TiB | 128.00 KiB |
|
||||
| `local-zfs` | zfspool | rootdir,images | 1.54 TiB | 217.65 GiB (12.12%) |
|
||||
| `backup-nfs` | nfs | backup,snippets,images,iso,vztmpl | 1.53 TiB | 174.99 GiB (9.55%) |
|
||||
|
||||
### Căi Storage
|
||||
- **Backup local:** `/var/lib/vz/dump/`
|
||||
- **Backup NFS:** `/mnt/pve/backup-nfs/dump/`
|
||||
- **ISO-uri:** `/mnt/pve/backup-nfs/template/iso/`
|
||||
|
||||
## Comenzi Utile Proxmox
|
||||
|
||||
### Gestiune VM-uri
|
||||
```bash
|
||||
# Listare toate VM-urile
|
||||
qm list
|
||||
|
||||
# Status VM specific
|
||||
qm status <VMID>
|
||||
|
||||
# Start/Stop/Restart VM
|
||||
qm start <VMID>
|
||||
qm stop <VMID>
|
||||
qm restart <VMID>
|
||||
|
||||
# Configurație VM
|
||||
qm config <VMID>
|
||||
|
||||
# Modificare configurație
|
||||
qm set <VMID> --memory 4096 --cores 2
|
||||
```
|
||||
|
||||
### Gestiune LXC Containers
|
||||
```bash
|
||||
# Listare containere
|
||||
pct list
|
||||
|
||||
# Status container
|
||||
pct status <CTID>
|
||||
|
||||
# Start/Stop container
|
||||
pct start <CTID>
|
||||
pct stop <CTID>
|
||||
|
||||
# Configurație container
|
||||
pct config <CTID>
|
||||
|
||||
# Intrare în container
|
||||
pct enter <CTID>
|
||||
```
|
||||
|
||||
### Gestiune Storage
|
||||
```bash
|
||||
# Listare storage-uri
|
||||
pvesm status
|
||||
|
||||
# Conținut storage
|
||||
pvesm list <storage_name>
|
||||
|
||||
# Spațiu disponibil
|
||||
pvesm list local-zfs
|
||||
|
||||
# Ștergere volum
|
||||
pvesm free <volume_id>
|
||||
```
|
||||
|
||||
### Gestiune Backup-uri
|
||||
```bash
|
||||
# Listare backup-uri
|
||||
pvesh get /cluster/backup
|
||||
|
||||
# Backup manual VM
|
||||
vzdump <VMID> --storage backup --compress gzip
|
||||
|
||||
# Restore backup
|
||||
qmrestore /path/to/backup.vma.gz <VMID> --storage local-zfs
|
||||
|
||||
# Căutare backup-uri pentru VM specific
|
||||
find /mnt/pve/backup-nfs/dump/ -name "*<VMID>*" | sort -V
|
||||
```
|
||||
|
||||
## Configurații Hardware Recomandate
|
||||
|
||||
### Pentru VM Windows 11
|
||||
```bash
|
||||
qm set <VMID> --cpu host --cores 2 --memory 4096 --kvm 1
|
||||
qm set <VMID> --machine q35 --bios ovmf --ostype win11
|
||||
qm set <VMID> --net0 e1000=<MAC>,bridge=vmbr0,firewall=1
|
||||
qm set <VMID> --virtio0 local-zfs:80,format=raw
|
||||
```
|
||||
|
||||
### Pentru VM Windows 7/10
|
||||
```bash
|
||||
qm set <VMID> --cpu host --cores 2 --memory 4096 --kvm 1
|
||||
qm set <VMID> --machine pc-i440fx-2.12 --bios seabios --ostype win10
|
||||
qm set <VMID> --net0 virtio=<MAC>,bridge=vmbr0,firewall=1
|
||||
qm set <VMID> --virtio0 local-zfs:60,format=raw
|
||||
```
|
||||
|
||||
### Pentru LXC Ubuntu/Debian
|
||||
```bash
|
||||
pct set <CTID> --cores 2 --memory 2048
|
||||
pct set <CTID> --net0 name=eth0,bridge=vmbr0,ip=dhcp,type=veth
|
||||
pct set <CTID> --rootfs local-zfs:20
|
||||
```
|
||||
|
||||
## Template-uri și ISO-uri Disponibile
|
||||
|
||||
### Windows ISO-uri
|
||||
- `Win11_24H2_Original.iso` - Windows 11 original (5.8GB)
|
||||
- `windows11rufus.iso` - Windows 11 modificat cu Rufus (5.8GB)
|
||||
- `windows10.iso` - Windows 10 (4.6GB)
|
||||
|
||||
### Drivere
|
||||
- `virtio-win-0.1.141.iso` - Drivere VirtIO pentru Windows
|
||||
|
||||
## Rețea
|
||||
|
||||
### Configurația Bridge
|
||||
- **Bridge:** vmbr0
|
||||
- **Subnet:** 10.0.20.0/24
|
||||
- **Gateway:** 10.0.20.1 (presumptiv)
|
||||
|
||||
### IP-uri Utilizate
|
||||
- **Proxmox Node:** 10.0.20.201
|
||||
- **VM 107:** 10.0.20.107 (Windows 7)
|
||||
- **VM 201:** 10.0.20.124 (Windows 11 - planificat)
|
||||
|
||||
## Backup Job Configuration
|
||||
|
||||
### Job ID: backup-fbb668c0-726e
|
||||
- **Schedule:** Daily la 02:00
|
||||
- **Compression:** zstd
|
||||
- **Mode:** snapshot
|
||||
- **Storage:** backup
|
||||
- **VM-uri incluse:** 100,101,102,104,106,107
|
||||
- **Retention:** 1 daily, 1 weekly
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Probleme Comune SSH
|
||||
```bash
|
||||
# Regenerare host keys dacă e nevoie
|
||||
ssh-keygen -R 10.0.20.201
|
||||
|
||||
# Conectare cu debug
|
||||
ssh -v root@10.0.20.201
|
||||
|
||||
# Test conectivitate
|
||||
ping 10.0.20.201
|
||||
```
|
||||
|
||||
### Probleme VM Windows 11
|
||||
```bash
|
||||
# Bypass cerințe TPM/Secure Boot în setup
|
||||
reg add "HKLM\SYSTEM\Setup\LabConfig" /v "BypassTPMCheck" /t REG_DWORD /d 1 /f
|
||||
reg add "HKLM\SYSTEM\Setup\LabConfig" /v "BypassSecureBootCheck" /t REG_DWORD /d 1 /f
|
||||
reg add "HKLM\SYSTEM\Setup\LabConfig" /v "BypassRAMCheck" /t REG_DWORD /d 1 /f
|
||||
|
||||
# Forțare cont local în OOBE
|
||||
oobe\BypassNRO.cmd
|
||||
```
|
||||
|
||||
### Verificare Status Servicii
|
||||
```bash
|
||||
# Status servicii Proxmox
|
||||
systemctl status pveproxy
|
||||
systemctl status pvedaemon
|
||||
systemctl status pvestatd
|
||||
|
||||
# Restart servicii dacă e nevoie
|
||||
systemctl restart pveproxy
|
||||
```
|
||||
|
||||
## Web Interface
|
||||
- **URL:** https://10.0.20.201:8006
|
||||
- **Utilizator:** root
|
||||
- **Port:** 8006 (HTTPS)
|
||||
|
||||
## Note Importante
|
||||
1. **Întotdeauna fă backup** înainte de modificări majore
|
||||
2. **Folosește storage local-zfs** pentru performanță optimă
|
||||
3. **Pentru Windows 11** folosește placa de rețea e1000 în loc de VirtIO pentru compatibilitate
|
||||
4. **CPU type 'host'** oferă performanțe maxime cu KVM=1
|
||||
5. **Testează conexiunea SSH** înainte de automatizări
|
||||
65
proxmox/vm107-monitor.sh
Normal file
65
proxmox/vm107-monitor.sh
Normal file
@@ -0,0 +1,65 @@
|
||||
#!/bin/bash
|
||||
|
||||
HOSTNAME=$(hostname)
|
||||
DATE=$(date '+%Y-%m-%d %H:%M:%S')
|
||||
VM_ID=107
|
||||
LOG_FILE="/var/log/vm107-monitor.log"
|
||||
|
||||
check_vm_status() {
|
||||
local vm_status=$(qm status $VM_ID 2>/dev/null | grep -oP 'status: \K.*')
|
||||
|
||||
if [ -z "$vm_status" ]; then
|
||||
echo "ERROR:VM_NOT_FOUND"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ "$vm_status" = "running" ]; then
|
||||
if ps aux | grep -E "(kvm|qemu).*-id $VM_ID" | grep -qv grep; then
|
||||
echo "RUNNING:OK"
|
||||
return 0
|
||||
else
|
||||
echo "ERROR:PROCESS_MISSING"
|
||||
return 1
|
||||
fi
|
||||
elif [ "$vm_status" = "stopped" ]; then
|
||||
echo "STOPPED:VM_STOPPED"
|
||||
return 1
|
||||
elif [ "$vm_status" = "internal-error" ]; then
|
||||
echo "ERROR:INTERNAL_ERROR"
|
||||
return 1
|
||||
else
|
||||
echo "ERROR:UNKNOWN_STATE:$vm_status"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
RESULT=$(check_vm_status)
|
||||
CHECK_EXIT=$?
|
||||
|
||||
STATUS=$(echo "$RESULT" | cut -d: -f1)
|
||||
ERROR_TYPE=$(echo "$RESULT" | cut -d: -f2)
|
||||
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S'): VM $VM_ID status: $STATUS ($ERROR_TYPE)" >> "$LOG_FILE"
|
||||
|
||||
if [ $CHECK_EXIT -ne 0 ]; then
|
||||
SUBJECT="VM $VM_ID $STATUS on $HOSTNAME"
|
||||
BODY="VM $VM_ID Status: $STATUS\n"
|
||||
BODY+="Error Type: $ERROR_TYPE\n"
|
||||
BODY+="Check Time: $DATE\n"
|
||||
BODY+="Host: $HOSTNAME\n\n"
|
||||
|
||||
if [ "$STATUS" = "STOPPED" ]; then
|
||||
BODY+="VM is stopped. To start: qm start $VM_ID"
|
||||
elif [ "$ERROR_TYPE" = "INTERNAL_ERROR" ]; then
|
||||
BODY+="VM has internal-error (KVM crash)."
|
||||
elif [ "$ERROR_TYPE" = "PROCESS_MISSING" ]; then
|
||||
BODY+="VM marked as running but process missing."
|
||||
fi
|
||||
|
||||
# Trimite email simplu prin mail command
|
||||
echo -e "$BODY" | mail -s "$SUBJECT" root
|
||||
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S'): Email sent for VM $VM_ID $STATUS" >> "$LOG_FILE"
|
||||
fi
|
||||
|
||||
exit $CHECK_EXIT
|
||||
Reference in New Issue
Block a user