Sponsored Link

Configure iSCSI Target (targetcli)2019/01/17

Configure Storage Server with iSCSI.
A storage on a network is called iSCSI Target, a Client which connects to iSCSI Target is called iSCSI Initiator. This example is based on the environment below.
+----------------------+          |          +----------------------+
| [   iSCSI Target   ] | || [ iSCSI Initiator  ] |
|    +----------+----------+    |
|                      |                     |                      |
+----------------------+                     +----------------------+

[1] Install administration tools.
dlp:~ #
zypper -n install python2-targetcli-fb
[2] Configure iSCSI Target.
For example, create an disk-image under the [/var/lib/iscsi_disks] directory and set it as a SCSI device.
# create a directory

dlp:~ #
mkdir /var/lib/iscsi_disks

# enter the admin console

dlp:~ #

targetcli shell version 2.1.fb47
Copyright 2011-2013 by Datera, Inc and others.
For help on commands, type 'help'.

/> cd backstores/fileio 

# create a disk-image with the name [disk01] on /var/lib/iscsi_disks/disk01.img with 10G
/backstores/fileio> create disk01 /var/lib/iscsi_disks/disk01.img 10G 
Created fileio disk01 with size 10737418240
/backstores/fileio> cd /iscsi 

# create a target
# naming rule : [ iqn.(year)-(month).(reverse of domain name):(any name you like) ]
/iscsi> create 
Created target
Created TPG 1.
Global pref auto_add_default_portal=true
Created default portal listening on all IPs (, port 3260.
/iscsi> cd 

# set LUN
/iscsi/iqn.20...t01/tpg1/luns> create /backstores/fileio/disk01 
Created LUN 0.
/iscsi/iqn.20...t01/tpg1/luns> cd ../acls 

# set ACL (it's the IQN of an initiator you permit to connect)
/iscsi/iqn.20...t01/tpg1/acls> create 
Created Node ACL for
Created mapped LUN 0.
/iscsi/iqn.20...t01/tpg1/acls> cd 

# set UserID for authentication
/iscsi/iqn.20...w.initiator01> set auth userid=username 
Parameter userid is now 'username'.
/iscsi/iqn.20...w.initiator01> set auth password=password 
Parameter password is now 'password'.
/iscsi/iqn.20...w.initiator01> exit 
Global pref auto_save_on_exit=true
Configuration saved to /etc/target/saveconfig.json

# after configuration above, the target enters in listening like follows

dlp:~ #
ss -napt | grep 3260

LISTEN   0         256          * 
[3] If Firewalld is running, allow iSCSI Target service.
dlp:~ #
firewall-cmd --add-service=iscsi-target --permanent

dlp:~ #
firewall-cmd --reload

Matched Content