Este conteúdo não está disponível no idioma selecionado.
Chapter 7. Configuring an iSCSI initiator
An iSCSI initiator forms a session to connect to the iSCSI target. By default, an iSCSI service is lazily started and the service starts after running the iscsiadm command. If root is not on an iSCSI device or there are no nodes marked with node.startup = automatic then the iSCSI service will not start until an iscsiadm command is executed that requires iscsid or the iscsi kernel modules to be started.
Execute the systemctl start iscsid command as root to force the iscsid service to run and iSCSI kernel modules to load.
7.1. Creating an iSCSI initiator Copiar o linkLink copiado para a área de transferência!
Create an iSCSI initiator to connect to the iSCSI target to access the storage devices on the server.
Prerequisites
You have an iSCSI target’s hostname and IP address:
- If you are connecting to a storage target that the external software created, find the target’s hostname and IP address from the storage administrator.
- If you are creating an iSCSI target, see Creating an iSCSI target.
Procedure
Install
iscsi-initiator-utilson client machine:dnf install iscsi-initiator-utils
# dnf install iscsi-initiator-utilsCopy to Clipboard Copied! Toggle word wrap Toggle overflow Start the
iscsidservice:systemctl start iscsid
# systemctl start iscsidCopy to Clipboard Copied! Toggle word wrap Toggle overflow Check the initiator name:
cat /etc/iscsi/initiatorname.iscsi InitiatorName=iqn.2006-04.com.example:888
# cat /etc/iscsi/initiatorname.iscsi InitiatorName=iqn.2006-04.com.example:888Copy to Clipboard Copied! Toggle word wrap Toggle overflow If the ACL was given a custom name in Creating an iSCI ACL, update the initiator name to match the ACL:
Open the
/etc/iscsi/initiatorname.iscsifile and modify the initiator name:vi /etc/iscsi/initiatorname.iscsi
# vi /etc/iscsi/initiatorname.iscsi InitiatorName=custom-nameCopy to Clipboard Copied! Toggle word wrap Toggle overflow Restart the
iscsidservice:systemctl restart iscsid
# systemctl restart iscsidCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Discover the target and log in to the target with the displayed target IQN:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Replace 10.64.24.179 with the target-ip-address.
You can use this procedure for any number of initiators connected to the same target if their respective initiator names are added to the ACL as described in the Creating an iSCSI ACL.
Find the iSCSI disk name and create a file system on this iSCSI disk:
grep "Attached SCSI" /var/log/messages mkfs.ext4 /dev/disk_name
# grep "Attached SCSI" /var/log/messages # mkfs.ext4 /dev/disk_nameCopy to Clipboard Copied! Toggle word wrap Toggle overflow Replace disk_name with the iSCSI disk name displayed in the
/var/log/messagesfile.Mount the file system:
mkdir /mount/point mount /dev/disk_name /mount/point
# mkdir /mount/point # mount /dev/disk_name /mount/pointCopy to Clipboard Copied! Toggle word wrap Toggle overflow Replace /mount/point with the mount point of the partition.
Edit the
/etc/fstabfile to mount the file system automatically when the system boots:vi /etc/fstab
# vi /etc/fstab /dev/disk_name /mount/point ext4 _netdev 0 0Copy to Clipboard Copied! Toggle word wrap Toggle overflow Replace disk_name with the iSCSI disk name and /mount/point with the mount point of the partition.
7.2. Setting up the Challenge-Handshake Authentication Protocol for the initiator Copiar o linkLink copiado para a área de transferência!
By using the Challenge-Handshake Authentication Protocol (CHAP), users can protect the target with a password. The initiator must be aware of this password to be able to connect to the target.
Prerequisites
- Created iSCSI initiator. For more information, see Creating an iSCSI initiator.
-
Set the
CHAPfor the target. For more information, see Setting up the Challenge-Handshake Authentication Protocol for the target.
Procedure
Enable CHAP authentication in the
iscsid.conffile:vi /etc/iscsi/iscsid.conf
# vi /etc/iscsi/iscsid.conf node.session.auth.authmethod = CHAPCopy to Clipboard Copied! Toggle word wrap Toggle overflow By default, the
node.session.auth.authmethodis set toNoneAdd target
usernameandpasswordin theiscsid.conffile:node.session.auth.username = redhat node.session.auth.password = redhat_passwd
node.session.auth.username = redhat node.session.auth.password = redhat_passwdCopy to Clipboard Copied! Toggle word wrap Toggle overflow Restart the
iscsidservice:systemctl restart iscsid
# systemctl restart iscsidCopy to Clipboard Copied! Toggle word wrap Toggle overflow
7.3. Monitoring an iSCSI session by using the iscsiadm utility Copiar o linkLink copiado para a área de transferência!
You can monitor the iscsi session by using the iscsiadm utility.
By default, an iSCSI service is lazily started and the service starts after running the iscsiadm command. If root is not on an iSCSI device or there are no nodes marked with node.startup = automatic then the iSCSI service will not start until an iscsiadm command is executed that requires iscsid or the iscsi kernel modules to be started.
Use the systemctl start iscsid command as root to force the iscsid service to run and iSCSI kernel modules to load.
Procedure
Install the
iscsi-initiator-utilson client machine:dnf install iscsi-initiator-utils
# dnf install iscsi-initiator-utilsCopy to Clipboard Copied! Toggle word wrap Toggle overflow Find information about the running sessions:
iscsiadm -m session -P 3
# iscsiadm -m session -P 3Copy to Clipboard Copied! Toggle word wrap Toggle overflow This command displays the session or device state, session ID (sid), some negotiated parameters, and the SCSI devices accessible through the session.
For shorter output, for example, to display only the
sid-to-nodemapping, run:Copy to Clipboard Copied! Toggle word wrap Toggle overflow These commands print the list of running sessions in the following format:
driver [sid] target_ip:port,target_portal_group_tag proper_target_name.
7.4. DM Multipath overrides of the device timeout Copiar o linkLink copiado para a área de transferência!
The recovery_tmo sysfs option controls the timeout for a particular iSCSI device. The following options globally override the recovery_tmo values:
-
The
replacement_timeoutconfiguration option globally overrides therecovery_tmovalue for all iSCSI devices. For all iSCSI devices that are managed by DM Multipath, the
fast_io_fail_tmooption in DM Multipath globally overrides therecovery_tmovalue.The
fast_io_fail_tmooption in DM Multipath also overrides thefast_io_fail_tmooption in Fibre Channel devices.
The DM Multipath fast_io_fail_tmo option takes precedence over replacement_timeout. Every time the multipathd service is reloaded, it resets recovery_tmo to the value of the fast_io_fail_tmo configuration option. Use the DM multipath fast_io_fail_tmo configuration option to override recovery_tmo in devices managed by DM Multipath.