Ubuntu 16.04
Sponsored Link

Configure iSCSI Taregt(targetcli)
2016/04/23
 
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   ] |10.0.0.30 | 10.0.0.31| [ iSCSI Initiator  ] |
|     dlp.srv.world    +----------+----------+     www.srv.world    |
|                      |                     |                      |
+----------------------+                     +----------------------+

[1] Install administration tools first.
root@dlp:~#
apt-get -y install targetcli
[2] Configure iSCSI Target.
For example, create an disk-image under the /var/iscsi_disks directory and set it as a SCSI device.
# create a directory

root@dlp:~#
mkdir /var/iscsi_disks

# enter the admin console

root@dlp:~#
targetcli

targetcli 3.0.pre4.1~ga55d018 (rtslib 3.0.pre4.1~g1b33ceb)
Copyright (c) 2011-2014 by Datera, Inc.
All rights reserved.

/>
cd backstores/fileio
# create a disk-image with the name "disk01" on /var/iscsi_disks/disk01.img with 10G

/backstores/fileio>
create disk01 /var/iscsi_disks/disk01.img 10G

Using buffered mode.
Created fileio disk01.
/backstores/fileio>
cd /iscsi
# create a target

/iscsi>
create iqn.2016-04.world.srv:storage.target00

Created target iqn.2016-04.world.srv:storage.target00.
Selected TPG Tag 1.
Created TPG 1.
# set portal (set IP address to listen)

/iscsi>
cd iqn.2016-04.world.srv:storage.target00/tpg1/portals

/iscsi/iqn.20.../tpg1/portals>
create 0.0.0.0

Using default IP port 3260
Created network portal 0.0.0.0:3260.
/iscsi/iqn.20.../tpg1/portals>
cd ../luns
# set LUN

/iscsi/iqn.20...t00/tpg1/luns>
create /backstores/fileio/disk01

Selected LUN 0.
Created LUN 0.
/iscsi/iqn.20...t00/tpg1/luns>
cd ../acls
# set ACL (it's the IQN of an initiator you permit to connect)

/iscsi/iqn.20...t00/tpg1/acls>
create iqn.2016-04.world.srv:www.srv.world

Created Node ACL for iqn.2016-04.world.srv:www.srv.world:www.srv.world
Created mapped LUN 0.
/iscsi/iqn.20...t00/tpg1/acls>
cd iqn.2016-04.world.srv:www.srv.world
# set UserID for authentication

/iscsi/iqn.20....srv.world>
set auth userid=username

Parameter userid is now 'username'.
/iscsi/iqn.20....srv.world>
set auth password=password

Parameter password is now 'password'.
/iscsi/iqn.20....srv.world>
exit

Comparing startup and running configs...
Some changes need saving.
Save configuration? [Y/n]:
y

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

root@dlp:~#
ss -napt | grep 3260

LISTEN     0      256          *:3260                     *:*

# set auto-start

root@dlp:~#
/lib/systemd/systemd-sysv-install enable target
Matched Content
 
Tweet