RC-TOG-03
Setup iSCSI on CentOS 7
Scenario:
Server: [Link]
Client1: [Link] (Windows)
Client2: [Link] (CentOS)
Server: [Link]
#####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 [Link]-mm.<dns-name-in-reverese-order>:<block-name> OR create [Link]-
mm.<IP-in-reverese-order>:<block-name>
/iscsi> create iqn.2019-[Link].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-[Link].10:disk2/tpg1/portals/
RC-TOG-03
# delete [Link] 3260
# create <private-IP-of-Client> 3260
+------------------------------------------------------------------------------------------+
### ACL rule ######
+------------------------------------------------------------------------------------------+
/> cd /iscsi/iqn.2019-[Link].10:disk2/tpg1/
# Create ACL
/iscsi/iqn.2019-[Link].10:disk2/tpg1/> acls/ create iqn.2019-[Link].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-[Link].10:disk2/tpg1/
/iscsi/iqn.2019-[Link].10:disk2/tpg1/> luns/ create /backstores/block/iscsi-disk
+------------------------------------------------------------------------------------------+
/iscsi/iqn.2019-[Link].10:disk2/tpg1/> cd /
/> saveconfig
/> exit
[root@server ~]# systemctl restart [Link]
RC-TOG-03
Client1: [Link] (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: [Link] (CentOS)
[root@vps ~]# yum install iscsi-initiator-utils
[root@vps ~]# iscsiadm -m discovery -t st -p [Link]
[Link]:3260,1 iqn.2019-[Link].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/[Link]
InitiatorName=iqn.2019-[Link].10:client
[root@vps ~]# systemctl restart iscsid
[root@vps ~]# iscsiadm -m node -T iqn.2019-[Link].10:disk2 -p [Link] –l
Logging in to [iface: default, target: iqn.2019-[Link].10:disk2, portal: [Link],3260] (multiple)
Login to [iface: default, target: iqn.2019-[Link].10:disk2, portal: [Link],3260] successful.
[root@vps ~]# dmesg | tail
[792198.587554] scsi [Link] alua: port group 00 rel port 01
[792198.587712] scsi [Link] alua: port group 00 state A non-preferred supports TOlUSNA
[792198.587714] scsi [Link] alua: Attached
[792198.587848] scsi [Link] Attached scsi generic sg1 type 0
[792198.989419] sd [Link] [sda] 4423680 512-byte logical blocks: (2.26 GB/2.10 GiB)
[792198.990600] sd [Link] [sda] Write Protect is off
[792198.990604] sd [Link] [sda] Mode Sense: 43 00 10 08
RC-TOG-03
[792198.990964] sd [Link] [sda] Write cache: enabled, read cache: enabled, supports DPO and FUA
[792199.005153] sda: sda1
[792199.007068] sd [Link] [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