Configure a iSCSI Target Server using targetcli on Linux

iscsi target server linux, iscsi target server, install targetcli iscsi, configure iscsi target linux, configure iscsi server, iSCSI target setup

Install & Configure a iSCSI Target Server using targetcli on RHEL7

In a SCSI Environment, there are two kind of iSCSI connecting types which are,

1. An iSCSI target which provides some storage space, this would be at server end.
2. An iSCSI initiator who access the provided space from storage at client end. This iSCSI initiator would be at Client end.

Our Scenario:

1. iSCSI Server :
2. iSCSI Client :

At Server End : iSCSI Target Congfiguration

iSCSI target configuration is done through the interactively targetcli command. This command uses a directory tree structures to access the different objects.

To create an iSCSI target server, we need to follow the below steps on the server.


Install the required Packages using YUM
If yum not configured, please go through this link How to Configure Local Yum Server
[root @learnitguide ~]#  yum install -y targetcli
Activate the target service at boot:
[root @learnitguide ~]#  systemctl enable target
Note: This is required to be enabled, otherwise your configuration won’t be read after a reboot!

Execute the targetcli command
[root @learnitguide ~]#  targetcli
Warning: Could not load preferences file /root/.targetcli/prefs.bin.
targetcli shell version 2.1.fb34
Copyright 2011-2013 by Datera, Inc and others.
For help on commands, type 'help'.

Creating Backstores

There is a two main options, fileio and block.

We will go with block backstores,

block backstore that usually provides the best performance. You can use a block device like /dev/sdb or a logical volume previously created.
/> backstores/block/ create mylun /dev/VolGroup00/lvol00
Created block storage object block1 using /dev/VolGroup00/lvol00.

Creating an IQN

/> iscsi/ create
Created target
Created TPG 1.
Global pref auto_add_default_portal=true
Created default portal listening on all IPs (, port 3260.

Now, we can go to the newly created directory.

Three objects have been defined under tpg1:

  1. acls (access control lists: restrict access to resources),
  2. luns (logical unit number),
  3. portals (define ways to reach the exported resources).
/iscsi/iqn.20...ple:t1/tpg1> portals/ create
Using default IP port 3260
Binding to INADDR_ANY (
Created network portal
Finally check the configuration using the command "ls" and quit from the targetcli session.
/iscsi/iqn.20...ple:tgt1/tpg1> exit
Global pref auto_save_on_exit=true
Last 10 configs saved in /etc/target/backup.
Configuration saved to /etc/target/saveconfig.json

Note: The configuration is automatically saved to the /etc/target/saveconfig.json file.

Also, it can be useful to check the ports currently used so we can confirm who accessing it.
[root @learnitguide ~]#  netstat -ant
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0    *               LISTEN
tcp        0      0  *               LISTEN
tcp        0      0  *               LISTEN
tcp        0      0      ESTABLISHED
tcp6       0      0 :::22                   :::*                    LISTEN
tcp6       0      0 ::1:25                  :::*                    LISTEN

Finally, open the 3260 tcp port in the firewall configuration:

[root @learnitguide ~]#  firewall-cmd --permanent --add-port=3260/tcp

Reload the firewall configuration:

[root @learnitguide ~]#  firewall-cmd --reload

That's it, we are done with iSCSI target configuration at server end. Now we need to go to the client and access the lun as mentioned in our previous articles. Click here to see How to Access or Map an iSCSI LUN Volume on Linux Client.

Please follow us to not miss any updates and leave your comment. Thank You. iscsi target server linux, iscsi target server, install iscsi target centos, configure iscsi target linux, configure iscsi target centos, iSCSI target setup, How to set up iSCSI target on Linux, Linux tgtadm Setup iSCSI Target, Configuring iSCSI target, linux iscsi target configuration, Set up an iSCSI Target, linux iscsi target multipath, linux iscsi target vmware, linux iscsi target multiple targets, iscsi target linux redhat 6, centos 7 iscsi target, centos iscsi target, how to configure iscsi target in linux, centos iscsi target, iscsi linux tutorial, rhel 7 iscsi target, targetcli centos, targetcli linux, targetcli iscsi
July 31, 2015

Post a Comment


Contact Form


Email *

Message *

Powered by Blogger.
Javascript DisablePlease Enable Javascript To See All Widget