Monday, October 17, 2016

iSCSI (Remote Storage)


1.            What is storage?
                The memory where we can store the data, such as files,  directories, ...etc.,  is called the storage.  Storage is mainly two types.   (i)  Local  storage   and   (ii)  Remote  Storage.
                (i)            Local  storage :
                                Local  storage is a storage which is directly connected to our system  and  ready to use.
                                Example :  Local hard disk,  local pen drive,  DAS (Direct  Access  Storage) ... etc.,
                (ii)           Remote  storage :
                                The storage which is not connected to our system directly but allotted some space to our system in remote                 location is called remote storage.
                                Example :  iSCSI  (Internet  Small  Computer  System  Interface),  SAN (Storage Area Network),  NAS (Network                         Area Storage)
2.            What is iSCSI  and  explain it?
                iSCSI is a way of connecting storage devices over a network using TCP/IP. It can be used over a local area        network (LAN), a wide area network (WAN), or the Internet.
                iSCSI devices are disks, tapes, CDs, and other storage devices on another networked computer that you can     connect to. Sometimes these storage devices are part of a network called a Storage Area Network (SAN).
                In the relationship between our computer and the storage device,  our computer is called an initiator because              it initiates the connection to the device, which is called a target.
                iSCSI  provides Remote Block  or  File Storage.  Most data centers keep their storage in centralised  SAN  racks.                 iSCSI  provides  an  inexpensive alternative  to  proprietary  SAN  hardware.
3.            What is the terminology  of iSCSI?
                iSCSI  supports sending  SCSI  commands from clients  (initiators)  over  IP  to SCSI  storage  devices  (targets)  on                 remote  systems  (servers).  iqn  is  a iSCSI  qualified name  or  number. 
                The format of  iqn  is  "iqn.yyyy-mm.label is used to identify  initiators  and                  targets  communicate through  port number  3260.
4.            What is the profile of  iSCSI?
                Package                 :               iscsi*  (for  RHEL-6),  target*  (for  RHEL-7 server)  and  iscsi-utils* (for  RHEL-7 Client)
                Configuration  files              :               /etc/tgt/target.conf (for  RHEL - 6) and   /etc/target/saveconfig.json  (for  RHEL - 7)
                Deamons                               :               tgtd  (for  RHEL-6) and  target  (for  RHEL-7 server)  and  iscsi,  iscsid  (for  RHEL-7)
                Port number          :               3260
5.            How to configure the  iSCSI  server?
                (i)            Create one partition  and  create the LVM with that partition.
                                # fdisk  
                                   :  n (new  partition) --->  Enter  --->  Enter  --->  Enter  --->  +   --->   w  (write the                                                changes into the disk)
                                # partprobe                                                                                                          (to write the changes into the partition table)
                                # pvcreate                                                     (to create the physical volume)
                                # vgcreate                                                                 (to create the volume group)
                                # lvcreate   -s       -n         (to create the logical  volume)
                (ii)           Install the  iSCSI  package  by   # yum  install   scsi-target-utils   -y    command  in  RHEL - 6  or 
                                Install the  iSCSI  package  by   # yum  install   target*   -y    command  in  RHEL - 7.
                (iii) Start the  iSCSI  deamon  and  enable the deamon  at next boot time.
                                # service  tgtd  restart                                                                                          (to start the iSCSI  deamon in  RHEL - 6)
                                # chkconfig  tgtd  on                                                             (to enable the  iSCSI  deamon at next boot  in  RHEL - 6)
                                # systemctl  start  target                                                                   (to start the target  deamon in  RHEL - 7)
                                # systemctl  enable  target                                 (to enable the target  deamon at next boot  in  RHEL - 7)
                (iv) Configure the  iSCSI  storage.
                                In  RHEL - 6 :
                #vi /etc/tgt/targets.conf
