Proxmox Cluster cho phép bạn gộp nhiều Proxmox VE nodes thành một hệ thống duy nhất, quản lý tập trung từ một giao diện web, chia sẻ storage và di chuyển VMs giữa các nodes mà không downtime. Kết hợp với High Availability (HA), khi một node bị sự cố, VMs sẽ tự động restart trên node khác — đảm bảo business continuity và giảm thiểu downtime.
Trong bài viết này, mình sẽ hướng dẫn bạn từng bước xây dựng Proxmox Cluster với HA: từ chuẩn bị network, tạo cluster, thêm nodes, cấu hình shared storage, thiết lập HA resources, cho đến test failover và troubleshooting. Bài viết phù hợp cho cả người mới bắt đầu lẫn admin cần triển khai production.
Proxmox Cluster hoạt động như thế nào?
Proxmox Cluster sử dụng Corosync làm cluster engine — chịu trách nhiệm giao tiếp giữa các nodes, bầu chọn master (quorum), và phát hiện node failure. Mỗi node trong cluster liên tục gửi heartbeat message cho các node khác. Nếu một node không phản hồi trong khoảng thời gian quy định, cluster sẽ coi node đó đã down và kích hoạt HA failover.
Quorum là cơ chế đảm bảo chỉ một phần cluster được phép điều khiển tài nguyên tại một thời điểm. Để đạt quorum, cần đa số nodes online (majority). Ví dụ: cluster 3 nodes cần ít nhất 2 nodes online, cluster 5 nodes cần 3. Đây là lý do khuyến nghị dùng tối thiểu 3 nodes — nếu chỉ có 2 nodes và 1 node down, cluster mất quorum và HA không hoạt động.
Fencing (hay watchdog) ngăn chặn tình huống split-brain — khi node bị cô lập vẫn nghĩ mình đang hoạt động bình thường và tiếp tục chạy VMs, trong khi các node khác cũng đang chạy cùng VMs. Fencing đảm bảo node bị cô lập sẽ tự restart, tránh xung đột dữ liệu.
Yêu cầu trước khi cài đặt
Phần cứng
- Tối thiểu 3 nodes (đảm bảo quorum majority). Có thể dùng 2 nodes nhưng cần external quorum witness.
- Mỗi node: CPU 4+ cores, RAM 16GB+, disk đủ cho VMs và Ceph OSDs (nếu dùng Ceph)
- Network: Tối thiểu 2 NICs — 1 cho production traffic, 1 riêng cho Corosync cluster communication
- Shared storage: Ceph (khuyến nghị), NFS, iSCSI, hoặc ZFS over iSCSI
Phần mềm và Network
- Proxmox VE 8.x đã cài đặt trên tất cả nodes
- Hostname unique cho mỗi node (không trùng)
- DNS resolution hoạt động giữa các nodes (hoặc dùng /etc/hosts)
- NTP đồng bộ thời gian trên tất cả nodes (chrony hoặc ntpd)
- SSH key-based authentication giữa các nodes
Bước 1: Chuẩn bị Network cho Cluster
Khuyến nghị dùng network riêng cho Corosync traffic, tách biệt với production network. Điều này giúp cluster communication không bị ảnh hưởng bởi production workload.
# Trên mỗi node, cấu hình dedicated network cho cluster
# /etc/network/interfaces
auto eno2
iface eno2 inet static
address 10.10.10.11/24 # Node 1
# address 10.10.10.12/24 # Node 2
# address 10.10.10.13/24 # Node 3
# Firewall rules — mở ports cần thiết cho cluster
# Port 5405-5406: Corosync (UDP)
# Port 22: SSH
# Port 8006: Proxmox Web UI
iptables -A INPUT -p udp --dport 5405:5406 -j ACCEPT
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -p tcp --dport 8006 -j ACCEPT
Bước 2: Tạo Cluster
# Trên Node 1 (primary node) — tạo cluster pvecm create vnhte-cluster --link0 10.10.10.11 # Kiểm tra trạng thái cluster pvecm status # Expected output: # Cluster Name: vnhte-cluster # Quorum: yes # Nodes: 1 # Xem chi tiết cluster pvecm list
Bước 3: Thêm Nodes vào Cluster
Qua Web UI
Trên Node 2 và Node 3, mở Proxmox Web UI → Datacenter → Cluster → Join Cluster. Nhập IP của Node 1, username/password, và cluster name. Node sẽ tự động join vào cluster.
Qua CLI
# Trên Node 2: pvecm add 10.10.10.11 --use_ssh 1 # Trên Node 3: pvecm add 10.10.10.11 --use_ssh 1 # Verify trên bất kỳ node nào: pvecm status # Expected: # Quorum: yes # Nodes: 3 # Xem danh sách nodes pvecm nodes
Lưu ý: Sau khi join cluster, tất cả cluster nodes sẽ đồng bộ cấu hình qua /etc/pve/ — bất kỳ thay đổi nào trên một node đều được replicate sang các nodes khác.
Bước 4: Cấu hình Shared Storage
HA yêu cầu shared storage — VMs phải được lưu trên storage mà tất cả nodes đều truy cập được. Khi node down, node khác có thể mount cùng disk và start VM.
Ceph Storage (Khuyến nghị)
Ceph là distributed storage được tích hợp sẵn trong Proxmox, cung cấp replicated storage mà không cần external NFS/iSCSI server. Mỗi node đóng vai trò vừa là compute vừa là storage.
# Cài đặt Ceph trên tất cả nodes pveceph install # Khởi tạo Ceph cluster (trên Node 1) pveceph init --network 10.10.10.0/24 # Tạo OSDs trên mỗi node (dùng disk riêng cho Ceph) pveceph osd create /dev/sdb # Node 1 pveceph osd create /dev/sdb # Node 2 (SSH sang node 2) pveceph osd create /dev/sdb # Node 3 # Tạo pool cho VMs (replicated 3 copies) pveceph pool create VMStorage --pg_num 64 --size 3 # Thêm Ceph RBD storage vào Proxmox # Datacenter → Storage → Add → RBD # Hoặc CLI: pvesm add rbd ceph-storage --pool VMStorage --content images,rootdir
NFS Storage
# Thêm NFS storage # Datacenter → Storage → Add → NFS # Hoặc CLI: pvesm add nfs shared-storage --server 192.168.1.50 --export /export/vms --content rootdir,images --shared 1 # Verify storage visible trên tất cả nodes pvesm status
Bước 5: Cấu hình High Availability
Tạo HA Group
HA Group xác định tập hợp các nodes mà VMs có thể chạy trên. Bạn có thể tạo nhiều groups cho các workload khác nhau (ví dụ: group production, group development).
# Tạo HA group # Datacenter → HA → Groups → Add # Group ID: production # Nodes: node1,node2,node3 # Restricted: No (VM có thể chạy trên bất kỳ node nào trong group) # Hoặc CLI: ha-manager groupadd production --nodes "node1,node2,node3"
Thêm VM vào HA
# Thêm VM vào HA (tự động restart khi node down) # Datacenter → HA → Resources → Add → Chọn VM # Hoặc CLI: ha-manager add vm:100 --state started --group production # Thêm nhiều VMs ha-manager add vm:101 --state started --group production ha-manager add vm:102 --state started --group production # Kiểm tra trạng thái HA ha-manager status # Expected output: # QUORUM OK # vm:100: started (node1) # vm:101: started (node2) # vm:102: started (node3)
Bước 6: Test HA Failover
Sau khi cấu hình HA, bạn cần test failover để đảm bảo hệ thống hoạt động đúng khi sự cố xảy ra. Có 2 cách test: simulate node failure hoặc manual migrate.
Test Manual Migration
# Live migrate VM sang node khác (không downtime) qm migrate 100 node2 --online # Verify VM đang chạy trên node2 ha-manager status # vm:100: started (node2)
Test Node Failure
# Cách 1: Shutdown node thật (rủi ro hơn) # SSH vào node đang chạy VM, rồi: systemctl stop pve-cluster pve-ha-lrm pve-ha-crm # Hoặc đơn giản: power off node (unplug power) # VMs trên node đó sẽ tự động restart trên node khác sau ~30-60 giây # Cách 2: Simulate bằng cách stop corosync systemctl stop corosync # Xem logs quá trình failover journalctl -u pve-ha-lrm -f journalctl -u pve-ha-crm -f # Kiểm tra trạng thái sau failover ha-manager status pvecm status
Quorum và Fencing
Quorum
Quorum đảm bảo chỉ một phần cluster (majority) được phép điều khiển tài nguyên. Nếu cluster mất quorum (quá nhiều nodes down), HA sẽ không restart VMs — để tránh split-brain.
# Kiểm tra quorum pvecm status # Expected: "Quorum: yes" # Nếu "Quorum: no" — cluster bị phân mảnh, cần khôi phục nodes # 2-node cluster: cần external QDevice (quorum witness) # Cài QDevice trên một server thứ 3 (bất kỳ Linux nào) apt install corosync-qnetd # Trên cluster nodes: pvecm qdevice setup 192.168.1.100
Fencing (Watchdog)
Fencing đảm bảo node bị cô lập sẽ tự restart, tránh chạy VMs đồng thời trên nhiều nodes (split-brain). Proxmox hỗ trợ software watchdog (softdog) và hardware watchdog (iLO, iDRAC, IPMI).
# Kích hoạt software watchdog modprobe softdog echo "softdog" >> /etc/modules # Verify watchdog đang chạy ls -la /dev/watchdog # crw------- 1 root root 10, 130 ... # Cho hardware watchdog (iLO/iDRAC): # modprobe hpwdt # HP iLO # modprobe ipmi_watchdog # IPMI generic # echo "hpwdt" >> /etc/modules
Troubleshooting Proxmox Cluster
| Vấn đề | Nguyên nhân | Cách xử lý |
|---|---|---|
| Nodes không thấy nhau | Firewall block Corosync ports | Mở ports 5405-5406 UDP trên tất cả nodes |
| Quorum lost | Nhiều nodes down cùng lúc | Khôi phục nodes, kiểm tra network. 3-node cluster chịu được 1 node down |
| HA VM không start | Không có shared storage | VM phải nằm trên shared storage (Ceph/NFS/iSCSI) |
| Split-brain VMs | Không có fencing/watchdog | Cấu hình watchdog (softdog hoặc hardware) |
| Cluster join failed | Hostname trùng hoặc SSH key conflict | Đổi hostname unique, xóa old SSH keys |
| Corosync high latency | Network bottleneck cho cluster traffic | Dùng dedicated NIC cho Corosync, kiểm tra cable/switch |
| VM restart chậm | Storage I/O slow hoặc network latency | Dùng SSD/NVMe cho storage, kiểm tra network bandwidth |
Best Practices cho Production
- Tối thiểu 3 nodes: Đảm bảo quorum majority. 2 nodes cần QDevice external.
- Dedicated Corosync network: Tách biệt cluster traffic khỏi production traffic. Dùng bond hoặc multiple links cho redundancy.
- Ceph replicated storage: Size 3 (3 copies), đảm bảo data survive khi 1 node down.
- Watchdog fencing: Bắt buộc. Dùng hardware watchdog (iLO/iDRAC) nếu có, softdog nếu không.
- NTP sync: Clock drift > 2 giây có thể gây Corosync issues. Dùng chrony.
- Test failover định kỳ: Ít nhất 1 lần/tháng, đảm bảo HA hoạt động khi cần.
Tìm hiểu thêm về Proxmox Backup Server, Nested Virtualization trên Proxmox và Proxmox vs VMware trên vnhte.com.