ESXi - iSCSI

最後更新: 2020-12-30

目錄

  • mount/un-mount
  • iscsi shared storage

Activate/Disable the Software iSCSI Adapter

 

Activate the Software iSCSI Adapter

vSphere Client -> Configuration tab -> Storage Adapters ->

Add -> select Software iSCSI Adapter -> Properties -> Configure -> select "Enabled"

Disable the Software iSCSI Adapter

vSphere Client -> Configuration -> Storage Adapters ->

Select "software iSCSI adapter" -> Properties -> Configure -> deselect "Enabled"

 


Config Software iSCSI Adapter

 

1. Add Software iSCSI Adapter

Configuration -> Storage adapters -> Add -> Click "Add Software 'iSCSI' Adapter"

2. Set local adapter name

Click "created adapter" -> Properties

Click "Configure" and set the Name to the IQN for the esxi

3. Assign NIC

"Network Configuration" Tab -> select NIC

4. Add LUN

Click the "Dynamic Discovery Tab" then click the "Add"

CHAP -> Use CHAP -> input Name & Secret

Right-click "created adapter" -> Rescan

The device turns gray and is 'unmounted' -> Right-click the device name and select attach

5. Add Storage

"Storage" Tab -> Add Storage... -> Disk/LUN -> 在 Storage Adapters 見到的 Devices

 


Enable Jumbo Frames for iSCSI

 

Configuration -> Networking -> Select switch(use for iSCSI traffic) Properties -> Ports tab -> select vSwitch -> Edit -> MTU
 

 


Un-mount

 

Unmount

just going to detach the device from that host and you do not loose any data

CLI

esxcli storage filesystem unmount -l LUN01
esxcli storage filesystem unmount -u 4e414917-a8d75514-6bae-0019b9f1ecf4
esxcli storage filesystem unmount -p /vmfs/volumes/4e414917-a8d75514-6bae-0019b9f1ecf4

Detach

You might need to detach the device to make it inaccessible to your host,

when, for example, you perform a hardware upgrade on the storage side.

Delete

This option will delete the data from your datastore.

The datastore delete operation permanently deletes all files associated with virtual machines on the datastore.

Although you can delete the datastore without unmounting, it is preferable that you unmount the datastore first.

 

Unmount 前要 ...

If the LUN is being used as a VMFS datastore, all objects, (such as virtual machines, snapshots, and templates)

stored on the VMFS datastore are unregistered or moved to another datastore.

All CD/DVD images located on the VMFS datastore must also be unregistered from the virtual machines.

補充

From the vSphere Client, this information is visible in the Properties window of the datastore.

CLI

esxcli storage vmfs extent list

Volume Name  VMFS UUID                            Extent Number  Device Name                           Partition
-----------  -----------------------------------  -------------  ------------------------------------  ---------
RAID6        57b8930b-a409c0a6-c88b-d4ae5275577e              0  naa.6782bcb0138478001f540cc410d12907          3
6000G_R1     59f931f8-c85576f2-939c-782bcb780071              0  naa.600140519d4ed05191948a1b9d6a2f04          1

use the vsphere client to:

1)perform the unmount for each host (or can be done for all hosts at once from the datastores and clusters view), then
2)perform the "detach" operation for each host individually from the vsphere client (step 3 below)
3)unpresent the LUN using vendor-specific storage tools/consoles
4)rescan from all hosts using the vsphere client

When  the device is detached, it stays in an unmounted state even if the device is represented (that is, the detached state is persistent).

To bring the device back online, the device must be attached.

After you unmount a VMFS datastore, the datastore becomes inactive and is dimmed in the host's datastore list.

An unmounted NFS datastore no longer appears on the list.

 

When the device is detached, it stays in an unmounted state even if the device is re-presented (that is, the detached state is persistent).

To bring the device back online, the device must be attached.

permanently decommission from an ESXi host

=> manually remove the NAA entries from the host configuration:

# To list the permanently detached devices, run this command:

esxcli storage core device detached list

Device UID State
------------------------------------ -----
naa.50060160c46036df50060160c46036df off
naa.6006016094602800c8e3e1c5d3c8e011 off

# To permanently remove the device configuration information from the system, run this command:

esxcli storage core device detached remove -d NAA_ID

 


Remove dead lun

 

 

# 當 Guest 沒有 mount 它上面的檔案( iso) 或沒東西要寫入(sync)時, 就可以用以下 cmd remove 佢

esxcfg-rescan -d vmhba35;

 


Disconnect the connection

 

# List session

esxcli iscsi session list

vmhba35,iqn.2003-01.org.linux-iscsi.backup2.x8664:sn.ee167d963b96,00023d000001
   Adapter: vmhba35
   Target: iqn.2003-01.org.linux-iscsi.backup2.x8664:sn.ee167d963b96
   ISID: 00023d000001
   TargetPortalGroupTag: 1
   AuthenticationMethod: none
   DataPduInOrder: true
   DataSequenceInOrder: true
   DefaultTime2Retain: 0
   DefaultTime2Wait: 2
   ErrorRecoveryLevel: 0
   FirstBurstLength: 65536
   ImmediateData: true
   InitialR2T: true
   MaxBurstLength: 262144
   MaxConnections: 1
   MaxOutstandingR2T: 1
   TSIH: 9180