default-driver iscsi
     backing-store  
    write-cache off
                                In  RHEL - 7 :
                                # targetcli                                               (to get the configuration window  and  displays  "/>"  prompt  appears)
                                />  ls                                                                                                                       (to see the configuration contents)
                                />   /backstores/block   create        (create the                                                                                                                                                                                                                 block storage)
                                />  /iscsi   create   iqn.2015-06.com.example:server9           (to create the lun number  not the lun  name)
                                />  /iscsi/iqn.2015-06.com.example:server9/tpg1/acls   create   iqn.2015-06.com.example:server9                                                                                                                                             (to create the alias name for client side lun number)
                                />  /iscsi/iqn.2015-06.com.example:server9/tpg1/luns   create   /backstores/block/
                                                                                                                                                (to create the lun using the block storage device)
                                />  /iscsi/iqn.2015-06.com.example:server9/tpg1/portals   create  
                                                                                    (to allot the above created  lun  to the  IP address  and  port number,  ie.,  3260)
                                />  saveconfig                                                                  (to save the  iSCSI  configuration into the configuration  file)
                                />  exit                                                                                                                       (to exit from the configuration window)
                (v)           Restart the  iSCSI  deamons  after the configuration  of  iSCSI  or  target.
                                # service  tgtd  restart                                                                                          (to start the iSCSI  deamon in  RHEL - 6)
                                # chkconfig  tgtd  on                                                             (to enable the  iSCSI  deamon at next boot  in  RHEL - 6)
                                # systemctl  restart  target                                                                                (to start the target  deamon in  RHEL - 7)
                                # systemctl  enable  target                                 (to enable the target  deamon at next boot  in  RHEL - 7)
                (vi) # tgt-admin --show                                                      (to check the  iSCSI  configuration in  RHEL - 6)
                (vii) Add the  iSCSI  service  and  port number to the  IP tables  and  firewall.
                                In  RHEL - 6 :
            # iptables-I INPUT -p tcp-m tcp --dport3260 -jACCEPT
            # iptables-O  OUTPUT   -p tcp-m tcp --dport3260 -jACCEPT
                                # service  iptables  save
                                # service  iptables  restart
                                In  RHEL - 7 :
                                # firewall-cmd    --permanent    --add-port=3260/tcp
                                # firewall-cmd    --complete-reload
6.            How to configure the  iSCSI  client?
                (i) Install  iscsi-initiator-utils package on the client by  # yum install iscsi-initiator-utils* -y  command in RHEL-6.
                                Install the iSCSI  packages  by   # yum  install  iscsi-utils*   -y   command  in  RHEL - 7.
                (ii)           Discover the target LUN’s exported by server using following command. It will provide iqn name with of LUN                   associated with given ip address.
                                # iscsiadm -m discovery -t sendtargets -p                                      (in  RHEL - 6)
                                # iscsiadm   --mode   discoverydb   --type   sendtargets   --portals         (in  RHEL - 7)
                (iii) Open the  iscsi  initiator file  and  put an entry of the above discovered  lun  number in RHEL - 7 only.
                                # vim   /etc/iscsi/initiatorname.iscsi                                                                                    (go to last line and type as below)
                                   Initiatorname=iqn.2015-06.com.example:server9                                                            (save  and  exit  this  file)
                (iv) Restart  and  enable  the  iSCSI  client side deamons.
                                # service  iscsi  restart                                                                                 (to restart the  iscsi  client deamon in  RHEL - 6)
                                # chkconfig  iscsi  on                                                            (to enable the iscsi client deamon at next boot  in  RHEL - 6)
                                # systemctl  restart  iscsid   iscsi                                                             (to restart the  iscsi  client deamons  in  RHEL - 7)
                                # systemctl  enable  iscsid   iscsi                                      (to enable the iscsi client deamons at next boot  in  RHEL - 7)
                (v)           To connect iSCSI target we can use following command , we need to mention server ip and iqn name.
                                In  RHEL - 6 :
                                # iscsiadm -m node -T iqn.2015-06.com.example:server9.target1–p login
                                In  RHEL - 7 :
                                # iscsiadm   --mode   node   --targetname   iqn.2015-06.com.example:server9   --portal   : 3260   --login
                (vi) Check the new remote disk name  by  # fdisk   -l         command.
                (vii) Create the required size partition using  # fdisk,   # partprobe    commands.
                (viii) Create the required  type of file systems  by   # mkfs.ext4       command.
                (ix) Create a mount point for the above file system  by  # mkdir   /mnt/iscsi    command.
                (x)           Open the   /etc/fstab   file  and put en entry of the above file system information.
                                # vim    /etc/fstab
                                   or                /mnt/iscsi            ext4        _netdev       0     0    (save  and  exit  this  file)
                (xi) Mount the all the partitions which are having entries in  /etc/fstab  file  by   # mount   -a   command.
                (xii) Check all the mounted file systems  by   # df   -hT   command.
                (xiii) To disconnect iSCSI target we can use following commands.  Don't forget  that logout from the target.
                                In  RHEL - 6 :
                                # iscsiadm -m node -T iqn.2015-06.com.example:server9.target1–p logout
                                In  RHEL - 7 :
                                # iscsiadm   --mode   node   --targetname   iqn.2015-06.com.example:server9   --portal   : 3260   --logout
                (xiv) Restart the client system  by   # init  6   command.

                (xv) After reboot  check the remote file system  by   # df   -hT    command.

No comments:

Linux, CCNA and MCSE Questions: User Managment

Linux, CCNA and MCSE Questions: User Managment