Setup iSCSI storage on CentOS systems (Part Two)


This is the second part of Iscsi Setup. First Part can be found here

Since our iSCSI target is ready, we will now head to configure iSCSI target. This is also a CentOS 7.3 machine, but the process works almost similar in other Linux distribution.

Client configuration:

Before doing the configuration , we will use the “lsblk” command , so later we can see the difference.

[root@localhost ~]# lsblk

NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda               8:0    0    8G  0 disk 
├─sda1            8:1    0  500M  0 part /boot
└─sda2            8:2    0  7.5G  0 part 
  ├─centos-root 253:0    0  6.7G  0 lvm  /
  └─centos-swap 253:1    0  820M  0 lvm  [SWAP]
sr0              11:0    1 1024M  0 rom 

The client machine that access the iSCSI storage is called “iscsi initiator” . Lets install the iscsi initiator utilities in our client machine.

[root@localhost ~]# yum -y install iscsi-initiator-utils

To set the initiator name we need to edit the /etc/iscsi/initiatorname.iscsi file and put the correct initiator name in it. This initiator name has to match the acl we have created in the iscsi target.Open the inistaitor file with your favourite text editor.

[root@localhost ~]# vi /etc/iscsi/initiatorname.iscsi

And put the following in that file.

InitiatorName=iqn.2017-09.com.example:client1

restart the iscsid service to configuration change to take effect.

[root@localhost ~]# systemctl restart iscsid

In order to login to iscsi target we first need to discover it first.

[root@localhost ~]# iscsiadm --mode discovery --type sendtargets --portal 192.168.1.56
192.168.1.56:3260,1 iqn.2017-09.com.example:rock

Here, 192.168.1.56 is the IP address of the iscsi target in my test environment. Adjust it according to your environment. We can see that it has discovered our target named  iqn.2017-09.com.example:rock.

Next we will connect to the target.

We can get further information about the target using following command.

[root@localhost ~]# iscsiadm --mode discovery --type sendtargets --portal 192.168.1.56
192.168.1.56:3260,1 iqn.2017-09.com.example:rock
[root@localhost ~]# iscsiadm --mode discovery -P 1
SENDTARGETS:
DiscoveryAddress: 192.168.1.56,3260
Target: iqn.2017-09.com.example:rock
 Portal: 192.168.1.56:3260,1

 Iface Name: default

iSNS:

No targets found.

STATIC:

No targets found.

FIRMWARE:

No targets found.

Now to log into the target we use following command.

[root@localhost ~]# iscsiadm --mode node --targetname iqn.2017-09.com.example:rock --portal 192.168.1.56:3260 --login

Logging in to [iface: default, target: iqn.2017-09.com.example:rock, portal: 192.168.1.56,3260] (multiple)

Login to [iface: default, target: iqn.2017-09.com.example:rock, portal: 192.168.1.56,3260] successful.

Now, if we use the “lsblk” command , we can see two additional device “sdb” and ” sbc” of size 8Gb and 1Gb appears here.

We can also use the following command to specifically check the iscsi devices.

[root@localhost ~]# lsscsi
[0:0:0:0]    disk    ATA      VBOX HARDDISK    1.0   /dev/sda 
[3:0:0:0]    cd/dvd  VBOX     CD-ROM           1.0   /dev/sr0 
[7:0:0:0]    disk    LIO-ORG  block1           4.0   /dev/sdb 
[7:0:0:1]    disk    LIO-ORG  file1            4.0   /dev/sdc

Leave a comment

Your email address will not be published. Required fields are marked *