ISCSI TARGET (TARGETCLI) CONFIGURATION FOR RHEL/CENTOS 7x

Posted on March 6, 2017

0


ENVIRONMENT

OS = Centos 7.2

VG  name = centos_iscsi-target

LVM partitions = 1GB

LVM partition name 1G-ISCSI-VOL

Target package = targetcli      (yum install targetcli)

yum install epel-release(optional)

iscsid = started on hosts

iscsid = on at startup

 

STEPS

targetcli clearconfig confirm=true

[root@ISCSI-TARGET ~]# targetcli
targetcli shell version 2.1.fb41
Copyright 2011-2013 by Datera, Inc and others.
For help on commands, type 'help'.

CREATING STORAGE
/>
/> ls
o- / ......................................................................................................................... [...]
  o- backstores .............................................................................................................. [...]
  | o- block .................................................................................................. [Storage Objects: 0]
  | o- fileio ................................................................................................. [Storage Objects: 0]
  | o- pscsi .................................................................................................. [Storage Objects: 0]
  | o- ramdisk ................................................................................................ [Storage Objects: 0]
  o- iscsi ............................................................................................................ [Targets: 0]
  o- loopback ......................................................................................................... [Targets: 0]
/>
/> cd backstores/
/backstores> cd block
/backstores/block>
/backstores/block> ls
o- block ...................................................................................................... [Storage Objects: 0]
/backstores/block>

/backstores/block> create name=5G-ISCSI-VOL dev=/dev/centos_iscsi-target/5G-ISCSI-VOL
Created block storage object 5G-ISCSI-VOL using /dev/centos_iscsi-target/5G-ISCSI-VOL.

/backstores/block> ls
o- block ...................................................................................................... [Storage Objects: 1]
  o- 5G-ISCSI-VOL .......................................... [/dev/centos_iscsi-target/5G-ISCSI-VOL (5.0GiB) write-thru deactivated]
/backstores/block>
/backstores/block> cd ../..
/>

CREATING WWN
/iscsi>ls
/iscsi>
/> cd iscsi
/iscsi>
/iscsi> create
Created target iqn.2003-01.org.linux-iscsi.iscsi-target.x8664:sn.85506c6b5e47.
Created TPG 1.
Global pref auto_add_default_portal=true
Created default portal listening on all IPs (0.0.0.0), port 3260.

/iscsi> ls
o- iscsi .............................................................................................................. [Targets: 1]
  o- iqn.2003-01.org.linux-iscsi.iscsi-target.x8664:sn.85506c6b5e47 ...................................................... [TPGs: 1]
    o- tpg1 ................................................................................................. [no-gen-acls, no-auth]
      o- acls ............................................................................................................ [ACLs: 0]
      o- luns ............................................................................................................ [LUNs: 0]
      o- portals ...................................................................................................... [Portals: 1]
        o- 0.0.0.0:3260 ....................................................................................................... [OK]

CREATING LUNS
/iscsi> 
/iscsi> ls
o- iscsi .............................................................................................................. [Targets: 1]
  o- iqn.2003-01.org.linux-iscsi.iscsi-target.x8664:sn.85506c6b5e47 ...................................................... [TPGs: 1]
    o- tpg1 ................................................................................................. [no-gen-acls, no-auth]
      o- acls ............................................................................................................ [ACLs: 0]
      o- luns ............................................................................................................ [LUNs: 0]
      o- portals ...................................................................................................... [Portals: 1]
        o- 0.0.0.0:3260 ....................................................................................................... [OK]
/iscsi> cd iqn.2003-01.org.linux-iscsi.iscsi-target.x8664:sn.85506c6b5e47/
/iscsi/iqn.20....85506c6b5e47>
/iscsi/iqn.20....85506c6b5e47> ls
o- iqn.2003-01.org.linux-iscsi.iscsi-target.x8664:sn.85506c6b5e47 ........................................................ [TPGs: 1]
  o- tpg1 ................................................................................................... [no-gen-acls, no-auth]
    o- acls .............................................................................................................. [ACLs: 0]
    o- luns .............................................................................................................. [LUNs: 0]
    o- portals ........................................................................................................ [Portals: 1]
      o- 0.0.0.0:3260 ......................................................................................................... [OK]
