Install and Configure iSCSI Target Server on CentOS 7

CentOS 7 is a great operating system for server. Today we will learn how to install and configure CentOS 7 as iSCSI Target server. Its pretty simple and straight forward. On this tutorial, I show you step by step to configure the iSCSI Target server. It is recommended to use a fresh CentOS 7 installation. You may want to have a look at my previous post on how to install CentOS 7.

Steps to install and configure iSCSI Target Server on CentOS 7

Step 1. Install iscsi tool

Step 2. Configure iSCSI Target

First, we need to create a special directory to store the iSCSI disks.

Now we need to perform some administrative tasks using admin console. Follow these steps to create 10 Gigabyte iSCSI disk

#enter the admin console
[root@localhost ~]# targetcli
targetcli shell version 2.1.fb41
Copyright 2011-2013 by Datera, Inc and others.
For help on commands, type ‘help’.

cd backstores/fileio

#create a disk image named disk01 on /mnt/iscsi_disks/disk01.img with 10G size
/backstores/fileio> create disk01 /mnt/iscsi_disks/disk01.img 10G
Created fileio disk01 with size 10737418240
cd /iscsi

#create a target
/iscsi> create iqn.2017-05.gamblisfx.com:storage.target00
Created target iqn.2017-05.gamblisfx.com:storage.target00.
Created TPG 1.
Global pref auto_add_default_portal=true
Created default portal listening on all IPs (0.0.0.0), port 3260.

#Set LUNS
/iscsi> cd iqn.2017-05.gamblisfx.com:storage.target00/tpg1/luns
/iscsi/iqn.20…t00/tpg1/luns> cd ../acls

#Set ACL (This is required in order to permit the initiator to connect to this Target server)
/iscsi/iqn.20…t00/tpg1/acls> create iqn.2017-05.gamblisfx.com:www.gamblisfx.com
Created Node ACL for iqn.2017-05.gamblisfx.com:www.gamblisfx.com

/iscsi/iqn.20…t00/tpg1/acls> cd iqn.2017-05.gamblisfx.com:www.gamblisfx.com

#Set User ID and password for authentication
/iscsi/iqn.20…gamblisfx.com> set auth userid=root
Parameter userid is now ‘root’.
/iscsi/iqn.20…gamblisfx.com> set auth password=12345678
Parameter password is now ‘12345678’.

#Exit from the admin console
/iscsi/iqn.20…gamblisfx.com> exit
Global pref auto_save_on_exit=true
Last 10 configs saved in /etc/target/backup.
Configuration saved to /etc/target/saveconfig.json

Now check if the target enters the listening mode. Use this command to check

[root@localhost ~]# ss -napt | grep 3260
LISTEN 0 256 *:3260

Now enable the target

[root@localhost ~]# systemctl enable target
Created symlink from /etc/systemd/system/multi-user.target.wants/target.service to /usr/lib/systemd/system/target.service.

Now configure the firewall

[root@localhost ~]# firewall-cmd –add-service=iscsi-target –permanent
success
[root@localhost ~]# firewall-cmd –reload
success

Done. At this point our iSCSI target server on CentOS 7 is well configured. Now we can connect our iSCSI initiator to use this iSCSI target server. For example, you can read my previous post how to connect to iSCSI target server from an Fedora 26 box.

Ariel

Leave a Reply

Your email address will not be published. Required fields are marked *