0% found this document useful (0 votes)
66 views8 pages

Setup iSCSI On CentOS7

Download as docx, pdf, or txt
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 8

RC-TOG-03

Setup iSCSI on CentOS 7


Scenario:
Server: 10.1.2.192
Client1: 10.1.2.123 (Windows)
Client2: 10.1.2.107 (CentOS)

Server: 10.1.2.192
#####Attach new disk and create LVM ########
+-------------------------------------------------------------------------------
pvcreate /dev/xvdb

vgcreate VG01 /dev/xvdb

lvcreate -l 100%FREE -n lv01 VG01

mkfs.ext4 /dev/VG01/lv01

-------------------------------------------------------------------------------------------+

### Installing targetcli ####

yum install targetcli -y

#### Configuration ####

[root@saqib-iscsi-test ~]# targetcli


RC-TOG-03

+------------------------------------------------------------------------------------------+
/> cd backstores/block

### Create block storage and mount to LVM #####


+------------------------------------------------------------------------------------------+
# create <Any-drive-Name> <LVM-PATH>

/backstores/block> create iscsi-disk /dev/mapper/VG01/LV01


+------------------------------------------------------------------------------------------+

#### Create TPG (Target Portal Group) was created along with the default portal (a pair
consisting of an IP address and a port which is the way initiators can reach the target) listening
on port 3260 of all IP addresses.

+------------------------------------------------------------------------------------------+
/backstores/block> cd /iscsi

# create iqn.yyyy-mm.<dns-name-in-reverese-order>:<block-name> OR create iqn.yyyy-


mm.<IP-in-reverese-order>:<block-name>

/iscsi> create iqn.2019-01.192.2.1.10:disk2

+------------------------------------------------------------------------------------------+

####If you want to bind your portal to a specific IP (the Target’s main IP, for example), delete
the default portal and create a new one as follows (otherwise, skip the following targetcli
commands. ####3
## OPTIONAL ##
+------------------------------------------------------------------------------------------+
/> cd /iscsi/iqn.2019-01.192.2.1.10:disk2/tpg1/portals/
RC-TOG-03

# delete 0.0.0.0 3260


# create <private-IP-of-Client> 3260

+------------------------------------------------------------------------------------------+

### ACL rule ######


+------------------------------------------------------------------------------------------+
/> cd /iscsi/iqn.2019-01.192.2.1.10:disk2/tpg1/
# Create ACL
/iscsi/iqn.2019-01.192.2.1.10:disk2/tpg1/> acls/ create iqn.2019-01.192.2.1.10:client
+------------------------------------------------------------------------------------------+

### LUN is a logical unit of storage. It is a volume that is accessed as a block device ####

+------------------------------------------------------------------------------------------+
# Create LUN
/> cd /iscsi/iqn.2019-01.192.2.1.10:disk2/tpg1/
/iscsi/iqn.2019-01.192.2.1.10:disk2/tpg1/> luns/ create /backstores/block/iscsi-disk
+------------------------------------------------------------------------------------------+

/iscsi/iqn.2019-01.192.2.1.10:disk2/tpg1/> cd /

/> saveconfig
/> exit

[root@server ~]# systemctl restart target.service


RC-TOG-03

Client1: 10.1.2.123 (Windows)

### It will show you all available targets


RC-TOG-03

## Add ACL rule here which you define in previous steps while configuring server ###

#Connect to Target Now


RC-TOG-03

#Attach storage to Machine

Create New Simple Volume and then click Next Next Next to create Partition
RC-TOG-03

Client2: 10.1.2.107 (CentOS)

[root@vps ~]# yum install iscsi-initiator-utils

[root@vps ~]# iscsiadm -m discovery -t st -p 10.1.2.192


10.1.2.192:3260,1 iqn.2019-01.192.2.1.10:disk2

[root@vps ~]# systemctl start iscsid


[root@vps ~]# systemctl enable iscsid

## Add ACL rule here which you define in previous steps while configuring server ###
[root@vps ~]# vi /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2019-01.192.2.1.10:client

[root@vps ~]# systemctl restart iscsid

[root@vps ~]# iscsiadm -m node -T iqn.2019-01.192.2.1.10:disk2 -p 10.1.2.192 –l


Logging in to [iface: default, target: iqn.2019-01.192.2.1.10:disk2, portal: 10.1.2.192,3260] (multiple)
Login to [iface: default, target: iqn.2019-01.192.2.1.10:disk2, portal: 10.1.2.192,3260] successful.

[root@vps ~]# dmesg | tail


[792198.587554] scsi 4:0:0:0: alua: port group 00 rel port 01
[792198.587712] scsi 4:0:0:0: alua: port group 00 state A non-preferred supports TOlUSNA
[792198.587714] scsi 4:0:0:0: alua: Attached
[792198.587848] scsi 4:0:0:0: Attached scsi generic sg1 type 0
[792198.989419] sd 4:0:0:0: [sda] 4423680 512-byte logical blocks: (2.26 GB/2.10 GiB)
[792198.990600] sd 4:0:0:0: [sda] Write Protect is off
[792198.990604] sd 4:0:0:0: [sda] Mode Sense: 43 00 10 08
RC-TOG-03

[792198.990964] sd 4:0:0:0: [sda] Write cache: enabled, read cache: enabled, supports DPO and FUA
[792199.005153] sda: sda1
[792199.007068] sd 4:0:0:0: [sda] Attached SCSI disk

[root@vps /]# fdisk -l | grep sda


Disk /dev/sda: 2264 MB, 2264924160 bytes, 4423680 sectors
/dev/sda1 128 4417663 2208768 7 HPFS/NTFS/exFAT

[root@vps /]# mkfs.ext4 /dev/sda1

[root@vps /]# mount /dev/sda1 /mnt/

[root@vps /]# df -h | grep sda


/dev/sda1 2.1G 6.4M 1.9G 1% /mnt

You might also like