ใน VMware vSphere สามารถใช้ iSCSI Disk เป็น Shared Datastore สำหรับ ESXi Hosts ได้ ESXi Host เข้าถึง iSCSI Storage ผ่าน Local Network ด้วย TCP Protocol บทความนี้จะแนะนำวิธีเพิ่ม iSCSI LUN ให้ VMware ESXi Host และสร้าง Shared VMFS Datastore บนมัน
สมมติว่าสร้าง Configure และ Publish iSCSI Target (Disk) บน Storage Device (Array) แล้ว ยังสามารถใช้ Virtual Disk (VHDX) ที่ Host บน Windows Server เป็น iSCSI Target ได้
ตรวจสอบว่าได้ Allow ESXi Hosts (iSCSI Initiators) ให้เชื่อมต่อ iSCSI Target ใน Storage Config แล้ว สามารถ Address iSCSI Target ด้วย IQN (วิธีหา IQN ของ iSCSI Adapter ใน ESXi แสดงด้านล่าง) DNS Name, IP หรือ MAC Address
ตัวอย่างใช้ Standalone Host รัน VMware ESXi 6.7 (ใช้ Free ESXi Hypervisor ก็ได้) อาจเป็น Physical Host หรือ VM (มีตัวอย่างรัน ESXi ใน Hyper-V VM) มี Network Interfaces 2 ตัว (ตัวแรกสำหรับ Management ตัวที่สองสำหรับ iSCSI Traffic)
กำหนดค่า Network สำหรับ iSCSI Traffic บน VMware ESXi
เปิด Web Interface จัดการ ESXi Host (https://YOUR_ESXI_HOST/ui/#/login)
ขั้นแรก สร้าง VMkernel Network Interface แยกสำหรับ ESXi Host เข้าถึง iSCSI Storage เปิด Networking → VMkernel NICs → Add VMkernel NIC

นอกจาก vmk Port แล้ว สร้าง Port Group ใหม่ (New port group) ระบุชื่อ Group (iSCSI) และกำหนด Static IP Address สำหรับ vmkernel Interface

เปิด Settings ของ Default vSwitch0 (Networking → Virtual Switches) ตรวจสอบว่า Physical Interface ตัวที่สอง (vmnic1) ของ Host ถูกเพิ่มใน Config และ Active แล้ว (ถ้าไม่ คลิก Add uplink เพื่อเพิ่ม)

ในส่วน NIC Teaming ตรวจสอบว่า Physical Interfaces ทั้งสองเป็น Active

จากนั้นใน iSCSI Port Group Settings ต้อง Allow เฉพาะ Interface ตัวที่สองสำหรับ iSCSI Traffic ไปที่ Networking → Port groups → iSCSI → Edit settings Expand NIC teaming เลือก Override failover order = Yes ทิ้ง vmnic1 Active และตั้ง Unused สำหรับ vmnic0 Port

ผลลัพธ์ ESXi Host จะใช้ Network Interface เดียวสำหรับเข้าถึง iSCSI LUN
กำหนดค่า iSCSI Software บน VMware ESXi
iSCSI Software Adapter ปิดอยู่โดยค่าเริ่มต้นใน ESXi เพื่อ Enable เปิด Storage → Adapters คลิก Software iSCSi

เปลี่ยน iSCSI enable เป็น Enabled
ที่นี่สามารถหา IQN ของ iSCSI Adapter (Initiator) ใช้ Config Access ให้ iSCSI LUN ใน Storage Array Settings
เพิ่ม IP Address ของ iSCSI Storage และ Connection Port (Default TCP Port 3260 สำหรับ iSCSI Traffic) ในส่วน Dynamic Targets ESXi จะ Scan iSCSI Targets ทั้งบน Storage และแสดงใน List Static Targets

ที่นี่ Config CHAP Authentication ได้ แต่ Optional ใน Test Environment
Save Settings จะเห็น iSCSI Software Adapter HBA ใหม่ vmhba65 ใน Tab Storage → Adapters

หาก ESXi Host เชื่อม vCenter แล้ว เปิด Configure → Storage → Storage Adapters เพื่อเพิ่ม iSCSI LUN เลือก Software iSCSI adapter ระบุชื่อหรือ IP ของ iSCSI Storage ใน Tab Dynamic Discovery คลิก Rescan รายการ iSCSI Targets ที่ใช้ได้จะปรากฏใน Tab Static Discovery

หากไม่เห็นรายการ iSCSI Targets ใน Storage สามารถ Diagnose iSCSI Disk Availability จาก ESXi Console
เปิด SSH บน ESXi Host และเชื่อมต่อด้วย SSH Client (ใช้ Windows 10 Built-in SSH Client):
ssh root@192.168.113.50
ตรวจสอบ Availability ของ iSCSI Storage (192.168.113.10) จาก vmkernel Port ที่ระบุ (vmk1):
# vmkping -I vmk1 192.168.113.10

ตัวอย่าง iSCSI Storage ตอบ Ping
ตรวจสอบว่า iSCSI TCP Port 3260 พร้อมใช้งานบน Storage ด้วย netcat (ในตัวอย่าง 192.168.113.60 คือ IP ของ vmk1 Interface):
# nc -s 192.168.113.60 -z 192.168.113.10 3260
Connection to 192.168.113.10 3260 port [tcp/*] succeeded!

ตรวจสอบว่า Software iSCSI Enable บน ESXi Host แล้ว:
# esxcli iscsi software get
true
Enable ถ้ายังไม่ได้:
# esxcli iscsi software set -e true
Software iSCSI Enabled
ดู Current Settings ของ Software iSCSI HBA Adapter:
# esxcli iscsi adapter get -A vmhba65

vmhba65 Name: iqn.1998-01.com.vmware:srv-esx1-1234abcd Alias: Vendor: VMware Model: iSCSI Software Adapter Description: iSCSI Software Adapter Serial Number: Hardware Version: Asic Version: Firmware Version: Option Rom Version: Driver Name: iscsi_vmk Driver Version: TCP Protocol Supported: false Bidirectional Transfers Supported: false Maximum Cdb Length: 64 Can Be NIC: false Is NIC: false Is Initiator: true Is Target: false Using TCP Offload Engine: false Using ISCSI Offload Engine: false
สร้าง VMFS Datastore บน iSCSI LUN ใน VMware ESXi
จากนั้นสร้าง VMFS (Virtual Machine File System) Datastore เก็บไฟล์ VM บน iSCSI LUN ที่เชื่อมต่อแล้ว
เปิด Storage → Datastores → New datastore

ป้อนชื่อ VMFS Datastore และเลือก iSCSI LUN ที่จะสร้าง

เลือก VMFS 6 เป็น File System และระบุว่าต้องการใช้ Volume ทั้งหมดของ iSCSI Disk สำหรับ Datastore ในไม่กี่วินาที VMFS Datastore ใหม่จะพร้อมใช้งานบน ESXi

หาก VMFS Datastore สร้างบน LUN นี้ไว้แล้ว จะปรากฏทันทีในรายการ Storage Devices ที่ใช้ได้บน Host

เชื่อมต่อ iSCSI Disk กับ ESXi Host และสร้าง VMFS Datastore บนมันเสร็จแล้ว Multiple ESXi Servers สามารถเข้าถึง Datastore นี้พร้อมกัน ตอนนี้มี Shared Storage หาก Config VMware vCenter Server จะใช้ vMotion ย้าย Running VMs ระหว่าง Hosts ได้