ISCSI. AlmaLinux 8. ISCSI-Initiator: различия между версиями

Материал из Wiki
Перейти к навигации Перейти к поиску
 
(не показаны 3 промежуточные версии этого же участника)
Строка 8: Строка 8:


<code>dnf -y install iscsi-initiator-utils</code>
<code>dnf -y install iscsi-initiator-utils</code>
Initiator name (IMPORTANT! like a unique hostname of this host for iscsi environment)
<code>nano /etc/iscsi/initiatorname.iscsi</code>
     InitiatorName=iqn.2023-01.alef:al8-test01
Timeout for iscsi-target reconnect (in seconds)
<code>nano /etc/iscsi/iscsid.conf</code>
...
node.session.timeo.replacement_timeout = 86400
...


=== Automatic connect to each server with iscsi-target ===
=== Automatic connect to each server with iscsi-target ===
Строка 44: Строка 55:


=== Automatic connect to ONE server with iscsi-target ===
=== Automatic connect to ONE server with iscsi-target ===
<blockquote>Use it when you have '''only ONE server with iscsi-target'''</blockquote>Target path
<blockquote>Use it when you have '''only ONE server with iscsi-target'''</blockquote>Login and password for target (CHAP only)    
 
<code>nano /etc/iscsi/initiatorname.iscsi</code>
     InitiatorName=iqn.2023-01.alef:vmail
Login and password for target (CHAP only)    


<code>nano /etc/iscsi/iscsid.conf</code>
<code>nano /etc/iscsi/iscsid.conf</code>
Строка 74: Строка 81:
Login to specific targets
Login to specific targets


<code>iscsiadm -m node --login --targetname iqn.2023-01.alef:vmail.zfs -p 192.168.199.250,3260</code>    
<code>iscsiadm -m node --login --targetname iqn.2023-01.alef:vmail.zfs -p 192.168.199.250,3260</code>


Show connected session info
Show connected session info
Строка 185: Строка 192:
      ...
      ...
Success!
Success!
= Errors =
=== RO on the iSCSI device ===
==== Error ====
After some time and, apparently, after some problems with network, we have RO on the iSCSI device, connected to our client:
/dev/sdb1 on /home/mail type ext4 ('''ro''',relatime,stripe=256,_netdev)
Logs:
<code>nano /var/log/messages</code><syntaxhighlight lang="bash">
[9610346.408763] sd 7:0:0:0: rejecting I/O to offline device
[9610346.408772] JBD2: Error -5 detected when updating journal superblock for sdc1-8.
[9610903.229966] audit: type=1400 audit(1573412971.694:10974): apparmor="DENIED" operation="mount" info="failed flags match" error=-13 profile="lxc-102_</var/lib/lxc>" name="/" pid=25409 comm="(ionclean)" flags="rw, rslave"
[9610928.726331] audit: type=1400 audit(1573412997.190:10975): apparmor="DENIED" operation="mount" info="failed flags match" error=-13 profile="lxc-103_</var/lib/lxc>" name="/" pid=25720 comm="(ionclean)" flags="rw, rslave"
...
[9634328.830830] audit: type=1400 audit(1573436397.189:11001): apparmor="DENIED" operation="mount" info="failed flags match" error=-13 profile="lxc-103_</var/lib/lxc>" name="/" pid=5088 comm="(ionclean)" flags="rw, rslave"
[9635534.626294] EXT4-fs error (device sdc1): ext4_journal_check_start:61: Detected aborted journal
[9635534.626305] EXT4-fs (sdc1): Remounting filesystem read-only
</syntaxhighlight>
==== ???Solution??? ====
<code>nano /etc/iscsi/iscsid.conf</code>
...
node.session.timeo.replacement_timeout = 86400
...
Restart iscsi service
<code>service iscsid restart</code>
Unmount device
<code>umount /var/vmail</code>
Logout target
<code>iscsiadm --mode node --targetname iqn.2023-01.alef:vmail --portal 192.168.199.250 -u</code>
    ...
    Logging out of session [sid: 1, target: iqn.2023-01.alef:vmail, portal: 192.168.199.250,3260]
    Logout of [sid: 1, target: iqn.2023-01.alef:vmail, portal: 192.168.199.250,3260] successful.
    ...
