This post will show you How to Install and Configure iSCSI Target Server using targetcli on Linux.
If you are interested in learning, Request you to go through the below recommended tutorial.
DevOps Full Course Tutorial for Beginners - DevOps Free Training Online
Docker Full Course Tutorial for Beginners - Docker Free Training Online
Kubernetes Full Course Tutorial for Beginners - Kubernetes Free Training Online
Ansible Full Course Tutorial for Beginners - Ansible Free Training Online
Openstack Full Course Tutorial for Beginners - Openstack Free Training Online
In a SCSI Environment, there are two kind of iSCSI connecting types which are,Docker Full Course Tutorial for Beginners - Docker Free Training Online
Kubernetes Full Course Tutorial for Beginners - Kubernetes Free Training Online
Ansible Full Course Tutorial for Beginners - Ansible Free Training Online
Openstack Full Course Tutorial for Beginners - Openstack Free Training Online
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 : 192.168.2.1
2. iSCSI Client : 192.168.2.2
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.
Configure iSCSI Target Server using targetcli on Linux
To create an iSCSI target server, we need to follow the below steps on the server.
ALSO WATCH THIS iSCSI CONFIGURATION TUTORIAL VIDEO FREE ON OUR YOUTUBE CHANNEL
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 iqn.2015-07.net.learnitguide:t1
Created target iqn.2015-07.net.learnitguide.
Created TPG 1.
Global pref auto_add_default_portal=true
Created default portal listening on all IPs (0.0.0.0), port 3260.
Now, we can go to the newly created directory.
Three objects have been defined under tpg1:
- acls (access control lists: restrict access to resources),
- luns (logical unit number),
- 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 (0.0.0.0)
Created network portal 0.0.0.0:3260.
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 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:3260 0.0.0.0:* LISTEN
tcp 0 0 192.168.2.1:22 192.168.2.2:33584 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
Success
Reload the firewall configuration:
[root @learnitguide ~]# firewall-cmd --reload
Success
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.
Related Content on Linux might be useful to you to improve your Linux Skills.
How to Configure IP Address on Ubuntu using Netplan
How to Access Linux Server from Windows Remotely
Configure SSH Passwordless Login Authentication (SSH-keygen)
How to Create LVM Partition in Linux – LVM Tutorial
Install & Configure Samba Server on Linux (RHEL7 / CentOS7)
How to Access Linux Server from Windows Remotely
Configure SSH Passwordless Login Authentication (SSH-keygen)
How to Create LVM Partition in Linux – LVM Tutorial
Install & Configure Samba Server on Linux (RHEL7 / CentOS7)
Keep practicing and have fun. Leave your comments if any.
Support Us: Share with your friends and groups.Stay connected with us on social networking sites, Thank you.
0 Comments