Mục Tiêu Buổi Học
- Hiểu Storage Stack trong vSphere và các loại storage được hỗ trợ
- Cấu hình iSCSI Software Initiator kết nối TrueNAS/StarWind
- Tạo VMFS-6 Datastore trên iSCSI LUN
- Tạo NFS 4.1 Datastore cho templates và shared storage
- Thiết lập VM Storage Policies (SPBM) Gold/Bronze tier
- Lập kế hoạch capacity và storage tiering cho doanh nghiệp
LÝ THUYẾT — MODULE 5
5.1 Storage Stack trong vSphere
VM (VMDK files)
↓
VMFS / NFS Datastore
↓
Storage Adapter (HBA / NIC)
↓
Storage Network (FC / iSCSI / NFS / NVMe-oF)
↓
Storage Array (SAN / NAS / vSAN)
Các Loại Storage được Hỗ Trợ
| Protocol | Loại | Use Case | Performance |
|---|---|---|---|
| Local VMFS | Block | Single host, dev/test | Cao |
| iSCSI SW | Block | Mid-range, flexible | Trung bình–Cao |
| iSCSI HW | Block | Enterprise, production | Cao |
| Fibre Channel | Block | Enterprise mission-critical | Rất cao |
| NFS v3/v4.1 | File | Flexible, easy mgmt | Trung bình |
| vSAN / vSAN ESA | HCI | Scale-out, VMware native (ESA: vSAN 8.0+ Express Storage Architecture) | Cao / Rất cao |
| NVMe-oF | Block | Ultra-low latency | Rất cao |
VMFS Versions — So Sánh
| Tính năng | VMFS-5 | VMFS-6 |
|---|---|---|
| Max volume size | 64 TB | 64 TB |
| Max file size | 62 TB | 62 TB |
| Block size | 1 MB | 1 MB |
| Space Reclamation (UNMAP) | Manual | Automatic |
| 4K Native Drives | Không | Có |
| Encryption | Không | Có |
Storage Policy Based Management (SPBM)
VM Storage Policy → Capabilities (IOPS, Replication, Encryption)
↓
vSphere assigns storage tự động thỏa mãn policy
↓
Compliance monitoring tự động
LAB THỰC HÀNH — MODULE 5
Lab 5.1 — Cấu Hình iSCSI Software Initiator
Chuẩn bị: iSCSI Target (dùng TrueNAS hoặc StarWind iSCSI)
Target config (TrueNAS SCALE):
1. Tạo Pool: storage-pool-01 (ZFS, 4x4TB RAIDZ1)
2. Tạo zvol: iscsi-vmfs-01 (500GB, thick)
3. Tạo iSCSI Target:
Target Name: iqn.2024-01.local.storage:esxi-cluster
Portal: 192.168.30.10:3260
Initiator: Allow All hoặc whitelist ESXi IQN
Trên vSphere (cho từng ESXi host):
Bước 1: Add VMkernel for iSCSI:
Host → Configure → VMkernel Adapters → Add
Port Group: DPG-iSCSI-A (VLAN 30)
IP: 192.168.30.11 (static)
Enable: vSphere iSCSI storage traffic
Bước 2: Enable iSCSI Software Adapter:
Host Client → Storage → Adapters → Add Software Adapter → iSCSI
(vSphere Client: Host → Configure → Storage Adapters → Add Software Adapter)
IQN hiển thị: iqn.1998-01.com.vmware:esxi-01-xxxxxxxx
Bước 3: Cấu hình Dynamic Discovery:
iSCSI Adapter → Properties → Dynamic Discovery
→ Add Server
Address: 192.168.30.10, Port: 3260
Bước 4: Rescan HBAs:
Actions → Rescan Storage Adapters
Bước 5: Kiểm tra:
Storage Adapters → Devices
Thấy: FREENAS iSCSI Disk (500 GB)
Lab 5.2 — Tạo VMFS Datastore
vSphere Client → Storage → New Datastore Type: VMFS Name: DS-iSCSI-VMFS6-01 Host: esxi-01.lab.local Disk: FREENAS iSCSI Disk (500 GB) VMFS Version: 6 Partition Configuration: Max size Repeat cho mỗi host → Add Extents (shared VMFS) Kiểm tra: Datastore → Summary → Capacity, Free Space → All Hosts connected
Lab 5.3 — Tạo NFS Datastore
Chuẩn bị NFS Share (TrueNAS): Dataset: /mnt/pool/nfs-vmware Share: 192.168.30.0/24, Read/Write, No root squash vSphere Client → Storage → New Datastore: Type: NFS Name: DS-NFS-Templates NFS version: 4.1 Server: 192.168.30.10 Share: /mnt/pool/nfs-vmware Best Practice NFS với vSphere: - Dùng NFS 4.1 (hỗ trợ multipathing, Kerberos) - Dedicated VMkernel cho NFS traffic - Jumbo Frames (MTU 9000) cho performance
Lab 5.4 — Storage Policies
vSphere Client → Policies and Profiles → VM Storage Policies 1. Tạo Policy "Gold-Tier": Name: Gold-Tier-Encrypted Rule: Encryption: Yes Rule: IOPS limit: 5000 2. Tạo Policy "Bronze-Tier": Name: Bronze-Tier-NFS Rule: Datastore type: NFS 3. Apply Policy khi tạo VM: VM Storage Policy → Gold-Tier-Encrypted → VM files: DS-iSCSI-VMFS6-01
ỨNG DỤNG DOANH NGHIỆP — MODULE 5
Các pattern storage doanh nghiệp thực tế — từ tích hợp storage array, multipath iSCSI, NFS best practices đến SPBM và naming conventions.
1. Storage Array Integration — Dell/NetApp/Pure Storage
Mỗi storage vendor có plugin tích hợp với vCenter — nên dùng để quản lý storage trực tiếp từ vSphere Client.
| Vendor | Plugin / vCenter Integration | Multipath Policy | Protocol | VAAI Support |
|---|---|---|---|---|
| Dell PowerStore/Unity | Dell Storage vCenter Plugin | Round Robin | iSCSI, FC, NFS | ✓ |
| NetApp ONTAP | NetApp ONTAP tools for VMware | Round Robin (8 I/O) | NFS 4.1, iSCSI | ✓ |
| Pure Storage FlashArray | Pure Storage Plugin for vSphere | Round Robin | iSCSI, FC, NVMe-oF | ✓ |
| HPE Nimble/Alletra | HPE InfoSight for VMware | Round Robin | iSCSI, FC | ✓ |
VAAI — vStorage APIs for Array Integration
VAAI cho phép vSphere offload các thao tác storage sang array hardware, giảm tải cho ESXi host:
- Full Copy (XCOPY): Clone VM trên cùng datastore không qua ESXi host — 10x nhanh hơn
- Block Zeroing: Zero out disk blocks trên array hardware — cải thiện thin provisioning
- Hardware Assisted Locking (ATS): Thay thế SCSI reserve cho VMFS locking
2. iSCSI Multipath Configuration — Dual Path Best Practice
Luôn cấu hình 2 đường iSCSI độc lập (Network A và B) để đảm bảo không single point of failure cho storage.
### iSCSI Dual-Path Architecture
ESXi Host NIC:
vmnic0 → vDS uplink A → vmk3 (VLAN 40) → iSCSI Network A → Storage Port A
vmnic1 → vDS uplink B → vmk4 (VLAN 41) → iSCSI Network B → Storage Port B
iSCSI Target IPs:
Path A: 10.100.40.100 (Storage Controller 1)
Path B: 10.100.41.100 (Storage Controller 2)
### CẤU HÌNH iSCSI Multipath trên ESXi (esxcli):
# 1. Thêm iSCSI Software Adapter
esxcli iscsi adapter add
# 2. Bind vmknic vào iSCSI adapter
esxcli iscsi networkportal add -A vmhba64 -n vmk3
esxcli iscsi networkportal add -A vmhba64 -n vmk4
# 3. Thêm Dynamic Discovery targets
esxcli iscsi adapter discovery sendtarget add \
-A vmhba64 -a 10.100.40.100 -p 3260
esxcli iscsi adapter discovery sendtarget add \
-A vmhba64 -a 10.100.41.100 -p 3260
# 4. Rescan để detect LUNs
esxcli storage core adapter rescan -A vmhba64
# 5. Set Multipath Policy = Round Robin
esxcli storage nmp psp roundrobin deviceconfig set \
--device naa.60000970000... --type=iops --iops=1
# 6. Verify paths
esxcli storage nmp path list -d naa.60000970000...
# Phải thấy 2 paths, cả 2 trạng thái Active (I/O)
iSCSI Network Best Practices
- Dùng Jumbo Frames (MTU 9000) cho iSCSI network — tăng throughput ~20%
- Tắt Flow Control trên physical switch port cho iSCSI traffic
- Mỗi iSCSI vmknic chỉ bind 1 uplink (NIC binding) — tránh traffic mixing
- Tách riêng iSCSI vào VLAN dedicated — không mix với VM traffic
- Dùng CHAP authentication cho iSCSI targets trong môi trường regulated
3. NFS Datastore Best Practices
NFS 4.1 là lựa chọn phổ biến cho Dev/Test và backup target — đơn giản hơn iSCSI nhưng cần tuning đúng cách.
### NFS 4.1 Mount với Kerberos Authentication
# vSphere Client → Storage → New Datastore → NFS → NFS 4.1
# Hoặc esxcli:
esxcli storage nfs41 add \
--host 10.100.50.10 \
--share /vmware/nfs-dev \
--volume-name DS-NFS-Dev-01 \
--auth-method SEC_KRB5
# Kiểm tra mount
esxcli storage nfs41 list
### NFS Tuning Parameters (Advanced Settings):
NFS.MaxVolumes = 256 # Max NFS datastores per host (default 8 — quá thấp!)
NFS.HeartbeatTimeout = 12 # Timeout trước khi coi NFS down
NFS.HeartbeatFrequency = 12 # Check interval (giây)
Net.TcpipHeapSize = 30 # TCP heap cho NFS throughput cao
Net.TcpipHeapMax = 120 # Max TCP heap
# Áp qua esxcli:
esxcli system settings advanced set -o /NFS/MaxVolumes -i 256
esxcli system settings advanced set -o /NFS/HeartbeatTimeout -i 12
| NFS Version | ESXi Support | Multipathing | Auth | Khi nào dùng |
|---|---|---|---|---|
| NFS 3 | ESXi 4+ | Không | AUTH_SYS | Legacy, đơn giản |
| NFS 4.1 | ESXi 6.0+ | Có (Session Trunking) | Kerberos | Khuyến nghị cho production |
4. VMFS-6 Block Size & Format Decisions
Quyết định đúng ngay từ đầu — thay đổi block size sau này yêu cầu format lại toàn bộ datastore.
| Thông số | VMFS-5 | VMFS-6 (Khuyến nghị) | Lý do nâng cấp |
|---|---|---|---|
| Block Size | 1 MB (cố định) | 1 MB (default, tự động) | Tương thích |
| UNMAP (thin reclaim) | Manual only | Tự động background | Tiết kiệm space trên thin-capable arrays |
| 4K Native Drives | Không hỗ trợ | Hỗ trợ | Drives mới dùng 4K sector |
| Max Datastore Size | 64 TB | 64 TB | Bằng nhau |
| Encryption | Không | Có (vSphere Encryption) | Compliance requirement |
5. Storage Policy Based Management (SPBM)
SPBM cho phép gán "storage policy" cho VM thay vì chọn datastore thủ công — tự động đặt VM vào đúng tier storage.
### PowerCLI — Tạo và gán VM Storage Policy
Connect-VIServer vcsa-hn-prod.hoatranlab.io.local
# 1. Tạo Tag Category và Tags để đánh dấu datastores
New-TagCategory -Name "StorageTier" -Cardinality Single -EntityType Datastore
New-Tag -Name "Tier-Gold" -Category "StorageTier"
New-Tag -Name "Tier-Silver" -Category "StorageTier"
New-Tag -Name "Tier-Bronze" -Category "StorageTier"
# 2. Gán Tag cho datastores
Get-Datastore "DS-iSCSI-SSD*" | New-TagAssignment -Tag "Tier-Gold"
Get-Datastore "DS-iSCSI-SAS*" | New-TagAssignment -Tag "Tier-Silver"
Get-Datastore "DS-NFS-Dev*" | New-TagAssignment -Tag "Tier-Bronze"
# 3. Tạo Storage Policy dựa trên Tag
$category = Get-SpbmTagCategory -Name "StorageTier"
$tag = Get-SpbmTag -Name "Tier-Gold" -Category $category
$rule = New-SpbmRule -AnyOfTags $tag
$ruleset = New-SpbmRuleSet -Name "Gold Tier Ruleset" -AllOfRules $rule
$policy = New-SpbmStoragePolicy -Name "Gold-Tier-Policy" `
-Description "All-Flash SSD datastores for critical workloads" `
-RuleSet $ruleset
# 4. Apply policy khi tạo/migrate VM
Set-VM -VM "prod-db-01" -StoragePolicy $policy
SPBM Use Cases tại doanh nghiệp
- vSAN Policy: FTT=1 (RAID-1), FTT=2 (RAID-6) cho DB tier
- Encryption Policy: Tự động mã hóa VMs thuộc nhóm PCI/HIPAA
- Replication Policy: Kết hợp với vSphere Replication cho DR
- Compliance: Kiểm tra VM có đang ở đúng tier không — alert nếu non-compliant
6. Datastore Naming Conventions & Capacity Planning
Naming convention nhất quán giúp xác định ngay storage tier, protocol và vị trí mà không cần mở thêm tài liệu.
### DATASTORE NAMING CONVENTION # Format: DS-[Protocol]-[Tier]-[Site]-[Seq] # DS = Datastore prefix # [Protocol] = VMFS6-iSCSI | VMFS6-FC | NFS41 | vSAN # [Tier] = Gold | Silver | Bronze | Backup # [Site] = HN (Hà Nội) | HCM (Hồ Chí Minh) # [Seq] = 01, 02, ... # Ví dụ: DS-VMFS6-iSCSI-Gold-HN-01 # iSCSI, SSD, Production, Hà Nội, #1 DS-VMFS6-iSCSI-Gold-HN-02 # iSCSI, SSD, Production, Hà Nội, #2 DS-NFS41-Silver-HN-01 # NFS 4.1, Hybrid, Production DS-NFS41-Bronze-HN-01 # NFS 4.1, NL-SAS, Dev/Test DS-NFS41-Backup-HN-01 # NFS 4.1, Backup target ### CAPACITY PLANNING FORMULA: Total Usable = Raw × (1 - RAID overhead) × (1 - format overhead 5%) RAID-5: 75% usable | RAID-6: 67% usable | RAID-10: 50% usable VM Storage per VM: Allocated = vDisk size (thin: actual write + 20% headroom) Snapshot = vDisk × 0.2 max (limit snapshot size policy) Swap = vRAM (vmx-swap, chỉ khi balloon không đủ) Alert Thresholds (Zabbix/vCenter Alarm): Warning ≥ 75% → email INFRA team Critical ≥ 85% → ticket + Storage vMotion suggestion Emergency ≥ 90% → auto-trigger Storage DRS migration