# Disconnect the session

# The iSCSI adapter name, for example, vmhba34. This option is required.
-A|--adapter=str

# The iSCSI target name, for example, iqn.X.
-n|--name=str

esxcli iscsi session remove -A vmhba35 -n iqn.2003-01.org.linux-iscsi.backup2.x8664:sn.ee167d963b96

 


Mount iscsi by cli

 

ESXi 6, 7 don't support iSCSI CRC chechsums, so "Data Digest" and "Header Digest"

It does support them as advanced options.

 * Depending on the type of your adapters, certain parameters might not be available.

=======

# 查看有無 Enable software iscsi

esxcli iscsi software get

true

# 如上上一 result 不是 true, 就要 Enable software iSCSI

esxcli iscsi software set -e true

# If no adapter exists, add one.
# -n <nic_iSCSI_target(iqn.xxx:xxx)(UID)> -A <vmhba>

esxcli iscsi networkportal add -n iqn.esxi -A vmhba64

# Info.

esxcli iscsi adapter list

Adapter  Driver     State   UID                                   Description
-------  ---------  ------  ------------------------------------  -----------
vmhba64  iscsi_vmk  online  iqn.1998-01.com.vmware:vms0-199aec7a  iSCSI Software Adapter

# Software adapter Info

esxcli iscsi adapter get -A vmhba64
vmhba64
   Name: iqn.1998-01.com.vmware:vms0-199aec7a
   Alias: iqn.office-esxi
   Vendor: VMware
   Model: iSCSI Software Adapter
   ...

esxcli iscsi adapter capabilities get -A vmhba64

vmhba64
   ISnS Settable: false
   SLP Settable: false
   Static Discovery Settable: false
   Sendtarget Discovery Settable: false
   ....

# Add a dynamic discovery address

esxcli iscsi adapter discovery sendtarget add -A vmhba64 -a 192.168.88.31

esxcli iscsi adapter discovery sendtarget param get -A vmhba64 -a 192.168.88.31

Name                  Current     Default     Min  Max       Settable  Inherit
--------------------  ----------  ----------  ---  --------  --------  -------
ErrorRecoveryLevel    0           0           0    2            false     true
InitialLoginRetryMax  4           4           0    64           false     true
...

esxcli iscsi adapter target portal list

Adapter  Target                      IP             Port  Tpgt
-------  --------------------------  -------------  ----  ----
vmhba64  iqn.synology:MyNAS.esxi-tg  192.168.88.31  3260  1
vmhba64  iqn.synology:MyNAS.esxi-tg  192.168.99.31  3260  1
....

# 設定 Login
# -D|--default          Resetting iSCSI authentication setting to default.
# -d|--direction=<str>  The iSCSI authentication direction. Options are: [uni, mutual]
# -l|--level=<str>      The iSCSI authentication level. Options are: [prohibited, discouraged, preferred, required]
# -N|--authname=<str>
# -S|--secret=<str>

esxcli iscsi adapter target portal auth chap set \
-N ? -S ? \
-A vmhba64 -a 192.168.88.31 -n iqn.synology:MyNAS.esxi-tg \
--direction=uni --level=required

# checking

esxcli iscsi adapter auth chap get -A vmhba64

   Direction: uni
   Name:
   Level: prohibited

# After setup is complete, perform rediscovery and rescan all storage devices.
esxcli iscsi adapter discovery rediscover -A vmhba64
Rediscovery started

esxcli storage core adapter rescan --adapter=vmhba64

#  logout & login

esxcli iscsi session list

esxcli iscsi session remove -A vmhba64

esxcli iscsi session add -A vmhba64

# 連線成功後. 可以見到有什麼 LUN

esxcli iscsi adapter target lun list

Adapter  LUN Identifier                        Channel Number  Target Number  LUN Number  LUN Size in MB
-------  ------------------------------------  --------------  -------------  ----------  --------------
vmhba64  naa.6001405121f0963dba19d4751da98ad6               0              0           1          409600

===============

esxcli storage filesystem [list|mount|unmount|rescan]

# -u|--volume-uuid=<str>
# -l|--volume-label=<str>
# -n|--no-persist

esxcli storage filesystem mount -u 5f5f2c2f-31fb59ce-ad12-a0369f8c3aec

esxcli storage filesystem list

esxcli storage core adapter rescan --all

 


Remout iSCSI Datastorage

 

Symptoms:

After cloning snapshot on SAN storage can’t mount the snapshot volume as a datastore to register the VM.

Version: ESXi 6.5, 6.7, 7.0

解決:

要完全 disconnect 先.

unmount datastorage

disconnect iscsi

 


iscsi shared storage

 

VMFS is a clustered file system => multiple hosts access the same VMFS datastore concurrently

* multiple hosts do not access the same virtual machine at the same time 

   => VMFS provides on-disk locking

 

VMFS Locking Mechanisms

  • ATS-Only Mechanism
  • ATS+SCSI Mechanism

ATS = atomic test and set locking

它是 hardware assisted locking

The ATS algorithm supports discrete locking per disk sector.

ATS+SCSI Mechanism

會嘗試用 ATS 先, 當失敗時會轉用 SCSI reservations

the SCSI reservations lock an entire storage device => performance degradation

 


 

 

 

 

 

Creative Commons license icon Creative Commons license icon