hoatranlab.io.vn Zalo: 0917516878 Hotline: 0917516878 [email protected]
HoaTranLab HoaTranLab
Buổi 4 / 14

Storage — VMFS, NFS & iSCSI

Module 5: Storage Stack · iSCSI Software Initiator · VMFS-6 · NFS 4.1 · Storage Policies (SPBM)

Tiến độ khóa học4 / 14 buổi
~4 giờ Intermediate Module 5 VMFS-6 iSCSI / NFS
Nội dung thực hành trên ESXi 8.0 Update 3 & vCenter Server 8.0 Update 3 (Build 24022515)

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ợ

ProtocolLoạiUse CasePerformance
Local VMFSBlockSingle host, dev/testCao
iSCSI SWBlockMid-range, flexibleTrung bình–Cao
iSCSI HWBlockEnterprise, productionCao
Fibre ChannelBlockEnterprise mission-criticalRất cao
NFS v3/v4.1FileFlexible, easy mgmtTrung bình
vSAN / vSAN ESAHCIScale-out, VMware native (ESA: vSAN 8.0+ Express Storage Architecture)Cao / Rất cao
NVMe-oFBlockUltra-low latencyRất cao
ESXi 8.0 — VMFS mặc định: VMFS-6 là phiên bản mặc định khi tạo datastore mới trên ESXi 8.0. VMFS-5 vẫn mount được nhưng không thể tạo mới. Nên migrate VMFS-5 sang VMFS-6 để có UNMAP tự động và hỗ trợ 4K drives.

VMFS Versions — So Sánh

Tính năngVMFS-5VMFS-6
Max volume size64 TB64 TB
Max file size62 TB62 TB
Block size1 MB1 MB
Space Reclamation (UNMAP)ManualAutomatic
4K Native DrivesKhông
EncryptionKhông

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.

VendorPlugin / vCenter IntegrationMultipath PolicyProtocolVAAI Support
Dell PowerStore/UnityDell Storage vCenter PluginRound RobiniSCSI, FC, NFS
NetApp ONTAPNetApp ONTAP tools for VMwareRound Robin (8 I/O)NFS 4.1, iSCSI
Pure Storage FlashArrayPure Storage Plugin for vSphereRound RobiniSCSI, FC, NVMe-oF
HPE Nimble/AlletraHPE InfoSight for VMwareRound RobiniSCSI, 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 VersionESXi SupportMultipathingAuthKhi nào dùng
NFS 3ESXi 4+KhôngAUTH_SYSLegacy, đơn giản
NFS 4.1ESXi 6.0+Có (Session Trunking)KerberosKhuyế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-5VMFS-6 (Khuyến nghị)Lý do nâng cấp
Block Size1 MB (cố định)1 MB (default, tự động)Tương thích
UNMAP (thin reclaim)Manual onlyTự động backgroundTiết kiệm space trên thin-capable arrays
4K Native DrivesKhông hỗ trợHỗ trợDrives mới dùng 4K sector
Max Datastore Size64 TB64 TBBằng nhau
EncryptionKhôngCó (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