This blog article is similar to my previous notes VMWARE ESXI INSTALL AND CONFIGURE SOFTWARE ISCSI STORAGE ADAPTER FOR VMFS VERSION 6 DATASTORE. Here I am using VMware Powercli instead of vSphere web client to configure iScsi storage adpater and add new datastore. As this is complete powercli article I will not use GUI at all.
I am configuring my first Esxi server. Storing its information in variable called $VMhost.
$VMhost = Get-VMhost Esxi001.vcloud-lab.com
Next install and enable iSCSI software adapter.
$VMhost | Get-VMHostStorage | Set-VMHostStorage -SoftwareIScsiEnabled $True
Before processing further first I will do ping and telnet test on esxi server to storage and vice versa, As this is complete powercli article, for this I will enable SSH service on Esxi server using below command.
$VMHost | Get-VMHostService | ? {$_.Key -eq 'TSM-SSH'} | Start-VMHostService -Confirm:$false
Putty to esxi server. The telnet command is not available in any versions of ESXi and, therefore, you must use netcat (nc) to confirm connectivity to a TCP port on a remote host. The syntax of the nc command is: nc -z <destination-ip> <destination-port>, I am telneting port 3260 and succeeded means good (This is also a guide how to telnet in vmware esxi)
nc -z 172.20.1.101 3260
Connection to 172.20.1.101 3260 port [tcp/*] succeeded!
To use telnet command on Microsoft Windows telnet client needs to be installed with PowerShell command Install-WindowsFeature Telnet-Client. run telnet IP port, prompt is changed means I can go ahead with further configuration.
After enabling iScsi software adapter I need iSCSI IQN name, which I will need to add on storage server in initiator list.
$VMhost | Get-VMHostHba -Type iScsi | Select-Object Name, Status, IScsiName
Below command is ran on Microsoft iSCSI target, in the Initiator list, without this Esxi will not able to view or access LUN. Refer this article POWERSHELL INSTALLING AND CONFIGURING MICROSOFT ISCSI TARGET SERVER
Set-IscsiServerTarget -TargetName Boot-Esxi001 -InitiatorIds iqn:iqn.1998-01.com.vmware:esxi001-5abe60a5
Add storage target IP in the software iScsi storage adapter static discovery. (Get-VMHostHba -Type iscsi parameter shows software adapter)
$VMhost | Get-VMHostHba -Type iScsi | New-IScsiHbaTarget -Address 172.20.1.101
Next is needed devicename of iSCSI VMkernel adapter configured earlier. Ref. article POWERCLI: VMWARE ESXI CONFIGURE (VSWITCH) VMKERNEL NETWORK PORT FOR ISCSI STORAGE, with using Where-Object filtering on Get-VMHostNetworkAdapter -VMkernel I easily get the needed DeviceName. I got two results vmk1 and vmk2. note them down.
$VMhost | Get-VMHostNetworkAdapter -VMKernel | ? {$_.PortGroupName -match 'iSCSI'} | select Devicename
After getting information about VMkernel port name, I need device name of vmhba using:
$VMHost | Get-VMHostHba -Type IScsi | Select Device
Next step use EsxCli and add vmkernel ports to network port binding,
$esxcli = $VMhost | Get-EsxCli
$esxcli.iscsi.networkportal.add('vmhba65',$Null,'vmk1')
$esxcli.iscsi.networkportal.add('vmhba65',$Null,'vmk2')
Once everything is successful rescan for HBA and VMFS on esxi server.
$VMhost | Get-VMHostStorage -RescanAllHba -RescanVmfs
If above steps are successful, It requires NAA id of Free LUN for last step, to find free lun follow this article FIND FREE OR UNASSIGNED STORAGE LUN DISKS ON VMWARE ESXI SERVER.
Get-FreeEsxiLUNs -Esxihost Esxi001.vcloud-lab.com
Once NAA id is rectified use New-Datastore command to format LUN with VMFS type, I am using complete space here.
$VMhost | New-Datastore -Name Disk1_Tier3 -Path naa.60003ff44dc75adc9601165db783a4ac -Vmfs
If you add another Esxi host adding datastore is not required, This formatted datastore will be automatically be visible once configuring VMKernel ports and iSCSI software adapter. New-Datastore need to run once only for newly presented storage disk.
Series Parts
MICROSOFT WINDOWS 2012 R2 ISCSI TARGET STORAGE SERVER FOR ESXI AND HYPERV
POWERSHELL INSTALLING AND CONFIGURING MICROSOFT ISCSI TARGET SERVER
VMWARE ESXI CONFIGURE (VSWITCH) VMKERNEL NETWORK PORT FOR ISCSI STORAGE
POWERCLI: VMWARE ESXI CONFIGURE (VSWITCH) VMKERNEL NETWORK PORT FOR ISCSI STORAGE
VMWARE ESXI INSTALL AND CONFIGURE SOFTWARE ISCSI STORAGE ADAPTER FOR VMFS VERSION 6 DATASTORE
POWERCLI VMWARE: CONFIGURE SOFTWARE ISCSI STORAGE ADAPTER AND ADD VMFS DATASTORE
VMWARE VCENTER STORAGE MIGRATE/SVMOTION VM AND PORT BINDING MULTIPATHING TESTING
POWERCLI: VIRTUAL MACHINE STORAGE MIGRATE/SVMOTION AND DATASTORE PORT BINDING MULTIPATHING