Iscsi: Difference between revisions

From Halfface
Jump to navigation Jump to search
 
Line 36: Line 36:
  node.session.auth.username = username
  node.session.auth.username = username
  node.session.auth.password = password
  node.session.auth.password = password
Start iscsid service.
==Start iscsid service.==
  systemctl enable iscsid.service
  systemctl enable iscsid.service
  systemctl restart iscsid.service
  systemctl restart iscsid.service
Discover target
==Discover target==
  iscsiadm -m discovery -t sendtargets -p 10.111.222.1
  iscsiadm -m discovery -t sendtargets -p 10.111.222.1
  [ 1542.659413] Loading iSCSI transport class v2.0-870.
  [ 1542.659413] Loading iSCSI transport class v2.0-870.
  [ 1542.679005] iscsi: registered transport (tcp)
  [ 1542.679005] iscsi: registered transport (tcp)
  10.0.0.30:3260,1 iqn.2019-11.world.srv:dlp.target01
  10.0.0.30:3260,1 iqn.2019-11.world.srv:dlp.target01
Confirm status after discovery
==Confirm status after discovery==
  [root@node01 ~]# iscsiadm -m node -o show
  [root@node01 ~]# iscsiadm -m node -o show
  # BEGIN RECORD 2.0-876
  # BEGIN RECORD 2.0-876
Line 56: Line 56:
  node.conn[0].iscsi.OFMarker = No
  node.conn[0].iscsi.OFMarker = No
  # END RECORD
  # END RECORD
Login to the target
==Login to the target==
  iscsiadm -m node --login
  iscsiadm -m node --login
  Logging in to [iface: default, target: iqn.2019-11.world.srv:dlp.target01, portal: 10.0.0.30,3260] (multiple)
  Logging in to [iface: default, target: iqn.2019-11.world.srv:dlp.target01, portal: 10.0.0.30,3260] (multiple)
  Login to [iface: default, target: iqn.2019-11.world.srv:dlp.target01, portal: 10.0.0.30,3260] successful.
  Login to [iface: default, target: iqn.2019-11.world.srv:dlp.target01, portal: 10.0.0.30,3260] successful.
Confirm the established session
==Confirm the established session==
  iscsiadm -m session -o show
  iscsiadm -m session -o show
  tcp: [1] 10.0.0.30:3260,1 iqn.2019-11.world.srv:dlp.target01 (non-flash)
  tcp: [1] 10.0.0.30:3260,1 iqn.2019-11.world.srv:dlp.target01 (non-flash)
Confirm the partitions
Confirm the partitions
  lsblk
  lsblk
Format and mount disk
==Format and mount disk==
  gdisk /dev/sda
  gdisk /dev/sda
  mount /dev/sda1 /mnt/
  mount /dev/sda1 /mnt/
# logout from all sessions.
==logout from all sessions.==
iscsiadm -m node -u
iscsiadm -m node -u

Latest revision as of 08:25, 27 March 2022

Configure Storage Server with iSCSI.

Storage server with iSCSI on network is called iSCSI Target.
Client Host that connects to iSCSI Target is called iSCSI Initiator.

Install target

dnf -y install scsi-target-utils

Create a disk image

mkdir /ssd/iscsi
dd if=/dev/zero of=/ssd/iscsi/target001.img count=0 bs=1 seek=10G
vim /etc/tgt/conf.d/target01.conf
<target iqn.2022-03.se.halfface.iscsi:target001>
    # provided devicce as a iSCSI target
    backing-store /ssd/iscsi/target001.img
    # iSCSI Initiator's IQN you allow to connect. Or set nothing to allow all.
    initiator-name iqn.2022-03.se.halfface.iscsi:node01.initiator01
#    initiator-address 10.111.222.13
    # authentication info ( set anyone you like for "username", "password" )
    incominguser username password
</target> 

If selinux.

chcon -R -t tgtd_var_lib_t /ssd/iscsi
semanage fcontext -a -t tgtd_var_lib_t /ssd/iscsi

Open firewall

firewall-cmd --add-service=iscsi-target --permanent
firewall-cmd --reload

Start tgtd

systemctl enable --now tgtd

show status

tgtadm --mode target --op show

Install initiator

dnf -y install iscsi-initiator-utils
vim /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2022-03.se.halfface.iscsi:node01.initiator01
vim /etc/iscsi/iscsid.conf
node.session.auth.authmethod = CHAP
node.session.auth.username = username
node.session.auth.password = password

Start iscsid service.

systemctl enable iscsid.service
systemctl restart iscsid.service

Discover target

iscsiadm -m discovery -t sendtargets -p 10.111.222.1
[ 1542.659413] Loading iSCSI transport class v2.0-870.
[ 1542.679005] iscsi: registered transport (tcp)
10.0.0.30:3260,1 iqn.2019-11.world.srv:dlp.target01

Confirm status after discovery

[root@node01 ~]# iscsiadm -m node -o show
# BEGIN RECORD 2.0-876
node.name = iqn.2019-11.world.srv:dlp.target01
node.tpgt = 1
node.startup = automatic
node.leading_login = No
iface.iscsi_ifacename = default
...
node.conn[0].iscsi.IFMarker = No
node.conn[0].iscsi.OFMarker = No
# END RECORD

Login to the target

iscsiadm -m node --login
Logging in to [iface: default, target: iqn.2019-11.world.srv:dlp.target01, portal: 10.0.0.30,3260] (multiple)
Login to [iface: default, target: iqn.2019-11.world.srv:dlp.target01, portal: 10.0.0.30,3260] successful.

Confirm the established session

iscsiadm -m session -o show
tcp: [1] 10.0.0.30:3260,1 iqn.2019-11.world.srv:dlp.target01 (non-flash)

Confirm the partitions

lsblk

Format and mount disk

gdisk /dev/sda
mount /dev/sda1 /mnt/

logout from all sessions.

iscsiadm -m node -u