Mục tiêu buổi học
- Hiểu hai chế độ VLCM: Baselines (legacy) và Images (recommended)
- Nắm vững update sequence bắt buộc: vCenter → ESXi → VMware Tools → HW Version
- Thực hiện nâng cấp VCSA an toàn (Stage 1 + Stage 2)
- Patch ESXi hosts bằng VLCM Images và PowerCLI
- Xây dựng Change Management process cho môi trường production
Lý Thuyết
vSphere Lifecycle Manager (VLCM)
VLCM thay thế hoàn toàn VUM (vSphere Update Manager) từ vSphere 7.0+ — là công cụ quản lý tập trung việc patch và nâng cấp toàn bộ hạ tầng vSphere từ một giao diện duy nhất. VLCM tích hợp kiểm tra HCL (Hardware Compatibility List) để xác nhận phần cứng hỗ trợ image trước khi remediate.
| Chế độ | Mô tả | Khuyến nghị |
|---|---|---|
| Baselines | Legacy từ vSphere 6.x. Patch/Upgrade/Extension baselines riêng biệt — vẫn hỗ trợ cho standalone hosts (không dùng cho cluster với image) | Môi trường cũ, nâng cấp từng phần |
| Images | Declarative — mô tả "desired state" của cluster. ESXi base + components + firmware. Toàn bộ cluster dùng cùng 1 image. | vSphere 7+ (recommended) — bắt buộc cho cluster mới |
Update Sequence — Bắt buộc theo thứ tự
QUAN TRỌNG: Sai thứ tự → mất tính tương thích, lỗi không lường trước!
Step 1: vCenter Server / VCSA
└─ Luôn nâng cấp trước tiên
└─ vCenter phải ≥ ESXi version
Step 2: ESXi Hosts
└─ Sau khi vCenter hoàn thành
└─ Rolling update: 1 host at a time
└─ DRS tự động vMotion VMs ra trước
Step 3: VMware Tools (trong VMs)
└─ Sau khi ESXi hosts updated
└─ Có thể hot-upgrade (không cần power off với Linux)
Step 4: VM Hardware Version
└─ Sau VMware Tools up-to-date
└─ BACKUP trước khi upgrade!
└─ Không downgrade được
VLCM Images — Cluster Desired State
ESXi 8.0.3 ISO: VMware-VMvisor-Installer-8.0.3-24022515.x86_64.iso
Cluster Image = ESXi Base + Firmware Addon + Components
ESXi Base Image: ESXi 8.0 Update 3 (8.0.3-24022515)
+
Firmware & Drivers Addon: HP Gen10 Addon v1.2
+
Components: VMware Tools, vSAN, NSX VIBs
→ Tất cả hosts trong cluster PHẢI có cùng image
→ Drift detection: tự phát hiện host không khớp
→ Remediate: tự động apply để khớp desired state
Compliance States:
✓ Compliant — host khớp cluster image
✗ Non-Compliant — cần update
✗ Incompatible — hardware không hỗ trợ
vSphere Image Builder (Custom ISO)
Tích hợp OEM drivers/firmware vào ESXi image khi NIC/HBA không có trong VMware HCL base image.
# PowerCLI — Tạo custom ESXi ISO với OEM driver
Add-EsxSoftwareDepot https://hostupdate.vmware.com/...
$imageProfile = Get-EsxImageProfile -Name "ESXi-8.0U2..."
Add-EsxSoftwarePackage -ImageProfile $imageProfile `
-SoftwarePackage "net-driver-xxx"
Export-EsxImageProfile -ImageProfile $imageProfile `
-ExportToIso -FilePath custom-esxi8.iso
Lab Thực Hành
Lab 9.1 — Setup Lifecycle Manager với Images
1. Tạo Cluster Image:
Cluster → Updates → Image → Edit
ESXi Version: 8.0 Update 3 (8.0.3-24022515)
Firmware and Drivers Addon: (chọn nếu có HW vendor plugin)
Components:
+ VMware Tools
+ vSAN
→ Validate Image → Save
2. Xem Image Compliance:
Cluster → Updates → Image → Image Compliance
Status per host:
- Compliant ✓
- Non-Compliant ✗ (needs update)
- Incompatible ✗ (HW không hỗ trợ)
3. Stage và Remediate (update hosts):
Non-Compliant Hosts → Remediate
→ Pre-check: Validation checks
→ Stage: Download patches to hosts (không reboot)
→ Remediate: Apply + Reboot
Options:
✓ PQP (Pre-check Query Profile)
✓ Enter Maintenance Mode automatically
✓ Migrate VMs with DRS
✓ Retry on failure: 3 attempts
Lab 9.2 — Nâng cấp VCSA (vCenter)
Phương thức: VCSA Installer → Upgrade
Bước 1: Mount ISO VCSA mới
File: VMware-VCSA-all-8.0U3-xxxxx.iso
Bước 2: Chạy installer → Upgrade
Stage 1: Deploy new VCSA alongside existing
Source vCenter: vcsa-01.lab.local (admin/password)
Deploy: vcsa-01-new (temp IP: 10.100.100.20)
Stage 2: Transfer data
Pre-upgrade checks:
✓ DNS resolution
✓ NTP sync
✓ Sufficient disk space
✓ No active alarms
Data to copy:
✓ Configuration
✓ Events & Tasks (tùy chọn, tốn thời gian)
Transfer complete → Swap IP (nguồn → đích)
Old VCSA powered off
Bước 3: Verify:
https://vcsa-01.lab.local/ui → Version 8.0U3 ✓
All hosts connected ✓
All VMs visible ✓
Lab 9.3 — Update ESXi với Baselines (PowerCLI)
# Connect to vCenter
Connect-VIServer -Server vcsa-01.lab.local `
-User [email protected]
# List available patches
Get-Baseline -Name "*Critical*"
# Scan hosts against baseline
Get-VMHost | Scan-Inventory -UpdateType HostPatch
# Get compliance report
Get-VMHost | Get-Compliance | `
Select-Object Entity, Status, NotCompliantPatches
# Remediate hosts (với Maintenance Mode tự động)
$cluster = Get-Cluster "Cluster-Production"
$baseline = Get-Baseline "Critical Host Patches"
Remediate-Inventory -Entity $cluster -Baseline $baseline `
-MaintenanceMode $true -Evacuate $true -Confirm:$false
# Monitor progress
Get-Task | Where-Object {$_.Name -eq "Remediate entity"}
Lab 9.4 — Upgrade VMware Tools và VM Hardware
1. Upgrade VMware Tools:
Cluster → Updates → VM Updates → VMware Tools
Select VMs → Upgrade
Options:
✓ Only upgrade if installed version is older
✓ Power off to upgrade (nếu không hỗ trợ hot upgrade)
2. Upgrade VM Hardware Version:
QUAN TRỌNG: Backup VM trước!
VM → Summary → VM Hardware (Version 14)
Actions → Compatibility → Upgrade VM Compatibility
Compatible with: ESXi 8.0 and later (v21)
✓ Run compatibility check first
Hoặc bulk upgrade:
Cluster → Updates → VM Updates → VM Hardware
Select VMs → Upgrade Compatibility
3. PowerCLI bulk upgrade:
$vms = Get-VM -Location (Get-Folder "Production")
foreach ($vm in $vms) {
if ($vm.Version -ne "v21") {
$vm | Set-VM -Version "v21" -Confirm:$false
}
}
ỨNG DỤNG DOANH NGHIỆP — MODULE 9
Vận hành vSphere Lifecycle Manager trong môi trường production — từ depot configuration, patch sequencing đến staged update workflow và rollback procedure.
1. Baseline vs Image-Based Lifecycle — Chọn Đúng Phương Pháp
vLCM hỗ trợ 2 mô hình quản lý lifecycle hoàn toàn khác nhau — lựa chọn sai ảnh hưởng đến cả cluster khi mở rộng thêm host mới.
| Tiêu chí | Baseline (Legacy) | Image-Based (Khuyến nghị) |
|---|---|---|
| Cách hoạt động | Áp dụng patch/update lên host hiện tại | Desired state — host phải match image hoàn toàn |
| Consistency | Hosts có thể khác nhau theo thời gian | Tất cả hosts trong cluster 100% identical |
| Driver / Firmware | Quản lý riêng (OEM tools) | Tích hợp vào image — OEM add-ons |
| Scale-out host mới | Cần áp dụng nhiều baseline | Boot từ image → tự động compliant |
| Dùng khi | Cluster cũ, mixed hardware | New cluster, homogeneous hardware |
| Chuyển đổi | Baseline → Image được | Image → Baseline KHÔNG được |
Best Practice — Image-Based cho New Cluster
- Tạo 1 cluster image chuẩn (ESXi base + OEM driver + security patch) → áp dụng toàn cluster
- Mỗi host mới join cluster tự động bị enforce về image → không cần cấu hình thủ công
- Export image thành file JSON để version control trong Git (Infrastructure as Code)
2. Depot Configuration — HTTPS & Local Air-Gapped
Môi trường doanh nghiệp thường không cho phép vCenter kết nối internet trực tiếp — cần setup local depot hoặc UMDS (Update Manager Download Service).
### TOPOLOGY — Local Depot cho Air-Gapped Environment ┌──────────────────────────────────────────────────────────┐ │ CORPORATE NETWORK (Isolated) │ │ │ │ ┌─────────────┐ Sync ┌─────────────────────────┐ │ │ │ UMDS Server│ ◄──────── │ VMware Online Depot │ │ │ │ (DMZ/Proxy)│ HTTPS │ depot.vmware.com │ │ │ └─────────────┘ └─────────────────────────┘ │ │ │ HTTP/HTTPS (internal) │ │ ▼ │ │ ┌─────────────────────────────────────────────────┐ │ │ │ vCenter / vLCM │ │ │ │ → Administration → Lifecycle Manager │ │ │ │ → Settings → Patch Download Settings │ │ │ │ → Use custom depot: http://umds-01.corp.com │ │ │ └─────────────────────────────────────────────────┘ │ └──────────────────────────────────────────────────────────┘
### Setup UMDS (Update Manager Download Service) — Windows Server # Cài đặt UMDS trên Windows Server có internet access (DMZ) # 1. Mount VMware-vCenter-Server ISO → Run VMware-UMDS.exe # 2. Cấu hình download path: D:\UMDS-Repository\ # 3. Kết nối vào VMware Depot online: # UMDS commands (PowerShell trên UMDS server): vmware-umds -S --add-url https://www.vmware.com/channeldata --url-type HostPatch vmware-umds -S --add-url https://hostupdate.vmware.com/software/VUM/PRODUCTION/main/vmw-depot-index.xml # Cấu hình download ESXi 8.0.3 patches vmware-umds -S --enable-host --host-product ESXi --host-version 8.0.0 # Download patches (chạy hàng ngày qua scheduled task) vmware-umds -D # Expose qua IIS / Apache: # Map D:\UMDS-Repository\ → http://umds-01.corp.com/umds/ ### Thêm depot vào vLCM: # vSphere Client → Administration → Lifecycle Manager # → Settings → Patch Download Settings → Use a shared repository # URL: http://umds-01.corp.com/umds/
3. Patch Sequencing cho Production Cluster — Thứ Tự Bắt Buộc
Sai thứ tự update là nguyên nhân phổ biến nhất gây lỗi sau patching — vCenter phải được update trước ESXi hosts.
Update vCenter Server (VCSA)
VAMI (port 5480) → Update → Check Updates → Stage All → Install → Reboot. vCenter phải ≥ version ESXi sẽ update lên.
Update ESXi Hosts (Rolling — 1 host at a time)
vLCM → Cluster → Updates → Remediate. DRS tự động vMotion VMs ra. Host reboot → exit maintenance mode → đợi 15 phút → host tiếp theo.
Update VMware Tools trên VMs
vSphere Client → VMs → Actions → Guest OS → Upgrade VMware Tools. Có thể mass-update bằng PowerCLI hoặc vLCM Guest Tools.
Upgrade VM Hardware Version (tùy chọn)
Cần power off VM. Chỉ thực hiện khi cần tính năng mới (new device type, larger vCPU limit). Không bắt buộc mỗi cycle.
Cảnh báo thứ tự quan trọng
- KHÔNG update ESXi lên version mới hơn vCenter — vCenter luôn phải update trước
- KHÔNG update tất cả hosts cùng lúc — rolling update, 1 host một lần
- KHÔNG upgrade VM HW Version nếu VM đang chạy — cần power off
- Test toàn bộ quy trình trên pre-production cluster trước khi áp dụng production
4. Staged Update Workflow — Scan → Stage → Remediate
Staging tách bước "download patch xuống host" ra khỏi "apply patch" — giúp rút ngắn maintenance window thực tế và kiểm soát rủi ro.
### PowerCLI — Staged Update Workflow tự động hóa
Connect-VIServer vcsa-01.lab.local
$cluster = Get-Cluster "CL-HN-Prod-01"
$clusterView = $cluster | Get-View
Write-Host "=== BƯỚC 1: SCAN compliance ==="
# Trigger scan để xác định hosts nào non-compliant
$scanTask = $clusterView.ScanEntityForCompliance_Task($clusterView.MoRef)
Wait-Task -Task (Get-Task -Id $scanTask)
# Xem kết quả compliance
$cluster | Get-View | Select-Object -ExpandProperty ComplianceCheckResult |
ForEach-Object { Write-Host "Host: $($_.Entity.Value) | Status: $($_.ComplianceStatus)" }
Write-Host "=== BƯỚC 2: STAGE patches (download to hosts, no reboot) ==="
# Stage trước maintenance window — download patches xuống host cache
# vSphere Client → Cluster → Updates → Pre-Check Remediations → Stage Patches
# Hoặc PowerCLI:
$hosts = $cluster | Get-VMHost | Where-Object { $_.ConnectionState -eq "Connected" }
foreach ($h in $hosts) {
Write-Host "Staging: $($h.Name)"
# Stage tải file xuống /scratch/downloads trên host
# KHÔNG reboot tại bước này
}
Write-Host "=== BƯỚC 3: REMEDIATE (apply + reboot, trong maintenance window) ==="
# Thực hiện trong maintenance window đã approved
# vSphere Client → Cluster → Updates → Remediate All
# DRS tự động evacuate VMs, host reboot, exit maintenance
Lợi ích của Staging trước Maintenance Window
- Stage patches 1-2 ngày trước → maintenance window chỉ còn apply + reboot (~20-30 phút/host thay vì 45-60 phút)
- Tránh tải mạng nặng trong giờ cao điểm khi download patches lớn (ESXi bundle ~600 MB)
- Phát hiện sớm lỗi download trước maintenance window (không bị bất ngờ)
5. Maintenance Mode Orchestration — Zero-Downtime Rolling Update
Quy trình rolling update chuẩn cho cluster 6 hosts — đảm bảo VMs không bị downtime trong suốt quá trình patch.
### ROLLING UPDATE TIMELINE — Cluster 6 hosts (4 giờ maintenance window)
T+00:00 ┌─ ESXi-01: Enter Maintenance Mode
│ DRS vMotion tất cả VMs → ESXi-02,03,04,05,06
T+00:05 │ VLCM Remediate ESXi-01 (download nếu chưa stage + apply)
T+00:25 │ ESXi-01 Reboot tự động
T+00:30 └─ ESXi-01: Exit Maintenance Mode, verify healthy (5 phút)
T+00:35 ┌─ ESXi-02: Enter Maintenance Mode → DRS evacuate
T+01:05 └─ ESXi-02: Exit Maintenance Mode
T+01:10 → ESXi-03 (tương tự)
T+01:45 → ESXi-04
T+02:20 → ESXi-05
T+02:55 → ESXi-06 (host cuối cùng)
T+03:30 HOÀN THÀNH ✓
→ vLCM Compliance Check: All Compliant
→ VMs: ZERO downtime (DRS liên tục vMotion)
### PowerCLI — Kiểm tra trạng thái sau mỗi host remediate
function Verify-HostAfterPatch {
param([string]$HostName)
$h = Get-VMHost -Name $HostName
$hView = $h | Get-View
$checks = @{
"ConnectionState" = $h.ConnectionState -eq "Connected"
"Build version" = $h.Build -ne $null
"No config error" = ($hView.ConfigStatus -eq "green")
"VMs back on host" = (Get-VM -Location $h | Where-Object { $_.PowerState -eq "PoweredOn" }).Count -gt 0
}
$allPass = ($checks.Values | Where-Object { $_ -eq $false }).Count -eq 0
Write-Host "$HostName — $(if ($allPass) { 'PASS ✓' } else { 'FAIL — xem chi tiết' })"
$checks.GetEnumerator() | ForEach-Object {
Write-Host " $($_.Key): $(if ($_.Value) { 'OK' } else { 'FAIL' })"
}
return $allPass
}
# Gọi sau khi từng host exit maintenance mode
Get-Cluster "CL-HN-Prod-01" | Get-VMHost | ForEach-Object {
Verify-HostAfterPatch -HostName $_.Name
}
6. Rollback Procedure — Khi Patch Gây Sự Cố
Phải có rollback plan trước khi bắt đầu patching — không chuẩn bị rollback = không được phép patch production.
### ESXi Host Rollback Options (theo thứ tự ưu tiên) ## Option 1: ESXi Boot Bank Rollback (nhanh nhất — không cần reinstall) # Khi ESXi có vấn đề sau patch, boot từ previous image (backup boot bank): # Trong DCUI (F2 → Troubleshooting Options) hoặc iDRAC/iLO boot menu: # → Advanced Boot Options → Select boot disk # → Chọn "Previous ESXi version" (esxiboot bank) # Hoặc qua SSH nếu còn access: esxcli system maintenanceMode set -e true esxcli software profile restore --depot=file:///vmfs/volumes/datastore1/VMware_ESXi_backup.zip ## Option 2: Reinstall từ ISO (nếu boot bank corrupt) # 1. Boot từ ESXi 8.0.3 ISO cũ (version trước khi patch) # 2. Chọn "Upgrade/Restore" → giữ VMFS datastore # 3. Hosts và VMs vẫn còn trên datastore # 4. Re-add host vào cluster sau khi install xong ## Option 3: vCenter Rollback (nếu VCSA update fail) # Trước khi update VCSA, VAMI tự động tạo snapshot (File-based backup) # Nếu VCSA update fail → VAMI → Backup → Restore từ snapshot gần nhất # Hoặc: vCenter snapshot trên ESXi host (nếu VCSA chạy trên ESXi, không embedded) ### Checklist Rollback Decision (trong maintenance window) # Nếu sau patch xuất hiện: # - Host không Exit Maintenance Mode được → xem /var/log/vmkernel.log # - VMs không power on được sau vMotion → kiểm tra datastore access # - vCenter services không start → vmon-cli --status # Nếu không fix được trong 30 phút → kích hoạt rollback procedure
Pre-Patch Backup Checklist
Post-Patch Validation