Home / How To / How to install an iSCSI storage server on Ubuntu 20.04 LTS

How to install an iSCSI storage server on Ubuntu 20.04 LTS



iSCSI stands for Internet Small Computer System Interface is a Storage Area Network protocol that can be used to share block devices such as HDD / SSD partitions or LVM partitions or block files on the network. iSCSI operates in a client server model and relies on TCP / IP networks to send SCSI commands between the initiator client and the target. iSCSI Target is a service on iSCSI server that provides access to shared storage and iSCSI Initiator is an iSCSI client that connects to the target and accesses the shared storage.

In this tutorial we will explain how to set iSCSI targets and the iSCSI initiator. on Ubuntu 20.04 server.

Requirements

  • A system running Ubuntu 20.04 for iSCSI targets with 1 GB external hard drive.
  • A system running new Ubuntu 20.04 for iSCSI initiator.
  • A static IP address 192.168.1.10 is configured on iSCSI target and 192.168.1.20 is configured on iSCSI initiator.
  • A root password is configured on both servers.

Updating the system

Before starting, it is a good idea to update your system with the latest package. You can update them with the following command:

  apt-get update -y 
apt-get upgrade -y

When all packages have been updated, restart the system to apply the changes.

Installing the iSCSI Target

By default, the iSCSI Target package is available in the standard Ubuntu 20.04 repository. You can install it by running the following command on the iSCSI Target server:

  apt-get install tgt -y 

After installing iSCSI Target, verify the server status with the following command:

  systemctl status tgt 

You should get the following output:

? tgt.service - (i) SCSI target demon
     Loaded: loaded (/lib/systemd/system/tgt.service; enabled; provider setting: enabled)
     Active: active (running) since Sat 2020-07-11 07:13:04 UTC; 23rd century ago
       Document: man: tgtd (8)
   Main PID: 7770 (tgtd)
     Status: "Start event loop ..."
      Tasks: 1
     Memory: 1.1M
     CGroup: /system.slice/tgt.service
             ?? 7770 / usr / sbin / tgtd -f

11 Jul 07:13:04 ubuntu2004 systemd [1]: Start (i) SCSI target daemon ...
11 Jul 07:13:04 ubuntu2004 tgtd [7770]: tgtd: iser_ib_init (3431) Unable to initialize RDMA; load core modules?
11 Jul 07:13:04 ubuntu2004 tgtd [7770]: tgtd: work_timer_start (146) use timer_fd-based scheduler
11 Jul 07:13:04 ubuntu2004 tgtd [7770]: tgtd: bs_init (387) use signalfd message
11 July 07:13:04 ubuntu2004 systemd [1]: Started (i) SCSI target daemon.

Right now iSCSI Target is installed on your server, you can now proceed to the next step.

Configuring the iSCSI Target

First you need to create a Logical Unit Number (LUN) on your iSCSI server. LUN is a backend storage device that is part of a physical SCSI device. All LUN cards mapped to the iSCSI target are virtually connected to the client's operating system. Therefore, Initiators can create and manage file systems on iSCSI LUNs.

You can configure it by creating a new configuration file:

  nano / etc / tgt / conf. d / iscsi.conf 

Add the following lines:

 
     backing-store / dev / sdb
     initiator address 192.168.1.20
    incoming user iscsi user password
     outgoing users iscsi-target secretpass

Save and close the file when done.

Where:

  • The first line defines the name of LUN.
  • The second line defines the location and name of the storage device on the iSCSI Target server.
  • The third line defines the IP address of the iSCSI initiator.
  • The fourth line defines the incoming username / password.
  • The fifth line defines the username / password that the target will give the initiator to allow mutual CHAP authentication to take place.

Then restart the iSCSI service to apply the changes:

  systemctl restart tgt 

Next, verify the iSCSI Target server with the following command:

  tgtadm - fashion goal - show 

You should get the following output:

 Goal 1: iqn.2020-07.example.com:lun1
    System information:
        Driver: iscsi
        Condition: ready
    I_T nexus info:
    LUN information:
        LUN: 0
            Type: control unit
            SCSI ID: IET 00010000
            SCSI SN: beaf10
            Size: 0 MB, Block size: 1
            Online: Yes
            Removable media: No.
            Prevent removal: No.
            Readonly: No.
            SWP: No.
            Thinning: No.
            Backup type: null
            Back up the store's path: None
            Backing store flags:
    Account information:
        iSCSI helpful
        iscsi target (outgoing)
    ACL information:
        192.168.1.10

At this time, the iSCSI destination server is installed and configured. Now you can move on to the next step.

Installing and Configuring the iSCSI Initiator

Next, go to the iSCSI Initiator machine and install the iSCSI Initiator package with the following command:

  apt-get install open-iscsi -y 

When the installation is complete, discover iSCSI target server to find out the shared targets with the following command:

  iscsiadm -m discovery -t st -p 192.168.1.10 

You should see the following output:

 192.168.1.10:3260,1 iqn.2020-07.example.com:lun1

Next you need to define the name of the LUN in the initiator name.iscsi file:

  nano /etc/iscsi/initiatorname.iscsi Chapter19659011 ?? Add your iSCSI Target LUN name as shown below: 

 InitiatorName = iqn.2020-07.example.com: lun1

