Update production scripts with optimized settings
- VM creation: Updated for vmbr1 network and pve-main NVMe storage - VM specs: 6 CPU cores, 16GB RAM, 150GB disk - Added NUMA optimization for dual-socket Xeon - Backup manager: Updated backup path to TrueNAS mount - Added validation checks for storage and network - Added TRIM support for SSD optimization
This commit is contained in:
parent
f037b852f5
commit
fc4d6c3204
|
|
@ -6,7 +6,7 @@
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
BACKUP_ROOT="/mnt/nas/backups/mission-control"
|
BACKUP_ROOT="/mnt/truenas/backups/mission-control"
|
||||||
DB_SOURCE="/home/devmatrix/mission-control/data/mission-control.db"
|
DB_SOURCE="/home/devmatrix/mission-control/data/mission-control.db"
|
||||||
CONFIG_SOURCE="/home/devmatrix/mission-control"
|
CONFIG_SOURCE="/home/devmatrix/mission-control"
|
||||||
LOG_FILE="/var/log/mission-control/backup.log"
|
LOG_FILE="/var/log/mission-control/backup.log"
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,20 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Proxmox Production VM Creator
|
# Proxmox Production VM Creator - Optimized for DevMatrix
|
||||||
# Run this on the Proxmox host as root
|
# Run this on the Proxmox host as root
|
||||||
# Source: https://git.lemonlink.eu/devmatrix/devmatrix-scripts
|
# Source: https://git.lemonlink.eu/devmatrix/devmatrix-scripts
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# Configuration
|
# Configuration - EDIT THESE FOR YOUR ENVIRONMENT
|
||||||
VM_ID=101
|
VM_ID=201 # Changed from 101 (already exists)
|
||||||
VM_NAME="DevMatrix-Prod"
|
VM_NAME="DevMatrix-Prod"
|
||||||
VM_IP="192.168.5.211/24"
|
VM_IP="192.168.5.211/24"
|
||||||
VM_GW="192.168.5.1"
|
VM_GW="192.168.5.1"
|
||||||
VM_CPU=4
|
VM_CPU=6 # 6 cores (plenty for production)
|
||||||
VM_RAM=8192 # 8GB
|
VM_RAM=16384 # 16GB RAM (you have 94GB available)
|
||||||
VM_DISK=100 # GB
|
VM_DISK=150 # 150GB on NVMe (pve-main)
|
||||||
STORAGE="local-lvm" # Change to your storage
|
STORAGE="pve-main" # Your NVMe storage
|
||||||
BRIDGE="vmbr0"
|
BRIDGE="vmbr1" # Your network bridge
|
||||||
|
|
||||||
# Colors
|
# Colors
|
||||||
RED='\033[0;31m'
|
RED='\033[0;31m'
|
||||||
|
|
@ -38,15 +38,30 @@ if qm status $VM_ID > /dev/null 2>&1; then
|
||||||
error "VM $VM_ID already exists!"
|
error "VM $VM_ID already exists!"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Check if storage exists
|
||||||
|
if ! pvesm status | grep -q "$STORAGE"; then
|
||||||
|
error "Storage '$STORAGE' not found! Available storages:"
|
||||||
|
pvesm status
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if bridge exists
|
||||||
|
if ! ip link show "$BRIDGE" > /dev/null 2>&1; then
|
||||||
|
error "Bridge '$BRIDGE' not found! Available bridges:"
|
||||||
|
ip link show | grep "vmbr"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
log "🚀 Creating DevMatrix Production VM"
|
log "🚀 Creating DevMatrix Production VM"
|
||||||
log "===================================="
|
log "===================================="
|
||||||
log ""
|
log ""
|
||||||
log "Configuration:"
|
log "Configuration:"
|
||||||
log " VM ID: $VM_ID"
|
log " VM ID: $VM_ID"
|
||||||
log " Name: $VM_NAME"
|
log " Name: $VM_NAME"
|
||||||
log " CPU: $VM_CPU cores"
|
log " CPU: $VM_CPU cores (Intel Xeon E5645)"
|
||||||
log " RAM: $((VM_RAM / 1024))GB"
|
log " RAM: $((VM_RAM / 1024))GB"
|
||||||
log " Disk: ${VM_DISK}GB"
|
log " Disk: ${VM_DISK}GB ($STORAGE NVMe)"
|
||||||
|
log " Network: $BRIDGE"
|
||||||
log " IP: $VM_IP"
|
log " IP: $VM_IP"
|
||||||
log ""
|
log ""
|
||||||
|
|
||||||
|
|
@ -66,49 +81,68 @@ if [ ! -f "$CLOUD_IMAGE" ]; then
|
||||||
success "Downloaded Ubuntu cloud image"
|
success "Downloaded Ubuntu cloud image"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create VM
|
# Create VM with optimized settings
|
||||||
log "Creating VM..."
|
log "Creating VM with optimized settings..."
|
||||||
qm create $VM_ID \
|
qm create $VM_ID \
|
||||||
--name "$VM_NAME" \
|
--name "$VM_NAME" \
|
||||||
--memory $VM_RAM \
|
--memory $VM_RAM \
|
||||||
--balloon 0 \
|
--balloon 0 \
|
||||||
--cores $VM_CPU \
|
--cores $VM_CPU \
|
||||||
--cpu cputype=host \
|
--cpu cputype=host \
|
||||||
--net0 virtio,bridge=$BRIDGE \
|
--sockets 2 \
|
||||||
|
--numa 1 \
|
||||||
|
--net0 virtio,bridge=$BRIDGE,firewall=1 \
|
||||||
--scsihw virtio-scsi-single \
|
--scsihw virtio-scsi-single \
|
||||||
--ostype l26 \
|
--ostype l26 \
|
||||||
--agent enabled=1
|
--agent enabled=1,fstrim_cloned_disks=1 \
|
||||||
|
--cpuunits 2048 \
|
||||||
|
--onboot 1
|
||||||
|
|
||||||
# Import disk
|
# Import disk to NVMe storage
|
||||||
log "Importing disk..."
|
log "Importing disk to $STORAGE..."
|
||||||
qm importdisk $VM_ID "$CLOUD_IMAGE" $STORAGE --format qcow2
|
qm importdisk $VM_ID "$CLOUD_IMAGE" $STORAGE --format qcow2
|
||||||
|
|
||||||
# Attach disk
|
# Attach disk with discard for TRIM support
|
||||||
qm set $VM_ID --scsi0 ${STORAGE}:vm-${VM_ID}-disk-0
|
qm set $VM_ID --scsi0 ${STORAGE}:vm-${VM_ID}-disk-0,discard=on,iothread=1
|
||||||
|
|
||||||
# Resize disk
|
# Resize disk
|
||||||
log "Resizing disk to ${VM_DISK}GB..."
|
log "Resizing disk to ${VM_DISK}GB..."
|
||||||
qm disk resize $VM_ID scsi0 ${VM_DISK}G
|
qm disk resize $VM_ID scsi0 ${VM_DISK}G
|
||||||
|
|
||||||
# Create CloudInit drive
|
# Create CloudInit drive on same storage
|
||||||
log "Configuring CloudInit..."
|
log "Configuring CloudInit..."
|
||||||
qm set $VM_ID --ide2 ${STORAGE}:cloudinit
|
qm set $VM_ID --ide2 ${STORAGE}:cloudinit
|
||||||
|
|
||||||
# Set boot order
|
# Set boot order
|
||||||
qm set $VM_ID --boot order=scsi0
|
qm set $VM_ID --boot order=scsi0
|
||||||
|
|
||||||
# Configure serial
|
# Configure serial for console
|
||||||
qm set $VM_ID --serial0 socket --vga serial0
|
qm set $VM_ID --serial0 socket --vga serial0
|
||||||
|
|
||||||
# Set IP configuration
|
# Set IP configuration
|
||||||
qm set $VM_ID --ipconfig0 ip=$VM_IP,gw=$VM_GW
|
qm set $VM_ID --ipconfig0 ip=$VM_IP,gw=$VM_GW
|
||||||
|
|
||||||
# Set user/password (change these!)
|
# Set user/password
|
||||||
qm set $VM_ID --ciuser devmatrix
|
qm set $VM_ID --ciuser devmatrix
|
||||||
qm set $VM_ID --cipassword $(openssl rand -base64 16)
|
qm set $VM_ID --cipassword $(openssl rand -base64 24)
|
||||||
|
|
||||||
# Enable QEMU agent
|
# Configure SSH keys if available
|
||||||
qm set $VM_ID --agent enabled=1
|
if [ -f "/root/.ssh/authorized_keys" ]; then
|
||||||
|
log "Adding SSH keys from host..."
|
||||||
|
qm set $VM_ID --sshkeys < /root/.ssh/authorized_keys
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Enable QEMU agent with full features
|
||||||
|
qm set $VM_ID --agent enabled=1,fstrim_cloned_disks=1,type=virtio
|
||||||
|
|
||||||
|
# Add tags for organization
|
||||||
|
qm set $VM_ID --tags production,mission-control,devmatrix
|
||||||
|
|
||||||
|
# Set start at boot
|
||||||
|
qm set $VM_ID --onboot 1
|
||||||
|
|
||||||
|
# Configure backups (will use Proxmox backup settings)
|
||||||
|
log "Configuring backup options..."
|
||||||
|
|
||||||
# Start VM
|
# Start VM
|
||||||
log "Starting VM..."
|
log "Starting VM..."
|
||||||
|
|
@ -125,13 +159,24 @@ log " ID: $VM_ID"
|
||||||
log " Name: $VM_NAME"
|
log " Name: $VM_NAME"
|
||||||
log " IP: $VM_IP"
|
log " IP: $VM_IP"
|
||||||
log " Console: https://$(hostname -I | awk '{print $1}'):8006/#v1:0:=$VM_ID"
|
log " Console: https://$(hostname -I | awk '{print $1}'):8006/#v1:0:=$VM_ID"
|
||||||
|
log " Storage: $STORAGE (NVMe)"
|
||||||
|
log " Network: $BRIDGE"
|
||||||
log ""
|
log ""
|
||||||
log "Next steps:"
|
log "Next steps:"
|
||||||
log "1. Open console and get IP: qm console $VM_ID"
|
log "1. Open console: qm console $VM_ID"
|
||||||
log "2. SSH into VM: ssh devmatrix@192.168.5.211"
|
log "2. SSH into VM: ssh devmatrix@192.168.5.211"
|
||||||
log "3. Run setup: curl -fsSL https://git.lemonlink.eu/devmatrix/devmatrix-scripts/raw/branch/main/proxmox/setup-production-vm.sh | sudo bash"
|
log "3. Run setup script"
|
||||||
log ""
|
log ""
|
||||||
log "To view VM status:"
|
log "To view VM status:"
|
||||||
log " qm status $VM_ID"
|
log " qm status $VM_ID"
|
||||||
log " qm list"
|
log " qm list"
|
||||||
log ""
|
log ""
|
||||||
|
log "Optimization notes:"
|
||||||
|
log " ✓ 6 CPU cores (NUMA optimized)"
|
||||||
|
log " ✓ 16GB RAM (dedicated, no ballooning)"
|
||||||
|
log " ✓ 150GB NVMe storage (TRIM enabled)"
|
||||||
|
log " ✓ 2 sockets for better NUMA performance"
|
||||||
|
log " ✓ High CPU priority (2048)"
|
||||||
|
log " ✓ Auto-start on boot"
|
||||||
|
log " ✓ QEMU guest agent enabled"
|
||||||
|
log ""
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue