Computer >> Computer tutorials >  >> Software >> Virtual machine

Configuring iSCSI Datastore (LUN) on VMware ESXi

In VMware vSphere, you can use an iSCSI disk as a shared datastore for your ESXi hosts. An ESXi host accesses iSCSI storage over your local network using the TCP protocol. In this article, we’ll look at how to add an iSCSI LUN to a VMWare ESXi host and create a shared VMFS datastore on it.

Suppose you have already created, configured, and published an iSCSI target (disk) on your storage device (array). Also, you can use a virtual disk (VHDX) hosted on Windows Server as an iSCSI target.

Make sure you allowed your ESXi hosts (iSCSI initiators) to connect to the iSCSI target in your storage configuration. You can address the iSCSI target using an IQN (how to get IQN of an iSCSI adapter in ESXi is shown below), DNS name, IP, or MAC address.

In this example, we are using a standalone host running VMware ESXi 6.7 (you can also use the free ESXi Hypervisor). This can be a physical host or a virtual machine (here is an example of running ESXi in a Hyper-V VM). There are two network interfaces in the host (the first is for management and the second is for the iSCSI traffic).

Configure Network for iSCSI Traffic on VMWare ESXi

Open the web interface to manage your ESXi host (_https://YOUR_ESXI_HOST/ui/#/login).

First of all, create a separate VMkernel network interface that will be used by the ESXi host to access the iSCSI storage. Open Networking -> VMkernel NICs -> Add VMkernel NIC.

Configuring iSCSI Datastore (LUN) on VMware ESXi

Besides the vmk port, create a new port group (New port group). Specify the group name (iSCSI) and assign a static IP address for your vmkernel interface.

Configuring iSCSI Datastore (LUN) on VMware ESXi

Then open the settings of your default vSwitch0 (Networking -> Virtual Switches). Make sure that the second physical interface (vmnic1) of your host has been added to the configuration and is active (otherwise, click Add uplink to add it).

Configuring iSCSI Datastore (LUN) on VMware ESXi

In the NIC Teaming section, make sure that both physical interfaces are Active.

Configuring iSCSI Datastore (LUN) on VMware ESXi

Then in the iSCSI port group settings, you need to allow only the second interface to be used for iSCSI traffic. Go to Networking -> Port groups -> iSCSI> Edit settings. Expand the NIC teaming section and select Override failover order = Yes. Leave vmnic1 active and set Unused for the vmnic0 port.

Configuring iSCSI Datastore (LUN) on VMware ESXi

As a result, your ESXi host will use only one network interface to access your iSCSI LUN.

Configuring iSCSI Software on VMWare ESXi

The iSCSI software adapter is disabled by default in ESXi. To enable it, open Storage -> Adapters. Click Software iSCSi.

Configuring iSCSI Datastore (LUN) on VMware ESXi

Change iSCSI enable to Enabled.

Note that here you can get the IQN of your iSCSI adapter (initiator). You can use it to configure access to your iSCSI LUN in the storage array settings.

Then add the IP address of your iSCSI storage and the connection port (by default, the TCP Port 3260 is used for the iSCSI traffic) in the Dynamic targets section. ESXi will scan all iSCSI targets on the storage and display them in the Static Targets list.

Configuring iSCSI Datastore (LUN) on VMware ESXi

Here you can configure CHAP authentication, but it is optional in the test environment.

Save the settings. Note that a new iSCSI Software Adapter HBA vmhba65 appeared in the Storage -> Adapters tab.

Configuring iSCSI Datastore (LUN) on VMware ESXi

If your ESXi host is connected to vCenter, open Configure -> Storage –> Storage Adapters to add an iSCSI LUN. Select Software iSCSI adapter and specify the name or the IP address of your iSCSI storage in the Dynamic Discovery tab. Click Rescan. A list of available iSCSI targets will appear in the Static Discovery tab.

Configuring iSCSI Datastore (LUN) on VMware ESXi

If you don’t see the list of iSCSI targets in your storage, you can diagnose iSCSI disk availability using the ESXi console.

Enable SSH on your ESXi host and connect to it using any SSH client (I use the built-in Windows 10 SSH client):

ssh [email protected]

Using the command below, you can check the availability of your iSCSI storage (192.168.113.10) from the specified vmkernel port (vmk1):

# vmkping -I vmk1 192.168.113.10

Configuring iSCSI Datastore (LUN) on VMware ESXi

In this example, the iSCSI storage responds to ping.

Then check if the iSCSI TCP Port 3260 is available on the storage using netcat (in this example, 192.168.113.60 is the IP address of the vmk1 interface):

# nc -s 192.168.113.60 -z 192.168.113.10 3260

Connection to 192.168.113.10 3260 port [tcp/*] succeeded!

Configuring iSCSI Datastore (LUN) on VMware ESXi

Make sure that the software iSCSI is enabled on your ESXi host:

# esxcli iscsi software get

true

Enable it if needed:

# esxcli iscsi software set -e true

Software iSCSI Enabled

You can also get the current settings of a software iSCSI HBA adapter as follows:

# esxcli iscsi adapter get -A vmhba65

Configuring iSCSI Datastore (LUN) on VMware ESXi

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

Create a VMFS Datastore on iSCSI LUN in VMWare ESXi

Then you can create a VMFS (Virtual Machine File System) datastore to store virtual machine files on the connected iSCSI LUN.

Open Storage -> Datastores -> New datastore.

Configuring iSCSI Datastore (LUN) on VMware ESXi

Enter the name of your VMFS datastore and select the iSCSI LUN to create it.

Configuring iSCSI Datastore (LUN) on VMware ESXi

Select VMFS 6 as a file system and specify that you want to entire the volume of the iSCSI disk for the datastore. In a few seconds, your new VMFS datastore will be available on ESXi.

Configuring iSCSI Datastore (LUN) on VMware ESXi

If the VMFS datastore has already been created on this LUN, it will immediately appear in the list of available Storage Devices on your host.

Configuring iSCSI Datastore (LUN) on VMware ESXi

So, you have connected the iSCSI disk to your ESXi host and created a VMFS datastore on it. Multiple ESXi servers can simultaneously access this datastore. Now you have shared storage, and if you configure a VMware vCenter server, you will be able to use vMotion to move running VMs between hosts.