Home / How To / How to install iSCSI Storage Server on Ubuntu 18.04 LTS

How to install iSCSI Storage Server on Ubuntu 18.04 LTS



iSCSI stands for (Internet Small Computer System Interface) is a storage area network (SAN) protocol that can be used for online storage management. It is an IP-based storage network standard that provides block-level access to storage devices by carrying SCSI commands over a TCP / IP network.

iSCSI consists of two components iSCSI target and iSCSI initiator. 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 guide we will show you how to configure iSCSI targets and iSCSI initiator on Ubuntu 18.04 server.

Requirements

  • A new Ubuntu 1
    8.04 server for iSCSI target with 2 GB external hard drive.
  • A fresh Ubuntu 18.04 server for iSCSI initiator.
  • A static IP address 192.168.0.103 is configured on iSCSI targets and 192.168.0.102 is configured on iSCSI initiator.
  • A root password is configured on both server.

Getting Started

Before you start, you must update both servers with the latest version. You can update them by running the following command on both $

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

Once both servers are updated, restart them to apply the changes.

Installing iSCSI Target

First, you must install the Target Framework (TGT) package on the iSCSI target server. You can install it with the following command:

  apt-get install tgt -y 

Once TGT is installed, check the status of TGT by running the following command:

  systemctl status tgt 

You should see the following output :

? tgt.service - (i) SCSI target daemon
Loaded: loaded (/lib/systemd/system/tgt.service; enabled; vendor setting: enabled)
Active: active (running) since Fri 2019-11-08 07:40:28 UTC; 27s ago
Document: man: tgtd (8)
Main PID: 2343 (tgtd)
Status: "Start Trade Loop ..."
Tasks: 1
CGroup: /system.slice/tgt.service
?? 2343 / usr / sbin / tgtd -f

Nov 8 07:40:28 ubuntu systemd [1]: Launch (i) SCSI target daemon ...
Nov 8 07:40:28 ubuntu tgtd [2343]: tgtd: iser_ib_init (3431) Could not initialize RDMA; load core modules?
Nov 8 07:40:28 ubuntu tgtd [2343]: tgtd: work_timer_start (146) use timer_fd-based scheduler
Nov 8 07:40:28 ubuntu tgtd [2343]: tgtd: bs_init (387) use signalfd message
Nov 8 07:40:28 ubuntu systemd [1]: Started (i) SCSI target daemon.

Once you have done that, you can move on to the next step.

Configuring iSCSI Target

Next, you must create a Logical Unit Number (LUN) on your iSCSI server. LUN is a backend storage device that the originator will connect to and use later.

You can do this by creating the configuration file in the /etc/tgt/conf.d directory:

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

Add the following lines:

 
# Device provided as an iSCSI target
backing-store / dev / sdb1
initiator address 192.168.0.102
incoming user iscsi user password
outgoing user iscsi-target secretpass

Save and close the file when you are done. Then restart the TGT service to apply the configuration changes:

  systemctl restart tgt 

Here is a brief explanation of each parameter:

target : This is the name of the specific target. [19659002] backing-store : This option specifies the storage disk to be used by the originator.

initiator address : This is the IP address of the initiator. [19659002] incoming user : This is the incoming username / password to secure LUN.

outgoing user : This is the outgoing username / password for reciprocal CHAP authentication.

After restarting the TGT service, check the iSCSI target server with the following command:

  tgtadm - mode target - display 

You should see that the iSCSI target is made available:

 Objective 1: iqn.2019 - 11.example.com:lun1
System information:
Driver: iscsi
Condition: Ready
I_T Nexus Information:
LUN information:
LUN: 0
Type: control unit
SCSI ID: IET 00010000
SCSI SN: affect10
Size: 0 MB, Block size: 1
Online: Yes
Removable media: No.
Prevent removal: No.
Readonly: No.
SWP: No.
Thin processing: No.
Backup type: null
Backing up the store's path: None
Backing store flags:
LUN: 1
Type: disk
SCSI ID: IET 00010001
SCSI SN: affect11
Size: 2146 MB, Block size: 512
Online: Yes
Removable media: No.
Prevent removal: No.
Readonly: No.
SWP: No.
Thin processing: No.
Type of store support: rdwr
Backup layer: / dev / sdb1
Backing store flags:
Account information:
iSCSI helpful
iscsi target (outbound)
ACL information:
192.168.0.102

Installing and Configuring the iSCSI Initiator

Next, you must install the iSCSI Initiator package on the iSCSI Initiator server. You can install it with the following command:

  apt-get install open-iscsi -y 