Save and close the file when done.

Next, you must define the CHAP information that you have configured on the iSCSI target to access the iSCSI target from the iSCSI initiator. The node configuration file is located in the directory & # 39; / etc / iscsi / nodes / & # 39; and will have one directory per LUN available.

You can define it by editing the following file:

  nano / etc / iscsi / nodes / iqn.2020-07.example.com : lun1 / 192.168.1.10 , 3260 , 1 / default 

Add / change the following lines:

 node.session.auth.authmethod = CHAP
node.session.auth.username = iscsi-user
node.session.auth.password = password
node.session.auth.username_in = iscsi-target
node.session.auth.password_in = secretpass
node.startup = automatic

Save and close the file and then restart the iSCSI initiator service with the following command:

  systemctl restart open-iscsi iscsid 

You can also verify the status of the service with the following command:

  systemctl status open-iscsi [19659011] You should get the following output: 

? open-iscsi.service - Log in to standard iSCSI destinations
     Loaded: loaded (/lib/systemd/system/open-iscsi.service; enabled; provider setting: enabled)
     Active: active (closed) since Sat 2020-07-11 07:24:19 UTC; Dozens ago
       Document: man: iscsiadm (8)
             male: iscsid (8)
    Process: 3861 ExecStart = / sbin / iscsiadm -m-node - loginall = automatic (code = completed, status = 0 / SUCCESS)
    Process: 3867 ExecStart = / lib / open-iscsi / enable-storage.sh (code = completed, status = 0 / SUCCESS)
   Main PID: 3867 (code = completed, status = 0 / SUCCESS)

11 Jul 07:24:19 initiator systemd [1]: Start login to standard iSCSI target ...
11 Jul 07:24:19 initiator iscsiadm [3861]: Log in to [iface: default, target: iqn.2020-07.example.com:lun1, portal: 104.245.33.142,3260] (m>
11 Jul 07:24:19 initiator iscsiadm [3861]: Log in to [iface: default, target: iqn.2020-07.example.com:lun1, portal: 104.245.33.142,3260] success>
11 July 07:24:19 initiator systemd [1]: Completed login to standard iSCSI target.

You can also verify the iSCSI connection with the following command:

  iscsiadm -m session -o show 

You should get the following output:

 tcp: [2] 192.168.1.10:3260,1 iqn. 2020-07.example.com:lun1 (non-flash)

You can also verify the storage device shared from the iSCSI target with the following command:

  lsblk 

You should see the shared device sdb in the following output:

 NAME MAY: MY RM SIZE RO TYPE MOUNTING POINT
sda 8: 0 0 80G 0-disk
?? sda1 8: 1 0 80G 0 del /
sdb 8:16 0 1000M 0 disk

Creating a file system on a shared device

To use the shared device on iSCSI Initiator, you must create a file system on the shared device (sdb) and mount it to make this device usable. [19659022] First create a file system on the shared drive (sdb) with the following command:

  fdisk / dev / sdb 

Answer all the questions shown below to create a file system:

 Welcome to fdisk (util-linux 2.34).
Changes only remain in memory until you decide to write them.
Be careful before typing the write command.

The drive does not contain a recognized partition table.
Created a new DOS sign with the disk identifier 0x9743ddcf.

Command (m for help): n
partition
   p primary (0 primary, 0 extended, 4 free)
   e extended (container for logical partitions)
Select (default p):

Use standard answers p.
Partition number (1-4, standard 1):
First sector (2048-2047999, standard 2048):
Last sector, +/- sectors or +/- size {K, M, G, T, P} (2048-2047999, standard 2047999):

Created a new partition 1 of the type & # 39; Linux & # 39; and in size 999 MiB.

Command (m for help): w
The partition table has changed.
Call ioctl () to read the partition table.
Synchronize discs.

Then format the partition with the following command:

  mkfs.ext4 / dev / sdb1 

You should get the following output:

 mke2fs 1.45.5 (07-Jan-2020)
Create file system with 255744 4k blocks and 64000 inodes
File system UUID: e7f06605-a0f5-41e1-b1b2-e85bd7a2d6a3
Superblock backups stored on blocks:
32768, 98304, 163840, 229376

Assign group tables: done
Writing input tables: done
Create journal (4096 blocks): ready
Writing superblock and file system accounting information: done

Then mount the partition in the directory / mnt with the following command:

  mount / dev / sdb1 / mnt 

You can now verify the mounted partition with the following command:

  df -h [19659011] You should get the following output: 

 File system size Used Use% Mounted on
udev 981M 0 981M 0% / dev
tmpfs 199M 588K 199M 1% / run
/ dev / sda1 79G 1.8G 74G 3% /
tmpfs 994M 0 994M 0% / dev / shm
tmpfs 5.0M 0 5.0M 0% / run / lock
tmpfs 994M 0 994M 0% / sys / fs / cgroup
tmpfs 199M 0 199M 0% / run / user / 0
/ dev / sdb1 968M 2.5M 899M 1% / mnt

Conclusion

In the guide above, you learned how to set up iSCSI targets and initiators on the Ubuntu 20.04 server. You will also learn how to share a device on the Target server and access it from the promoter. Feel free to ask me if you have any questions.


Source link