iSCSI Storage Configuration Using Iscsiadm Command

N

nixsavy

Guest
In this article I would try to explain iscsi storage configuration on linux distro. We will first need iscsi initiator installed , that will use iscsi commands to communicate with the iscsi storage. What I would care more on this article , is to understand usage is iscsi commands to access / manage storage. First requirement is to install iscsi package and you can use open iscsi from open iscsi or you try installing using yum.

Code:
[root@centos-cluster-node1 ~]# yum install iscsi-initiator-utils

Query iscsi-initiator package installed or not


Code:
[root@centos-cluster-node1 ~]# rpm -qa | grep -i iscsi
iscsi-initiator-utils-6.2.0.873-2.el6.x86_64
[root@centos-cluster-node1 ~]#


Keep note of iscsi intiator name


Code:
[root@centos-cluster-node1 ~]# cat /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.1994-05.com.redhat:9f51e9794fa
[root@centos-cluster-node1 ~]#


Start the Iscsi service.

Code:
[root@centos-cluster-node1 ~]# service iscsi start

By default, the newly added iscsi initiator is not enabled at boot, which is the reason for each of the run levels listed to have the service set to off. To enable this at boot, again use the chkconfig command as follows.


Code:
[root@centos-cluster-node1 ~]# chkconfig –-add iscsi
[root@centos-cluster-node1 ~]# chkconfig iscsi on


Log into all targets

Code:
[root@centos-cluster-node1 ifaces]# iscsiadm –m node –l

To see the connection status

[
Code:
root@centos-cluster-node1 ifaces]# iscsiadm -m session

Login individual target

You can also Log into an individual target as below. You might see multiple iface because I have configured multipathing.


Code:
[root@centos-cluster-node1 ifaces]# iscsiadm -m node -l -T iqn.2001-05.com.equallogic:0-8a0906-3a86b2a07-c4e150b3415519cb-centos-cluster -l -p 192.168.40.10:3260
Logging in to [iface: default, target: iqn.2001-05.com.equallogic:0-8a0906-3a86b2a07-c4e150b3415519cb-centos-cluster, portal: 192.168.40.10,3260] (multiple)
Login to [iface: default, target: iqn.2001-05.com.equallogic:0-8a0906-3a86b2a07-c4e150b3415519cb-centos-cluster, portal: 192.168.40.10,3260] successful.
[root@centos-cluster-node1 ifaces]#


Logging out all targets.

Code:
[root@centos-cluster-node1 ifaces]# iscsiadm –m node –u

Logging off an individual target.

Shown an example below

Code:
iscsiadm –m node –u –T iqn.2001-05.com.equallogic:0-8a0906-3a86b2a07-c4e150b3415519cb-centos-cluster –p <Group IP address>:3260

Find device name

Find the newly created device name, using the iscsiadm command. In this test configuration, the new volume is /dev/sdb. At the end of the output you could see attached scsi disk name.

Code:
[root@centos-cluster-node1 ifaces]# iscsiadm -m session -P3

Dev Mapper device name

You can find the device name in /dev/mapper directory. I have configured multipath so you could see alias name as "centos_storage_node1". We could cover multipath configuration in another article.


Code:
[root@centos-cluster-node1 ifaces]# ls /dev/mapper/centos_*
/dev/mapper/centos_storage_node1


Create physical volume

Now from here its more simple. Creating physical volume


Code:
[root@centos-cluster-node1 ifaces]# pvcreate /dev/mapper/centos_storage_node1
  Physical volume "/dev/mapper/centos_storage_node1" successfully created
[root@centos-cluster-node1 ifaces]#


Creating a volume group


Code:
[root@centos-cluster-node1 ifaces]# vgcreate vg01 /dev/mapper/centos_storage_node1
  Volume group "vg01" successfully created
[root@centos-cluster-node1 ifaces]#


Creating logical volume


Code:
[root@centos-cluster-node1 /]# lvcreate -L 9G -n data vg01
  Logical volume "data" created
[root@centos-cluster-node1 /]#


Display logical volume


Code:
[root@centos-cluster-node1 /]# lvdisplay
  --- Logical volume ---
  LV Path                /dev/vg01/data
  LV Name                data
  VG Name                vg01
  LV UUID                dHGUcq-Smy9-4QuL-EW9e-mo7a-SLtE-ea2ySm
  LV Write Access        read/write
  LV Creation host, time centos-cluster-node1.local, 2013-05-22 09:16:57 -0400
  LV Status              available
  # open                0
  LV Size                9.00 GiB
  Current LE            2304
  Segments              1
  Allocation            inherit
  Read ahead sectors    auto
  - currently set to    256
  Block device          253:3
[root@centos-cluster-node1 /]#


Filesystem creation

Now you are ready for creating a file system with journaling mode enabled

Code:
[root@centos-cluster-node1 /]# mke2fs –j /dev/vg01/data

If you are using storage clustering try below gfs filesystem


Code:
[root@centos-cluster-node1 /]# mkfs.gfs2 -p lock_dlm -t cluster-centos:database -j 8 /dev/vg01/data
This will destroy any data on /dev/vg01/data.
It appears to contain: symbolic link to `../dm-3'

Are you sure you want to proceed? [y/n]

Device:                    /dev/vg01/data
Blocksize:                4096
Device Size                9.00 GB (2359296 blocks)
Filesystem Size:          9.00 GB (2359294 blocks)
Journals:                  8
Resource Groups:          36
Locking Protocol:          "lock_dlm"
Lock Table:                "cluster-centos:database"
UUID:                      f05156fa-cdf3-eaab-cda9-74c2d73d931a
[root@centos-cluster-node1 /]#


Some useful iscsiadm options

Delete session records

To manually delete the records sessions -o delete option. Be sure to enter the appropriate iscsi targetname

Code:
iscsiadm –o delete

Rescan lun

When you expand the volume or disk, you might need to rescan. So the below command will help.

Code:
iscsiadm -m node -p 192.168.40.10 --rescan
 

Attachments

  • slide.jpg
    slide.jpg
    17.6 KB · Views: 29,426
Last edited:


Excellent article. How did you manage the multipathing?
 

Staff online

Members online


Latest posts

Top