Difference between revisions of "CentOS 8.x iSCSI target server setup"

From Notes_Wiki
(Created page with "<yambe:breadcrumb self="iSCSI target server setup">CentOS 8.x iSCSI|iSCSI</yambe:breadcrumb> =CentOS 8.x iSCSI target server setup= To setup CentOS 8.x machine for iSCSI targ...")
 
m
 
Line 1: Line 1:
<yambe:breadcrumb self="iSCSI target server setup">CentOS 8.x iSCSI|iSCSI</yambe:breadcrumb>
[[Main Page|Home]] > [[CentOS]] > [[CentOS 8.x]] > [[CentOS 8.x iSCSI]] > [[CentOS 8.x iSCSI target server setup]]
=CentOS 8.x iSCSI target server setup=


To setup CentOS 8.x machine for iSCSI target use:
To setup CentOS 8.x machine for iSCSI target use:
Line 19: Line 18:
#:</pre>
#:</pre>
#: where primary.iscsi is name of iSCSI backing store file and 800G is its size
#: where primary.iscsi is name of iSCSI backing store file and 800G is its size
# Run '''<tt>targetcli</tt>''' and configure it using:
# Run '''<tt>targetcli</tt>''' and configure it using: <source line lang="shell>
#:<pre>
#Create file to be used as iscsi backstore
#::      #Create file to be used as iscsi backstore
cd /backstores/fileio
#::      cd /backstores/fileio
create primary /backstores/primary.iscsi
#::      create primary /backstores/primary.iscsi
cd ..
#::      cd ..
ls  
#::      ls  
#Note that we can also use block devices using /backstores/block
#::      #Note that we can also use block devices using /backstores/block
 
#::
cd /iscsi
#::      cd /iscsi
#This will create IQN number automatically
#::      #This will create IQN number automatically
#Ideally we should create different iqn numbers for every backstore
#::      #Ideally we should create different iqn numbers for every backstore
#So that there is flexibility on client side.  We can run
#::      #So that there is flexibility on client side.  We can run
#create multiple times to create different iqn numbers.
#::      #create multiple times to create different iqn numbers.
create
#::      create
cd iqn.<press-tab-to-autocomplete>
#::      cd iqn.<press-tab-to-autocomplete>
   
#::   
#Create lun  
#::
cd tpg1/luns
#::      #Create lun  
create /backstores/fileio/primary
#::      cd tpg1/luns
 
#::      create /backstores/fileio/primary
#Allow client IQN numbers without authentication
#::
cd ../acls
#::      #Allow client IQN numbers without authentication
create <client1-iscsi-initiator-name>
#::      cd ../acls
create <client2-iscsi-initiator-name>
#::      create <client1-iscsi-initiator-name>
 
#::      create <client2-iscsi-initiator-name>
#Save and exit
#::
cd /
#::      #Save and exit
saveconfig
#::      cd /
exit
#::      saveconfig
</source>
#::      exit
#:  Client initiator name is located in file '<tt>/etc/iscsi/initiatorname.iscsi</tt>'.  Take only value after 'InitiatorName=' starting with 'iqn.'
#:</pre>
#::  Client initiator name is located in file '<tt>/etc/iscsi/initiatorname.iscsi</tt>'.  Take only value after 'InitiatorName=' starting with 'iqn.'
# Configure service to start on system boot and also start it for current run:
# Configure service to start on system boot and also start it for current run:
#:<pre>
#:<pre>
Line 67: Line 64:




<yambe:breadcrumb self="iSCSI target server setup">CentOS 8.x iSCSI|iSCSI</yambe:breadcrumb>
[[Main Page|Home]] > [[CentOS]] > [[CentOS 8.x]] > [[CentOS 8.x iSCSI]] > [[CentOS 8.x iSCSI target server setup]]

Latest revision as of 17:32, 15 May 2022

Home > CentOS > CentOS 8.x > CentOS 8.x iSCSI > CentOS 8.x iSCSI target server setup

To setup CentOS 8.x machine for iSCSI target use:

  1. Create appropriate file-system and mount it at desired location (eg /backstores) to be used for storing iSCSI disk images (parted, mkfs.ext4, /etc/fstab, mount -a, df -h, etc.)
  2. Install targetcli package using:
    dnf -y install epel-release
    dnf -y install targetcli
  3. Clear existing configuration (if any) using:
    targetcli clearconfig confirm=true
  4. Go to /backstores in OS and create desired backing store using:
    cd /backstores
    qemu-img create -f raw primary.iscsi 800G
    where primary.iscsi is name of iSCSI backing store file and 800G is its size
  5. Run targetcli and configure it using:
    #Create file to be used as iscsi backstore
    cd /backstores/fileio
    create primary /backstores/primary.iscsi
    cd ..
    ls 
    #Note that we can also use block devices using /backstores/block
    
    cd /iscsi
    #This will create IQN number automatically
    #Ideally we should create different iqn numbers for every backstore
    #So that there is flexibility on client side.  We can run
    #create multiple times to create different iqn numbers.
    create
    cd iqn.<press-tab-to-autocomplete>
         
    #Create lun 
    cd tpg1/luns
    create /backstores/fileio/primary
    
    #Allow client IQN numbers without authentication
    cd ../acls
    create <client1-iscsi-initiator-name>
    create <client2-iscsi-initiator-name>
    
    #Save and exit
    cd /
    saveconfig
    exit
    
    Client initiator name is located in file '/etc/iscsi/initiatorname.iscsi'. Take only value after 'InitiatorName=' starting with 'iqn.'
  6. Configure service to start on system boot and also start it for current run:
    systemctl enable target
    systemctl start target
  7. Disable firewall or given exception for port 3260
    systemctl disable firewalld
    systemctl stop firewalld



Home > CentOS > CentOS 8.x > CentOS 8.x iSCSI > CentOS 8.x iSCSI target server setup