Delete connection
<code>iscsiadm --mode node --targetname iqn.2023-01.alef:vmail --portal 192.168.199.250 -o delete</code>
Login to target again
<code>iscsiadm -m node --login --targetname iqn.2023-01.alef:vmail.zfs -p 192.168.199.250,3260</code>
[[Категория:ISCSI]]
[[Категория:ISCSI]]
[[Категория:AlmaLinux 8]]
[[Категория:AlmaLinux 8]]

Текущая версия на 08:34, 27 октября 2023

Links

https://computingforgeeks.com/how-to-configure-iscsi-initiator-on-centos-rhel/

Configuring

Connect to target and mount a device

Install

dnf -y install iscsi-initiator-utils

Initiator name (IMPORTANT! like a unique hostname of this host for iscsi environment)

nano /etc/iscsi/initiatorname.iscsi

    InitiatorName=iqn.2023-01.alef:al8-test01

Timeout for iscsi-target reconnect (in seconds)

nano /etc/iscsi/iscsid.conf

...
node.session.timeo.replacement_timeout = 86400
...

Automatic connect to each server with iscsi-target

Use it when you have several servers with iscsi-target

iscsiadm -m discovery -t st -p 192.168.199.187

    ...
    192.168.199.187:3260,1 iqn.2023-03.nas-test:esxi-v1
    192.168.199.187:3260,1 iqn.2023-03.nas-test:pve-v1
    192.168.199.187:3260,1 iqn.2023-03.nas-test:vmail
    ...

iscsiadm -m node --targetname "iqn.2023-03.nas-test:pve-v1" --portal "192.168.199.187:3260" --op=update --name node.session.auth.authmethod --value=CHAP

iscsiadm -m node --targetname "iqn.2023-03.nas-test:pve-v1" --portal "192.168.199.187:3260" --op=update --name node.session.auth.chap_algs --value=SHA3-256,SHA256,SHA1,MD5

iscsiadm -m node --targetname "iqn.2023-03.nas-test:pve-v1" --portal "192.168.199.187:3260" --op=update --name node.session.auth.username --value=pve

iscsiadm -m node --targetname "iqn.2023-03.nas-test:pve-v1" --portal "192.168.199.187:3260" --op=update --name node.session.auth.password --value=PassWord#1

iscsiadm -m node --targetname "iqn.2023-03.nas-test:pve-v1" --portal "192.168.199.187:3260" --op=update --name node.startup --value=automatic

iscsiadm -m node --targetname "iqn.2023-03.nas-test:pve-v1" --portal "192.168.199.187:3260" --login

Now you can see above settings in the separated config file for each target:

/etc/iscsi/nodes/iqn.2023-03.nas-test\:pve-v1/192.168.199.187\,3260\,1/default

This settings will remain after reboot.

reboot

Check if iscsi disk is UP. Show connected block device.

lsblk

    ...
    sdb                       8:16   0  100G  0 disk
    ...

Automatic connect to ONE server with iscsi-target

Use it when you have only ONE server with iscsi-target

Login and password for target (CHAP only)    

nano /etc/iscsi/iscsid.conf

...
node.session.auth.username = vmail
node.session.auth.password = PassWord
...

Discovery target (target discovery auth disabled)

iscsiadm -m discovery -t sendtargets -p 192.168.199.250

    ...
    192.168.199.250:3260,1 iqn.2023-01.alef:vmail
    ...

Target info

iscsiadm -m node -o show

Login to ALL targets

iscsiadm -m node --login

    ...
    Logging in to [iface: default, target: iqn.2023-01.alef:vmail, portal: 192.168.199.250,3260]
    Login to [iface: default, target: iqn.2023-01.alef:vmail, portal: 192.168.199.250,3260] successful.
    ...

Login to specific targets

iscsiadm -m node --login --targetname iqn.2023-01.alef:vmail.zfs -p 192.168.199.250,3260

Show connected session info

iscsiadm -m session -o show

    ...
    tcp: [6] 192.168.199.250:3260,1 iqn.2023-01.alef:vmail (non-flash)
    ...

Show connected block device

lsblk

    ...
    sdb                       8:16   0  100G  0 disk
    ...

Create and mount partition

Create partition

fdisk /dev/sdb

    n - Next - Next...

Create FS

mkfs.ext4 /dev/sdb1

Getting partition UUID

