Saturday, 30 November 2019

How to Configure iSCSI Initiator Node on CentOS 7



iSCSI (Internet Small Computer Systems Interface) is an Internet Protocol based storage networking for connecting remote storage devices over the network. It provides block-level access to storage devices. iSCSI is used to facilitate block-level data data transfer between iSCSI initiator on a client machine and target on a storage server over local area networks (LANs), wide area networks (WANs).
This article describes How to Configure iSCSI Node on CentOS 7.

Step 1. Packages installation: Install the iscsi-initiator-utils package to configure iSCSI initiator on Linux systems:

[root@iscsi-initiator ~]# yum install iscsi-initiator-utils
Loaded plugins: fastestmirror
………………………………..
Installed:
  iscsi-initiator-utils.x86_64 0:6.2.0.874-10.el7

Dependency Installed:
  iscsi-initiator-utils-iscsiuio.x86_64 0:6.2.0.874-10.el7

Complete!
[root@iscsi-initiator ~]#

Step 2. iSCSI Initiatorname Configuration: Edit the /etc/iscsi/initiatorname.iscsi file and replace the Initiatorname with the earlier created in ACL on target server and comment all other initiator names if any present in this and not in use anymore:

[root@iscsi-initiator ~]# vi /etc/iscsi/initiatorname.iscsi
#InitiatorName=iqn.1994-05.com.redhat:386a688ba762
InitiatorName=iqn.2019-08.local.linuxcnf.iscsi-target:iscsi-disk1:iscsi-initiator
[root@iscsi-initiator ~]#

 Step 3. Restart iscsid services: Run the following commands to enable on system startup and restart the service to reflect the change:

[root@iscsi-initiator ~]# systemctl enable iscsid
Created symlink from /etc/systemd/system/multi-user.target.wants/iscsid.service to /usr/lib/systemd/system/iscsid.service.
[root@iscsi-initiator ~]# systemctl restart iscsid
[root@iscsi-initiator ~]#

Step 4. iSCSI Discovery: Discover the target using the below command:

[root@iscsi-initiator ~]# iscsiadm --mode discovery --type sendtargets --portal 192.168.43.14 --discover
192.168.43.14:3260,1 iqn.2019-08.local.linuxcnf.iscsi-target:iscsi-disk1
[root@iscsi-initiator ~]#

Step 5. Create iSCSI Initiator Session: Run the following command for making connection:

[root@iscsi-initiator ~]# iscsiadm --mode node --targetname iqn.2019-08.local.linuxcnf.iscsi-target:iscsi-disk1 --login
Logging in to [iface: default, target: iqn.2019-08.local.linuxcnf.iscsi-target:iscsi-disk1, portal: 192.168.43.14,3260] (multiple)
Login to [iface: default, target: iqn.2019-08.local.linuxcnf.iscsi-target:iscsi-disk1, portal: 192.168.43.14,3260] successful.
[root@iscsi-initiator ~]#

Step 6. Verification: Once the session created successfully verify the LUNs using below commands:

[root@iscsi-initiator ~]# lsscsi
…………………………
[3:0:0:0]    disk    LIO-ORG  iscsi-disk1      4.0   /dev/sdb
[root@iscsi-initiator ~]#

[root@iscsi-initiator ~]# cat /proc/partitions
…………………………
   8       16    5242880 sdb
[root@iscsi-initiator ~]#

Here the iscsi target mapped to the disk /dev/sdb. Use the following command to monitor the iscsi session:

[root@iscsi-initiator ~]# iscsiadm --mode node -P 1
Target: iqn.2019-08.local.linuxcnf.iscsi-target:iscsi-disk1
        Portal: 192.168.43.14:3260,1
                Iface Name: default
[root@iscsi-initiator ~]#

Done!!! iSCSI Initiator Node is configured successfully. Session is created and iscsi target mapped to the disk /dev/sdb in iscsi initiator system.

iSCSI Target Node Configuration: Follow the article How to Install and Configure iSCSI Target on CentOS 7.

No comments:

Post a comment