- A Cloud Guru
Working with iSCSI Target and Initiator to Mount on Clients
Being able to work with iSCSI block storage on servers and clients is becoming a common skill in today's distributed IT organizations. This activity will allow you to get hands on with setting up both an iSCSI initator and target (client and server) in order to mount that block storage on a system. Once you have completed this activity, you will understand how to make iSCSI storage available and then consume it on a system.
Table of Contents
Install the Server and Client iSCSI Utilities
Since we are using the single instance as both server and client (target and initiator in this case), we can install what is needed with:
sudo yum install -y targetcli iscsi-initiator-utils
Create the iSCSI Block Device on the Server
Using the first device on the system of 20gb, you are asked to create a block device that you make available via iSCSI. This will involve the following commands:
[#/] targetcli /> backstores/block/ create test1 /dev/nvme2n1 /> iscsi/ create iqn.2018-11.com.mylabserver:t1 /> cd iscsi/iqn.2018-11.com.mylabserver:t1/tpg1 /> luns/ create /backstores/block/test1 /> acls/ create iqn.2018-11.com.mylabserver:client
Enable and Start the Target iSCSI Service
Easy enough to do, as root:
systemctl enable target systemctl start target
Create the Client Initiator Name
We need to add the client initiator name (which we created in the earlier configration ACL for the target) to the /etc/initiatorname.iscsi file, like so:
Complete the Client 'Initiator' Configuration and Discover (Verify) the Configuration
Within the /etc/iscsi/iscsi.conf file, you will look for, and change, the following values in the file:
node.session.auth.authmethod = CHAP <CHANGE TO> #node.session.auth.authmethod = CHAP
You are COMMENTING OUT the value. You then need to enable and start the service:
systemctl enable iscsi systemctl start iscsi
Discover and verify you can now see the block device:
iscsiadm --mode discovery --type sendtargets --portal [Private IP of Server]
and you should see the target configured.
Restart the iscsi and iscsid services:
systemctl restart iscsi
systemctl restart iscsid
Now make sure you can connect:
iscsiadm --mode node --targetname iqn.2018-11.com.mylabserver:t1 --portal [Private IP of Server] --login
You should now see the SCSI device (like /dev/sda) when executing the 'lsblk' command
What's a lab?
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.