iSCSI Server installation Providing Remote block storage
iSCSI Server installation and configuration RHEL7 Providing Remote Block StorageiSCSI means Internet Small SCSI System Interface, We will use iSCSI connectivity because it is cost effective compare to FC connection. Fibre Connection required separate Hardware such as like FC switch (SAN Switch) FC switch is more cost compare to normal network switch. To provide iSCSI based storage we do not required any extra environment because we can make use of existing Network switches. Let’s see how this technology is going to work for us iscsi server installation and configuration RHEL 7 providing remote block storage.
We have different types of storage’s such as
- DAS – Directly attache storage
- NAS – Network Attached Storage
- SAN – Storage Area Network
- Create one Partition
- Create LVM using that partition (Don’t format)
- Install iSCSI Utilities if not available
- Create LUN and Map to iSCSI client
- iSCSI server = Target. iSCSI Client = Initiator.
Environment
Server IP =192.168.4.27
Client IP = 192.168.4.13
By Installing and configuring this iSCSI Server, We are Turing Linux box as SAN.
Creating Partition
Here i have new HDD called /dev/sdb 10GB with no partitions[root@iSCSIServer ~]# fdisk -l /dev/sdb Disk /dev/sdb: 10.7 GB, 10737418240 bytes, 20971520 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0xea9e3f19 Device Boot Start End Blocks Id SystemStandard partition creation and converting standard to LVM
[root@iSCSIServer ~]# fdisk /dev/sdb Welcome to fdisk (util-linux 2.23.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Command (m for help): n Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p):↵ Using default response p Partition number (1-4, default 1):↵ First sector (2048-20971519, default 2048): ↵ Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519): +2G Partition 1 of type Linux and of size 2 GiB is set Command (m for help): p Disk /dev/sdb: 10.7 GB, 10737418240 bytes, 20971520 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0xea9e3f19 Device Boot Start End Blocks Id System /dev/sdb1 2048 4196351 2097152 83 Linux Command (m for help): t Selected partition 1 Hex code (type L to list all codes): 8e Changed type of partition 'Linux' to 'Linux LVM' Command (m for help): p Disk /dev/sdb: 10.7 GB, 10737418240 bytes, 20971520 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0xea9e3f19 Device Boot Start End Blocks Id System /dev/sdb1 2048 4196351 2097152 8e Linux LVM Command (m for help): wq The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.Update to Kernel when we create new partition, partition table should be up-to date other wise partition will not be listed, use below command to update
[root@iSCSIServer ~]# partprobe /dev/sdb
Creating Physical Volume, Volume Group and Logical Volume[root@iSCSIServer ~]# pvcreate /dev/sdb1 Physical volume "/dev/sdb1" successfully created [root@iSCSIServer ~]# vgcreate VG0 /dev/sdb1 Volume group "VG0" successfully created [root@iSCSIServer ~]# vgs VG #PV #LV #SN Attr VSize VFree VG0 1 0 0 wz--n- 2.00g 2.00g rhel 1 2 0 wz--n- 39.51g 44.00m [root@iSCSIServer ~]# lvcreate -l 100%FREE -n iscsilv VG0 WARNING: ext4 signature detected on /dev/VG0/iscsilv at offset 1080. Wipe it? [y/n]: y Wiping ext4 signature on /dev/VG0/iscsilv. Logical volume "iscsilv" created.
iSCSI Server Installation Providing Remote block storage
As per above output we just created Logical Volume but we did no formatted, Means we did not created any file system in it.[root@iSCSIServer ~]# yum install targetcli* Installed: targetcli.noarch 0:2.1.fb37-3.el7 Dependency Installed: pyparsing.noarch 0:1.5.6-9.el7 python-configshell.noarch 1:1.1.fb14-1.el7 python-kmod.x86_64 0:0.9-4.el7 python-rtslib.noarch 0:2.1.fb50-1.el7 python-urwid.x86_64 0:1.1.1-3.el7 Complete!Targetcli is the command to enter into iscsi console
Create Storage Object and Create IQN (iSCSI Qualified Name) to map LUN. This IQN we should take from iSCSI client machine, either we can create our own.
/> /backstores/block create LUN /dev/VG0/iscsilv /> /iscsi create iqn.2017-03.com.arkit:iSCSIClient1
Go to iSCSI Client Side
Client side we have to install iscsi utilities to connect iscsi server.Install iscsi-initiator-utils-iscsiuio-6.2.0.873-29.el7.x86_64 rpm in iSCSI client
[root@iSCSIClient ~]# yum install iscsi*Get IQN number from Client machine and add to server for mapping disk from server.
[root@iSCSIClient ~]# cat /etc/iscsi/initiatorname.iscsi InitiatorName=iqn.1994-05.com.redhat:ba1abe3b1a4Enable and Start iscsid service
[root@iSCSIClient ~]# systemctl enable iscsid.service ln -s '/usr/lib/systemd/system/iscsid.service' '/etc/systemd/system/multi-user.target.wants/iscsid.service' [root@iSCSIClient ~]# systemctl start iscsid.service [root@iSCSIClient ~]# systemctl status iscsid.service iscsid.service - Open-iSCSI Loaded: loaded (/usr/lib/systemd/system/iscsid.service; enabled) Active: active (running) since Sun 2016-10-23 19:19:49 IST; 11s ago Docs: man:iscsid(8) man:iscsiadm(8) Process: 4144 ExecStart=/usr/sbin/iscsid (code=exited, status=0/SUCCESS) Main PID: 4146 (iscsid) CGroup: /system.slice/iscsid.service ├─4145 /usr/sbin/iscsid └─4146 /usr/sbin/iscsid Oct 23 19:19:49 iSCSIClient iscsid[4145]: iSCSI daemon with pid=4146 started! Oct 23 19:19:49 iSCSIClient systemd[1]: Started Open-iSCSI.
Come Back to iSCSI Server side
Now add client IQN in server so that we can map LUN/> /iscsi create iqn.1994-05.com.redhat:ba1abe3b1a4 Created target iqn.1994-05.com.redhat:ba1abe3b1a4. Created TPG 1. Global pref auto_add_default_portal=true Created default portal listening on all IPs (0.0.0.0), port 3260. /> /iscsi/iqn.1994-05.com.redhat:ba1abe3b1a4/tpg1/acls create iqn.1994-05.com.redhat:ba1abe3b1a4 Created Node ACL for iqn.1994-05.com.redhat:ba1abe3b1a4Create New LUN using existing LVM and map to client
/> /iscsi/iqn.1994-05.com.redhat:ba1abe3b1a4/tpg1/luns create /backstores/block/LUN Created LUN 0. Created LUN 0->0 mapping in node ACL iqn.1994-05.com.redhat:ba1abe3b1a4Portal Creation in Server to map
/> /iscsi/iqn.1994-05.com.redhat:ba1abe3b1a4/tpg1/portals create 192.168.4.14
Using default IP port 3260
Could not create NetworkPortal in configFS.
If your able to see above error while creating portal then do delete default port 0.0.0.0 then create new/> /iscsi/iqn.2017-03.com.arkit:iscsiclient1/tpg1/portals delete 0.0.0.0 ip_port=3260 Deleted network portal 0.0.0.0:3260 /> /iscsi/iqn.1994-05.com.redhat:ba1abe3b1a4/tpg1/portals create 192.168.4.14 Using default IP port 3260 Created network portal 192.168.4.14:3260.Save the configuration
/> saveconfig Last 10 configs saved in /etc/target/backup. Configuration saved to /etc/target/saveconfig.jsonExit from the Console
/> exit Global pref auto_save_on_exit=true Last 10 configs saved in /etc/target/backup. Configuration saved to /etc/target/saveconfig.json
Allow Firewall Port to communicate with iSCSI Client
3260 iscsi default port[root@iSCSIServer ~]# firewall-cmd --permanent --add-port=3260/tcp success [root@iSCSIServer ~]# firewall-cmd --permanent --add-port=3260/udp success [root@iSCSIServer ~]# firewall-cmd --reload success
Client Side to connect iSCSI LUN
[root@desktop4 ~]# iscsiadm -m discovery -t st -p 192.168.4.27 192.168.4.27:3260,1 iqn.1994-05.com.redhat:ba1abe3b1a4 [root@desktop4 ~]# iscsiadm -m node -T iqn.1994-05.com.redhat:ba1abe3b1a4 -p 192.168.4.27 -l Logging in to [iface: default, target: iqn.1994-05.com.redhat:ba1abe3b1a4, portal: 192.168.4.27,3260] (multiple) Login to [iface: default, target: iqn.1994-05.com.redhat:ba1abe3b1a4, portal: 192.168.4.27,3260] successful.After successful mapping of LUN now you can create file system on LUN, To Create file system repeat Step 1 (Creating Partition)
[root@iSCSIClient ~]# partprobe /dev/sda [root@iSCSIClient ~]# mkfs.ext4 /dev/sda1 mke2fs 1.42.9 (28-Dec-2013) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=1024 blocks 327680 inodes, 1308672 blocks 65433 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=1340080128 40 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736 Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done [root@iSCSIClient ~]# mkdir /ravi [root@iSCSIClient ~]# vim /etc/fstab [root@iSCSIClient ~]# cat /etc/fstab |grep sda /dev/sda1 /ravi ext4 _netdev 0 0 [root@iSCSIClient ~]# mount -a [root@iSCSIClient ~]# df -h |grep ravi /dev/sda1 2.0G 20M 2.0G 1% /raviEnjoy…………….