When the installation is complete, run target detection against our iSCSI target server to find out the shared targets.

  iscsiadm - m discovery -t st -p 192.168.0.103 

You should see the available target in the following output:

 192.168.0.103:3260,1 iqn.2019-11.example.com:lun1

The above command also generates two files with LUN information. You can see them with the following command:

  ls -l /etc/iscsi/nodes/iqn.2019-11.example.com:lun1/192.168.0.103,3260,1/ / etc / iscsi / send_targets / 192.168.0.103,3260 / 

You should see the following files:

 /etc/iscsi/nodes/iqn.2019-11.example.com:lun1/192.168.0.103,3260,1/:
a total of 4
-rw ------- 1 root root 1840 8 Nov 8 13:17 standard

/etc/iscsi/send_targets/192.168.0.103,3260/:
a total of 8
lrwxrwxrwx 1 root root 66 Nov 8 13:17 iqn.2019-11.example.com:lun1,192.168.0.103,3260,1,default -> /etc/iscsi/nodes/iqn.2019-11.example.com: lun1 / 192.168.0.103,3260,1
-rw ------- 1 root root 547 Nov 8 13:17 st_config

Next, you must edit the default file and define the CHAP information that you have configured on the iSCSI target to access the iSCSI target from the iSCSI initiator.

  nano /etc/iscsi/nodes/iqn.2019-11 .example.com : lun1 / 192.168.0.103 , 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 = automatically

Save and close the file when you are done. Then restart the iSCSI initiator service to apply the configuration changes:

  systemctl restart open-iscsi 

You should see the following output:

 * Dismantle iscsi-backed file system [ OK ]
* Disconnect iSCSI target iscsiadm: No matching sessions found
[ OK ]
* Stop iSCSI Initiative Service [ OK ]
* Start the iSCSI initiator service iscsid [ OK ]
* Set iSCSI goals
Login to [iface: default, target: iqn.2019-11.example.com:lun1, portal: 192.168.0.103,3260] (multiple)
Login to [iface: default, target: iqn.2019-11.example.com:lun1, portal: 192.168.0.103,3260] successful.
[ OK ]
* Network File System Installation [ OK ]

You can now check the storage disk shared from the iSCSI target with the following command:

  lsblk 

You should see that the storage disk is now available to the initiator as sdb:

 NAME MAY: MIN RM SIZE RO TYPE MOUNTPOINT
sda 8: 0 0 465.8G 0 disk
?? sda1 8: 1 0 93.1G 0 part /
?? sda2 8: 2 0 1K 0 part
?? sda5 8: 5 0 186.3G 0 part / home
?? sda6 8: 6 0 181.6G 0 part / Data
?? sda7 8: 7 0 4.8G 0 part [SWAP]
sdb 8:16 0 2G 0 disk

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

  tgtadm - mode switch - show - time 1 

You should get the following output:

 Session: 1
Connection: 0
Initiator: iqn.1993-08.org.debian: 01: 2e1e2383de41
IP Address: 192.168.0.102

Next, you must create a file system on the shared device (sdb) and mount it to make this device useful.

First, create a file system on the shared drive (sdb) with the following command: [19659011] fdisk / dev / sdb

You should see the following output:

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

The device does not contain a recognized partition table.
Created a new DOS sign with disk identifier 0x06091fe8.

Command (m for help): n
partition
p primary (0 primary, 0 extended, 4 free)
e extended (logical partition container)
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-4194303, standard 2048):
Last sector, + sectors or + size {K, M, G, T, P} (2048-4194303, standard 4194303):

Created a new partition # 1 of the & # 39; Linux & # 39; and of size 2 GiB.

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

Then format this partition with the following command:

  mkfs.ext4 / dev / sdb1 

Next, mount this partition in the / mnt directory with the following command:

  mount / dev / sdb1 / mnt 

You can now check the mounted device with the following command:

  df -h 

You should see the following output:

 File System Size Used Use% Mounted on
udev 1.9G 4.0K 1.9G 1% / dev
tmpfs 384M 1.2M 383M 1% / run
/ dev / sda1 92G 36G 51G 42% /
none 4.0 K 0 4.0 K 0% / sys / fs / cgroup
no 5.0 M 0 5.0 M 0% / drive / lock
no 1.9G 54M 1.9G 3% / driving / shm
no 100M 48K 100M 1% / run / user
/ dev / sda5 184G 96G 79G 55% / home
/ dev / sda6 179G 32G 138G 19% / Data
/ dev / sdb1 2.0G 3.0M 1.9G 1% / mnt

Congratulations! you have installed the iSCSI target server and connect it from the iSCSI initiator. You can now use the shared iSCSI device as a standard connected disk.


Source link