DOCS/UNIX/RHEL/ISCSI/Config iSCSI Target : Différence entre versions

De MonPtitSite
Sauter à la navigation Sauter à la recherche
Ligne 169 : Ligne 169 :
  
 
- Verify the created block storage.
 
- Verify the created block storage.
 +
 +
<syntaxhighlight lang="shell">
 
/backstores/block> ls
 
/backstores/block> ls
 
o- block .................................................. [Storage Objects: 1]
 
o- block .................................................. [Storage Objects: 1]
Ligne 174 : Ligne 176 :
 
     o- alua ................................................... [ALUA Groups: 1]
 
     o- alua ................................................... [ALUA Groups: 1]
 
       o- default_tg_pt_gp ....................... [ALUA state: Active/optimized]
 
       o- default_tg_pt_gp ....................... [ALUA state: Active/optimized]
<syntaxhighlight lang="shell">
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  

Version du 31 août 2022 à 08:03

Accueil SysAdmin Hobbies                  
QEMU - Configure iSCSI Target on CentOS 9/AlmaLinux 9/RHEL 9

Sites Références

Cet articles est une transposition sous MediaWiki de ces adresses :

iSCSI stands for Internet Small Computer Systems Interface. It is an Internet Protocol that allows multiple servers and users to access network drives remotely over a TCP/IP network by setting up a shared storage network. iSCSI components include the iSCSI target which is the server that stores and allows access to storage and iSCSI initiator which is the hardware installed on a client to send data. A basic Ethernet port or a Host Bus Adapter (HBA) is what is required to connect iSCSI targets and initiators to a network. Both components are identified by a unique name known as iSCSI Qulified Name (iQN).

What is iSCSI Target?

iSCSI target as discussed above is the server that stores the storage and allows access to it. It can be a dedicated physical device on a network or an iSCSI software-configured logical device on a networked storage server. It is the remote storage that appears as a local drive on a host system. The iSCSI protocol then links the host with the storage over IP networks like LAN and WAN or Internet.

This guide shows how to configure an iSCSI Target on CentOS 9|AlmaLinux 9|RHEL 9 systems.

Install iSCSI Target on CentOS 9|AlmaLinux 9|RHEL 9

- Update the system packages.

sudo yum update -y

or

sudo dnf update -y

- Install the targetcli tool

sudo dnf install targetcli

- Start and enable the target service on boot time.

sudo systemctl enable --now target

- Open port 3260 in the firewall.

sudo firewall-cmd --permanent --add-port=3260/tcp
sudo firewall-cmd --reload

- To view the targetcli layout, login to the admin console.

$ sudo targetcli
targetcli shell version 2.1.53
Copyright 2011-2013 by Datera, Inc and others.
For help on commands, type 'help'.

/>

- List using the following command


> ls
o- / ..................................................................... [...]
  o- backstores .......................................................... [...]
  | o- block .............................................. [Storage Objects: 0]
  | o- fileio ............................................. [Storage Objects: 0]
  | o- pscsi .............................................. [Storage Objects: 0]
  | o- ramdisk ............................................ [Storage Objects: 0]
  o- iscsi ........................................................ [Targets: 0]
  o- loopback ..................................................... [Targets: 0]

- Exit the shell using the following command.

/> exit
Global pref auto_save_on_exit=true
Configuration saved to /etc/target/saveconfig.json

Configure iSCSI Target on CentOS 9|AlmaLinux 9|RHEL 9

To configure an iSCSI Target, we will use the following details

  • iSCSI target with a unique iQN.
  • iSCSI Backstore – is a storage object that defines the resources that the backstore uses.
  • Create iSCSI Portal.
  • Setup iSCSI LUN.
  • Creating an iSCSI ACL.
  • Setup CHAP Authentication.

Create an iSCSI target

The target name is in the iQN format. iQN format is as follows iqn.YYYY-MM.reverse.domain.name:OptionalIdentifier. Let’s say I was to name a target with an iQN unique string with the name technixleo and my domain is target.example.com the iqn name will be as iqn.2022-06.com.example.target:technixleo - Login to the admin console of the target CLI shell.

sudo targetcli

- Navigate to the iSCSI directory

/> cd iscsi/

- Create the iSCSI target as shown below.

/iscsi> create iqn.2022-06.com.example.target:technixleo

Created target iqn.2022-06.com.example.target:technixleo.
Created TPG 1.
Global pref auto_add_default_portal=true
Created default portal listening on all IPs (0.0.0.0), port 3260.

- Then verify the created target.

/iscsi> ls

o- iscsi .......................................................... [Targets: 1]
  o- iqn.2022-06.com.example.target:technixleo ....................... [TPGs: 1]
    o- tpg1 ............................................. [no-gen-acls, no-auth]
      o- acls ........................................................ [ACLs: 0]
      o- luns ........................................................ [LUNs: 0]
      o- portals .................................................. [Portals: 1]
        o- 0.0.0.0:3260 ................................................... [OK]

Create iSCSI Backstore

You can create backstore devices of any of the following 4 types

  • fileio backstore for files
  • block backstore for block devices.
  • pscsi backstore for direct pass-through of SCSI commands.
  • ramdisk backstore for a temporary RAM-backed device.

For this guide, I will create one for fileio and block backstores

Create fileio storage object

-Navigate to the fileio on the backstore directory. The backstore is the device where the storage is located.

/> cd /backstores/fileio

- Create a file storage object named disk1 in a directory say /tmp/disk1.img of size 5GB. You can create a different directory to store the disk.

/backstores/fileio> create disk1 /tmp/disk1.img 5G
Created fileio disk1 with size 5368709120

- Verify the created storage object

/backstores/fileio> ls

o- fileio ................................................. [Storage Objects: 1]
  o- disk1 .................... [/tmp/disk1.img (5.0GiB) write-back deactivated]
    o- alua ................................................... [ALUA Groups: 1]
      o- default_tg_pt_gp ....................... [ALUA state: Active/optimized]

Create a block storage object

Block devices include physical devices like HDDs, SSDs, CDs, and DVDs, and logical devices such as software or hardware RAID volumes, or LVM volumes.

- Navigate to the block of the backstores directory

/> cd /backstores/block

- Create a block storage object with the following command. Use a disk that is not in use.

/backstores/block> create name=block1 dev=/dev/vdb
Created block storage object block1 using /dev/vdb.

- Verify the created block storage.

/backstores/block> ls
o- block .................................................. [Storage Objects: 1]
  o- block1 ........................ [/dev/vdb (10.0GiB) write-thru deactivated]
    o- alua ................................................... [ALUA Groups: 1]
      o- default_tg_pt_gp ....................... [ALUA state: Active/optimized]

Creating an iSCSI Portal


Creating an iSCSI LUN


Creating an iSCSI ACL

Setup CHAP for the target