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:
[[email protected] ~]# yum install iscsi-initiator-utils
Query iscsi-initiator package installed or not


Code:
[[email protected] ~]# rpm -qa | grep -i iscsi
iscsi-initiator-utils-6.2.0.873-2.el6.x86_64
[[email protected] ~]#

Keep note of iscsi intiator name


Code:
[[email protected] ~]# cat /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.1994-05.com.redhat:9f51e9794fa
[[email protected] ~]#

Start the Iscsi service.

Code:
[[email protected] ~]# 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:
[[email protected] ~]# chkconfig –-add iscsi
[[email protected] ~]# chkconfig iscsi on

Log into all targets

Code:
[[email protected] ifaces]# iscsiadm –m node –l
To see the connection status

[
Code:
[email protected] 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:
[[email protected] 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.
[[email protected] ifaces]#

Logging out all targets.

Code:
[[email protected] 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:
[[email protected] 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:
[[email protected] ifaces]# ls /dev/mapper/centos_*
/dev/mapper/centos_storage_node1

Create physical volume

Now from here its more simple. Creating physical volume


Code:
[[email protected] ifaces]# pvcreate /dev/mapper/centos_storage_node1
  Physical volume "/dev/mapper/centos_storage_node1" successfully created
[[email protected] ifaces]#

Creating a volume group


Code:
[[email protected] ifaces]# vgcreate vg01 /dev/mapper/centos_storage_node1
  Volume group "vg01" successfully created
[[email protected] ifaces]#

Creating logical volume


Code:
[[email protected] /]# lvcreate -L 9G -n data vg01
  Logical volume "data" created
[[email protected] /]#

Display logical volume


Code:
[[email protected] /]# 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
[[email protected] /]#

Filesystem creation

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

Code:
[[email protected] /]# mke2fs –j /dev/vg01/data
If you are using storage clustering try below gfs filesystem


Code:
[[email protected] /]# 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
[[email protected] /]#

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

Last edited:



Members online


Top