Managing iSCSI Sessions
To communicate with each other, iSCSI initiators and targets establish iSCSI sessions. You can use esxcli iscsi session to list and manage iSCSI sessions for software iSCSI and dependent hardware iSCSI.
Introduction to iSCSI Session Management
By default, software iSCSI and dependent hardware iSCSI initiators start one iSCSI session between each initiator port and each target port. If your iSCSI initiator or target has more than one port, your host can establish multiple sessions. The default number of sessions for each target equals the number of ports on the iSCSI adapter times the number of target ports. You can display all current sessions to analyze and debug them.You might add sessions to the default for several reasons.
Cloning sessions. Some iSCSI arrays support multiple sessions between the iSCSI adapter and target ports. If you clone an existing session on one of these arrays, the array presents more data paths for your adapter. Duplicate sessions do not persist across reboot. Additional sessions to the target might have performance benefits, but the result of cloning depends entirely on the array. You must log out from an iSCSI session if you want to clone a session. You can use the esxcli iscsi session add command to clone a session.
Enabling Header and Data Digest. If you are logged in to a session and want to enable the Header and Data Digest parameters, you must set the parameter, remove the session, and add the session back for the parameter change to take effect. You must log out from an iSCSI session if you want to clone a session.
Establishing target-specific sessions. You can establish a session to a specific target port. This can be useful if your host connects to a single-port storage system that, by default, presents only one target port to your initiator, but can redirect additional sessions to a different target port. Establishing a new session between your iSCSI initiator and another target port creates an additional path to the storage system.
Caution Some storage systems do not support multiple sessions from the same initiator name or endpoint. Attempts to create multiple sessions to such targets can result in unpredictable behavior of your iSCSI environment.
The following example scenario uses the available commands. Run esxcli iscsi session --help and each command with --help for reference information. The example uses a configuration file to log in to the host. Specify one of the options listed in Connection Options in place of <conn_options>.
Listing iSCSI Sessions
esxcli <conn_options> iscsi session list --adapter=<iscsi_adapter>
esxcli <conn_options> iscsi session list --name=<target> --adapter=<iscsi_adapter>
Logging in to iSCSI Sessions
You can use esxcli iscsi session to log in to a session. Specify one of the options listed in Connection Options in place of <conn_options>.
esxcli <conn_options> iscsi session add --adapter=<adapter_name>
For example:
esxcli --config /host-config-file iscsi session add --adapter=vmhba36
esxcli <conn_options> iscsi session add --name=<target> --adapter=<adapter_name>
For example:
esxcli --config /host-config-file iscsi session add -name=iqn.xxx --adapter=vmhba36
esxcli <conn_options> iscsi session add --name=<iqn.xxxx> --isid=<session_id>
--adapter=<iscsi_adapter>
iqn.xxxx is the target IQN, which you can determine by listing all sessions. session_id is the session’s iSCSI ID. For example:
esxcli --config /host-config-file iscsi session add -name=iqn.xxx --isid='00:02:3d:00:00:01' --adapter=vmhba36
Removing iSCSI Sessions
You can use esxcli iscsi session to remove iSCSI sessions. Specify one of the options listed in Connection Options in place of <conn_options>.
esxcli <conn_options> iscsi session remove --adapter=<iscsi_adapter>
For example:
esxcli iscsi session remove --adapter=vmhba36
esxcli <conn_options> iscsi session remove --name=<iqn> --adapter=<iscsi_adapter>
For example:
esxcli <conn_options> iscsi session remove --name=iqn.xxx --adapter=vmhba38
esxcli <conn_options> iscsi session remove --name=<iqn.xxxx> --isid=<session id>
--adapter=<iscsi_adapter>
iqn.xxxx is the target IQN, which you can determine by listing all sessions. session_id is the session’s iSCSI ID.
For example:
esxcli --config /host-config-file iscsi session remove --name=iqn.xxx --session='00:02:3d:01:00:01' --adapter=vmhba36