iSCSI initiator introduction
In CentOS/RHEL system, an iSCSI initiator is typically implemented in software and functions similar to a hardware iSCSI host bus adapter (HBA) to access targets from a remote storage server. Using a software-based iSCSI initiator requires connecting to an existing Ethernet network of sufficient bandwidth to carry the expected storage traffic.
iSCSI can also be implemented using a hardware initiator that includes the required protocols in a dedicated host bus adapter. iSCSI HBAs and TCP offload engines (TOE), which include the TCP network stack on an Ethernet NIC, move the processing of iSCSI or TCP overhead and Ethernet interrupts to hardware, easing the load on system CPUs.
Configuring an iSCSI client initiator requires installing the iscsi-initiator-utils package, which includes the iscsi and iscsid services and the /etc/iscsi/iscsid.conf and /etc/iscsi/initiatorname.iscsi configuration files.
As an iSCSI node, the client requires a unique iSCSJ Qualified Name (ION). The default /etc/iscsi/initiatorname.iscsi file contains a generated IQN using Red Hat’s domain. Administrators typically reset the IQN to their own domain and an appropriate client system string.
The /etc/iscsi/iscsid.conf file contains default settings for node records created during new target discovery. Settings include iSCSI timeouts, retry parameters, and authentication usernames and passwords. Changing this file requires restarting the iscsi service.
# systemctl restart iscsi
To be able to discover targets, install the iscsi-initiator-utils package, then enable and start the iscsi service. Targets must be discovered before device connection and use. The discovery process stores target node informat_ion and settings in the /var/lib/iscsi/nodes directory, using defaults from /etc/iscsi/iscsid.conf. Since the same target can exist on multiple portals, node records are stored for each portal. Perform discovery with the following command:
# iscsiadm -m discovery -t sendtargets -p target_server[:port] 172.25.X.11:3260,1 iqn.2014-06.com.example:serverX
In discovery mode, the sendtargets request returns only targets with access configured for this initiator. The port number can be omitted when the target server is configured on default port 3260. Upon discovery, a node record is written to /var/lib/iscsi/nodes and used for subsequent logins. To use the listed target, log in using the following command:
# iscsiadm -m node -T iqn.2014-06.com.example:serverX [-p target_server[:port]] -l
Specifying the portal is optional. If the target exists on multiple portals (e.g., in a multipathed, redundant server configuration), performing a login without specifying a portal will connect to every portal node that accepts this target name.
Once discovered, obtain information about targets with the iscsiadm command. Use the option -P N to set the command detail level, with 0 specifying the least verbose output.
- iscsiadm -m discovery [-P 0|1]: Show information about discovered targets.
iscsiadm -m node [ -P 0|1]: Show information about known targets.
- iscsiadm -m session [ -P 0|1|2|3]: Show information about active sessions.
To discontinue using a target, use iscsiadm to log out temporarily. By design, node records remain after logout and are used to automatically log into targets upon system reboot or iscsi service restart. Log out of a target using the following command (notice the similarity to login):
# iscsiadm -m node -T iqn.2012-04.com.example:example [P target_server[:port]] -u
If a portal is not specified, the target logs out of all relevant portals. To log into the target again, repeating discovery is not necessary since the node records already exist. Permanently logging out of a target requires deleting the node records so that manual or automatic login cannot reoccur without performing another discovery. Not specifying a portal removes the target node records for all relevant portals. Delete the node record permanently by using the following command (notice again the command similarity):
# iscsiadm -m node -T iqn.2012-04.com.example:example [-p target_server[:port]J -o delete