Setting up iscsi sharing between RHEL7

by Jephe Wu

=== On target side

1. Add a volume on AWS EC2 console and assign volume to the EC2 VM

confirmed new volume in /proc/partitions

fdisk /dev/xvdf

to create one partition with linux type

2.  yum install targetcli
systemctl enable target
systemctl start target

3. setup target lun

[root@ip-172-31-4-10 ec2-user]# targetcli
targetcli shell version 2.1.fb49
Copyright 2011-2013 by Datera, Inc and others.
For help on commands, type 'help'.
/> iscsi/
/iscsi> create
Created target iqn.2003-01.org.linux-iscsi.ip-172-31-4-10.x8664:sn.82d2391e0b7c.
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.ip-172-31-4-10.x8664:sn.82d2391e0b7c .................................................... [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.2003-01.org.linux-iscsi.ip-172-31-4-10.x8664:sn.82d2391e0b7c/tpg1


/iscsi/iqn.20...391e0b7c/tpg1> /
/> /backstores/block create name=block_backend dev=/dev/xvdf
Created block storage object block_backend using /dev/xvdf.
/> iscsi/
/iscsi> iqn.2003-01.org.linux-iscsi.ip-172-31-4-10.x8664:sn.82d2391e0b7c/tpg1
/iscsi/iqn.20...391e0b7c/tpg1> luns/ create /backstores/block/block_backend
Created LUN 0.
/iscsi/iqn.20...391e0b7c/tpg1> ls
o- tpg1 ..................................................................................................... [no-gen-acls, no-auth]
  o- acls ................................................................................................................ [ACLs: 0]
  o- luns ................................................................................................................ [LUNs: 1]
  | o- lun0 ................................................................... [block/block_backend (/dev/xvdf) (default_tg_pt_gp)]
  o- portals .......................................................................................................... [Portals: 1]
    o- 0.0.0.0:3260 ........................................................................................................... [OK]
/iscsi/iqn.20...391e0b7c/tpg1> /

/iscsi> iqn.2003-01.org.linux-iscsi.ip-172-31-4-10.x8664:sn.82d2391e0b7c/tpg1

/iscsi/iqn.20...391e0b7c/tpg1> acls/
/iscsi/iqn.20...b7c/tpg1/acls> create iqn.1994-05.com.redhat:413be97b32f2
Created Node ACL for iqn.1994-05.com.redhat:413be97b32f2
Created mapped LUN 0.

/iscsi/iqn.20...391e0b7c/tpg1> ls
o- tpg1 ..................................................................................................... [no-gen-acls, no-auth]
  o- acls ................................................................................................................ [ACLs: 1]
  | o- iqn.1994-05.com.redhat:413be97b32f2 ........................................................................ [Mapped LUNs: 1]
  |   o- mapped_lun0 ............................................................................... [lun0 block/block_backend (rw)]
  o- luns ................................................................................................................ [LUNs: 1]
  | o- lun0 ................................................................... [block/block_backend (/dev/xvdf) (default_tg_pt_gp)]
  o- portals .......................................................................................................... [Portals: 1]
    o- 0.0.0.0:3260 ........................................................................................................... [OK]


====on client side

[root@ip-172-31-8-24 ec2-user]#  yum install iscsi-initiator-utils


[root@ip-172-31-0-31 iscsi]# iscsiadm -m discovery -t st -p 172.31.4.10 
172.31.4.10:3260,1 iqn.2003-01.org.linux-iscsi.ip-172-31-4-10.x8664:sn.82d2391e0b7c

[root@ip-172-31-0-31 iscsi]# iscsiadm -m node -T iqn.2003-01.org.linux-iscsi.ip-172-31-4-10.x8664:sn.82d2391e0b7c -l
Logging in to [iface: default, target: iqn.2003-01.org.linux-iscsi.ip-172-31-4-10.x8664:sn.82d2391e0b7c, portal: 172.31.4.10,3260] (multiple)
Login to [iface: default, target: iqn.2003-01.org.linux-iscsi.ip-172-31-4-10.x8664:sn.82d2391e0b7c, portal: 172.31.4.10,3260] successful.

[root@ip-172-31-0-31 iscsi]# dmesg | grep sda
[348576.211493] sd 4:0:0:0: [sda] 20971520 512-byte logical blocks: (10.7 GB/10.0 GiB)
[348576.221556] sd 4:0:0:0: [sda] Write Protect is off
[348576.226764] sd 4:0:0:0: [sda] Mode Sense: 43 00 00 08
[348576.227815] sd 4:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[348576.256350]  sda: sda1
[348576.263152] sd 4:0:0:0: [sda] Attached SCSI disk

there's no need to enable any client service, as kernel will detect iscsi drive automatically below

----
[   12.312069] Loading iSCSI transport class v2.0-870.
[   12.354416] iscsi: registered transport (tcp)
[   12.382519] scsi host2: iSCSI Initiator over TCP/IP
[   12.398666] scsi 2:0:0:0: Direct-Access     LIO-ORG  block_backend    4.0  PQ: 0 ANSI: 5
[   12.417146] scsi 2:0:0:0: alua: supports implicit and explicit TPGS
[   12.422931] scsi 2:0:0:0: alua: device naa.600140563a0ac28e2414b52a3c5f8f89 port group 0 rel port 1
[   12.431126] scsi 2:0:0:0: alua: Attached
[   12.438279] scsi 2:0:0:0: alua: transition timeout set to 60 seconds
[   12.445803] scsi 2:0:0:0: alua: port group 00 state A non-preferred supports TOlUSNA
[   12.458154] scsi 2:0:0:0: Attached scsi generic sg0 type 0
[   12.506779] sd 2:0:0:0: [sda] 20971520 512-byte logical blocks: (10.7 GB/10.0 GiB)
[   12.543041] sd 2:0:0:0: [sda] Write Protect is off
[   12.547556] sd 2:0:0:0: [sda] Mode Sense: 43 00 00 08
[   12.564423] sd 2:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[   12.597412]  sda: sda1
[   12.609015] sd 2:0:0:0: [sda] Attached SCSI disk
----

References


iscsiadm -m session [-P1 | -P3]
login all Luns exported on the target: iscsiadm -m discovery -t st -l
node and discovery database directory: /var/lib/iscsi
disconnect: iscsiadm -m node -T target_iqn_name -p ipaddress -u
remove target from database so it won't connect upon reboot: iscsiadm -m node -T target_iqn_name -p ipaddress --op delete
delete all bindings for iface0: iscsiadm -m node -I iface0 --op=delete
logout all target: iscsiadm -m node -U all
login all node: iscsiadm -m node -L all
rescan lun: iscsiadm -m node -p 192.168.40.10 --rescan
check /var/lib/iscsi interface directory:



No comments:

Post a Comment