/iscsi/iqn.20....85506c6b5e47> cd tpg1/luns
/iscsi/iqn.20...e47/tpg1/luns> ls
o- luns .................................................................................................................. [LUNs: 0]
/iscsi/iqn.20...e47/tpg1/luns>
/iscsi/iqn.20...e47/tpg1/luns> ls
o- luns .................................................................................................................. [LUNs: 0]
/iscsi/iqn.20...e47/tpg1/luns> create /backstores/block/5G-ISCSI-VOL
Created LUN 0.
/iscsi/iqn.20...e47/tpg1/luns>

CREATING ACLS / (REGISTER OR BIND YOUR HOSTS WITH TARGETS)
/iscsi/iqn.20...e47/tpg1/luns> cd ..
/iscsi/iqn.20...6c6b5e47/tpg1> ls
o- tpg1 ..................................................................................................... [no-gen-acls, no-auth]
  o- acls ................................................................................................................ [ACLs: 0]
  o- luns ................................................................................................................ [LUNs: 1]
  | o- lun0 ........................................................... [block/5G-ISCSI-VOL (/dev/centos_iscsi-target/5G-ISCSI-VOL)]
  o- portals .......................................................................................................... [Portals: 1]
    o- 0.0.0.0:3260 ........................................................................................................... [OK]
/iscsi/iqn.20...6c6b5e47/tpg1> cd acls
/iscsi/iqn.20...e47/tpg1/acls> ls
o- acls .................................................................................................................. [ACLs: 0]
/iscsi/iqn.20...e47/tpg1/acls>

/iscsi/iqn.20...e47/tpg1/acls> create
Missing required parameter wwn

FROM ON ALL HOSTS PICK INITIATOR INFORMATION
 [root@NODE1-HA ~]# cat /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.1994-05.com.redhat:a12c61dd92bb

[root@NODE2-HA ~]# cat /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.1994-05.com.redhat:216b2189eaa9

/iscsi/iqn.20...e47/tpg1/acls> create iqn.1994-05.com.redhat:a12c61dd92bb
Created Node ACL for iqn.1994-05.com.redhat:a12c61dd92bb
Created mapped LUN 0.
/iscsi/iqn.20...e47/tpg1/acls> create iqn.1994-05.com.redhat:216b2189eaa9
Created Node ACL for iqn.1994-05.com.redhat:216b2189eaa9
Created mapped LUN 0.
/iscsi/iqn.20...e47/tpg1/acls> ls
o- acls .................................................................................................................. [ACLs: 2]
  o- iqn.1994-05.com.redhat:216b2189eaa9 .......................................................................... [Mapped LUNs: 1]
  | o- mapped_lun0 .................................................................................. [lun0 block/5G-ISCSI-VOL (rw)]
  o- iqn.1994-05.com.redhat:a12c61dd92bb .......................................................................... [Mapped LUNs: 1]
    o- mapped_lun0 .................................................................................. [lun0 block/5G-ISCSI-VOL (rw)]
/iscsi/iqn.20...e47/tpg1/acls>

CREATE PORTAL
/> cd iscsi/iqn.2003-01.org.linux-iscsi.iscsi-target.x8664:sn.85506c6b5e47/tpg1/portals/
/iscsi/iqn.20.../tpg1/portals> create
Using default IP port 3260
Binding to INADDR_ANY (0.0.0.0)
This NetworkPortal already exists in configFS
/iscsi/iqn.20.../tpg1/portals>

SAVE CONFIGURATION
/> saveconfig

START & ENABLE TARGET.SERVICE
systemctl enable target.service
systemctl restart target.service

DISCOVER TARGET
iscsiadm -m discovery -t st -p 192.168.24.50

LOGIN FROM HOST TO TARGET
iscsiadm -m node -T  iqn.2003-01.org.linux-iscsi.iscsi-target.x8664:sn.85506c6b5e47 -p 192.168.24.50 -l

CHECK STORAGE ON HOST
fdisk -l

 

HELPFUL LINKS

https://wiki.rvijay.in/index.php/Configuring_iSCSI_target_using_targetcli

http://linux-iscsi.org/wiki/Targetcli

https://wiki.linuxhotel.de/lib/exe/fetch.php/lpi2:rhel_iscsi.pdf

TIPS

Makesure selinux,firewall disabled OR properly configured

 

Advertisements
Posted in: Linux