Friday, 12 June 2015

How to configure ISCSI target in Redhat 7

@ Motive behind iscsi protocol is to send hard disk (block device) over the network
@ In redhat 7  we are going to setup a cli target
Step 1 :  To setup target you need to install software which is in version 7 (targetcli)
[root@redhat7 Desktop]# yum install targetcli
step 2 : There is no need to start the service or open configuration file so use targetcli command
====
[root@redhat7 Desktop]# targetcli
targetcli shell version 2.1.fb34
Copyright 2011-2013 by Datera, Inc and others.
For help on commands, type ‘help’.
/>                                                            # this is the prompt of targetcli
i)  To list the architecture of iscsi target
/> 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]
/>
ii) To create a iscsi target block
/> cd  /backstores/block
/backstores/block>
/backstores/block> create  newhd  /dev/sda7
Created block storage object newhd using /dev/sda7.
/backstores/block>
iii)  To  create an  IQN number use below stpes
/backstores/block> cd /iscsi
/iscsi>
/iscsi> create                                                               # create command will automatically IQN number
Created target iqn.2003-01.org.linux-iscsi.redhat7.x8664:sn.66955d1bd65c.
Created TPG 1.
/iscsi>
OR you can give your own IQN number in proper format
/iscsi> create  iqn.2014-10.com.example:iscsit
Created target iqn.2014-10.com.example:iscsit.
Created TPG 1.
/iscsi>
iV)  Now you need to configure the iscsi hard disk for client with given properities like acls , luns , portals
     ==========================================================================================================
/iscsi> cd /iscsi/iqn.2014-10.com.example:iscsit/tpg1/
/iscsi/iqn.20…e:iscsit/tpg1>
/iscsi/iqn.20…e:iscsit/tpg1> ls
o- tpg1 ……………………………………….. [no-gen-acls, no-auth]
  o- acls …………………………………………………. [ACLs: 0]
  o- luns …………………………………………………. [LUNs: 0]
  o- portals ……………………………………………. [Portals: 0]
 A)  Create a portal so that client can connect and access hard disk
 /iscsi/iqn.20…e:iscsit/tpg1> portals  create
Using default IP port 3260
Binding to INADDR_ANY (0.0.0.0)
Created network portal 0.0.0.0:3260.
/iscsi/iqn.20…e:iscsit/tpg1>
Note : IT will automatically create  3260 port binded with all ip of ISCSI server
Important:  You can create you won port and also can bind with any server IP using below step
=========
/iscsi/iqn.20…e:iscsit/tpg1> portals  create   192.168.0.20  1234
Created network portal 192.168.0.20:1234.
/iscsi/iqn.20…e:iscsit/tpg1>
B)  You also need to create a Logical unit number or Luns  for client hard disk
/iscsi/iqn.20…e:iscsit/tpg1> luns/  create /backstores/block/newhd
Created LUN 0.
/iscsi/iqn.20…e:iscsit/tpg1>
C)  By default acls must be implemented in version 7 .To two disable acls use below given steps
i)
/iscsi/iqn.20…fb47f492/tpg1> set  attribute  authentication=0
Parameter authentication is now ‘0’.
/iscsi/iqn.20…fb47f492/tpg1>
ii)
/iscsi/iqn.20…fb47f492/tpg1> set  attribute  generate_node_acls=1
Parameter generate_node_acls is now ‘1’.
/iscsi/iqn.20…fb47f492/tpg1>
Now you can login via any client and use Targetcli from command line which same as Redhat version 6

No comments:

Post a Comment