blkid

    ...
    /dev/sdb1: UUID="d13097d0-1b54-47b0-b504-ffc56d9bceff" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="797c5bc8-01"
    ...

Auto mount after OS boot

mkdir /var/vmail

nano /etc/fstab

...
# iscsi vmail
UUID="d13097d0-1b54-47b0-b504-ffc56d9bceff" /var/vmail ext4 _netdev 0 0
...

reboot

df -h

    ...
    /dev/sdb1                         98G  4.1G   89G   5% /var/vmail
    ...

Unmount and disconnect a target

Unmount device

umount /var/vmail

Logout target

iscsiadm --mode node --targetname iqn.2023-01.alef:vmail --portal 192.168.199.250 -u

   ...
   Logging out of session [sid: 1, target: iqn.2023-01.alef:vmail, portal: 192.168.199.250,3260]
   Logout of [sid: 1, target: iqn.2023-01.alef:vmail, portal: 192.168.199.250,3260] successful.
   ...

Delete connection

iscsiadm --mode node --targetname iqn.2023-01.alef:vmail --portal 192.168.199.250 -o delete

Increase a size of the an extent (block device)

Server ISCSI-target

Increase size of the extent

For example, on Nas4free you just have to type bigger size of the file-extent instead of old size of the file-extent in the web-interface and restart ISCSI-target service

Client ISCSI-initiator

Unmount device (don't logout from target, otherwise you wil not be able to work with sdb - it will disappear)

umount /dev/sdb1

Run parted util

parted

Select device

> select /dev/sdb

Get device full size (it will be bigger than actual size)

> print

    ...
    Disk /dev/sdb: 129GB
    ...

Increaze size to full disk size

> resizepart 1 129GB

Exit

> quit

Increase FS size

resize2fs /dev/sdb1

Mount device

mount /dev/sdb1

Check new size

df -h

    ...
    /dev/sdb1                        118G  4.1G  108G   4% /var/vmail
    ...

Success!

Errors

RO on the iSCSI device

Error

After some time and, apparently, after some problems with network, we have RO on the iSCSI device, connected to our client:

/dev/sdb1 on /home/mail type ext4 (ro,relatime,stripe=256,_netdev)

Logs:

nano /var/log/messages

[9610346.408763] sd 7:0:0:0: rejecting I/O to offline device
[9610346.408772] JBD2: Error -5 detected when updating journal superblock for sdc1-8.
[9610903.229966] audit: type=1400 audit(1573412971.694:10974): apparmor="DENIED" operation="mount" info="failed flags match" error=-13 profile="lxc-102_</var/lib/lxc>" name="/" pid=25409 comm="(ionclean)" flags="rw, rslave"
[9610928.726331] audit: type=1400 audit(1573412997.190:10975): apparmor="DENIED" operation="mount" info="failed flags match" error=-13 profile="lxc-103_</var/lib/lxc>" name="/" pid=25720 comm="(ionclean)" flags="rw, rslave"
...
[9634328.830830] audit: type=1400 audit(1573436397.189:11001): apparmor="DENIED" operation="mount" info="failed flags match" error=-13 profile="lxc-103_</var/lib/lxc>" name="/" pid=5088 comm="(ionclean)" flags="rw, rslave"
[9635534.626294] EXT4-fs error (device sdc1): ext4_journal_check_start:61: Detected aborted journal
[9635534.626305] EXT4-fs (sdc1): Remounting filesystem read-only

???Solution???

nano /etc/iscsi/iscsid.conf

...
node.session.timeo.replacement_timeout = 86400
...

Restart iscsi service

service iscsid restart

Unmount device

umount /var/vmail

Logout target

iscsiadm --mode node --targetname iqn.2023-01.alef:vmail --portal 192.168.199.250 -u

   ...
   Logging out of session [sid: 1, target: iqn.2023-01.alef:vmail, portal: 192.168.199.250,3260]
   Logout of [sid: 1, target: iqn.2023-01.alef:vmail, portal: 192.168.199.250,3260] successful.
   ...

Delete connection

iscsiadm --mode node --targetname iqn.2023-01.alef:vmail --portal 192.168.199.250 -o delete

Login to target again

iscsiadm -m node --login --targetname iqn.2023-01.alef:vmail.zfs -p 192.168.199.250,3260