12 C
Texas

How To Configure iSCSI Target and Initiator on CentOS 8 /RHEL 8

In this tutorial, we are going to configure iSCSI Target & Initiator on CentOS 8 / RHEL 8 using single server as Target & Initiator as shown in figure.

Step 1: Update your System

Type this command to update your system.

sudo dnf update

Step 2: SELinux is in Enforcing Mode

Make sure your SELinux status is working.

- Advertisement -
getenforce

As it will cover configuration of SELinux, make sure it is running in enforcing mode.

Step 3: Install Targetcli on CentOS / RHEL 8

The package for iSCSI Target is available as targetcli on your CentOS / RHEL 8 default AppStrean repositories. You can isnstall it by runnign following command.

sudo dnf -y install targetcli

Step 4: Check available space on your system

Before proceeding further make sure you’ve enough space available for allocation. It is recommended to set a different partition for easier way to manage without interfering with the core CentOS files and system.

df -hT

It would be more easy if you’ve a secondary disk on the server so use it if you’ve.

Step 5: Configure iSCSI Target on CentOS / RHEL 8.

Create a directory in your configured disks e.g; in /var/ or a mount point for your secondary disk, or a raid device.

sudo mkdir /var/targetdisk01

Now move towards to create our targets through targetcli admin console.

sudo su -
targetcli

List its contents to look over.

ls

After listing you will see that everything is empty. You will notice that the first thing in the content is the back-stores.

What are Backstores?

Backstores are for the purpose of providing different ways of keeping data locally that can be later exported or made available to an external system such as an initiator. The available options for backstores are block, fileio,pscsi, and ramdisk.

Block backstore can be a Linux block device like hard drive. If you’ve disk in your target you can use this option. Fileio refered to a normal file on the file system that has been created with a predefined size. We will use this option in our set up. Genearally, a block backstore performs better than a single file.

Create a fileio backstore of 5GB.

Change path to backstores/fileio while on the targetcli console and create the backstore.

cd backstores/fileio

Make sure it is created by listing the content.

ls

Create the iSCSI Target

Move to the iSCSI path in your server for creating the iSCSI Target.

cd /iscsi

As we are now inside iscsi path so it is possible to create the iscsi target with a name. The naming convention is standard and be like this.

[ iqn.(year)-(month).(reverse of domain name):(Your favourite name) ].

Our domain is osradar.com, the reverse of it will be the com.osradar. You can select your desired domain according to this method. So, let’s create our first target.

create iqn.2019.11.osradar.com:iSCSITarget1

Have a look at the changes by typing ls command.

ls

Create a LUN

LUN is a logical unit of storage. A target can offer one or more LUNs to the iSCSI clients, who initiates a connection with the iSCSI server. Navigate to the option target portal group (TPG) we created earlier in the previous command. Notice “Created TPG 1” from above.

cd iqn.2019-11.osradar.com:target01/tpg1/luns

Now create the LUN from the targetdisk1. Use your selected disk.

create /backstores/fileio/targetdisk1

List content to verify.

ls

Configur Access Control List (ACL)

ACL is used to connect only known initiators to our Target. Go to file /etc/iscsi/iniatorname.iscsi file on the client/initiator and check the name of initiator. You can use your own according to your requirements.

sudo vi /etc/iscsi/initiatorname.iscsi

While staying on the same path as above navigate to acls

cd acls

Now run the following command with the iqn of the initiator in the acls path.

create iqn.2019-11.com.osradar:initiator1

Set up Credential details

Set up username and password to authenticate the initiator while it sends a request to the target.

Make sure your settings are properly done by navigating to /iscsi and then save it by exiting.

Enable the target and allow firewall rules.

Step 6: Configure iSCSI Initiator

We have all done except configuring our initiator. Follow our following tutorial to learn configuring iSCSI initiator.

How To Configure iSCSI Initiator on CentOS / RHEL 8.

Congratulations! You’ve all done if have any queries regarding this tutorial leave a comment.

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article